@@ -126,7 +126,7 @@ public function checkGithubUpdates()
126
126
127
127
$ branch = $ lib ->getBranch ();
128
128
if ($ branch === null ){
129
- $ branch = 'master ' ;
129
+ $ branch = '' ; // not providing any branch will make git return the commits of the default branch
130
130
}
131
131
132
132
$ directoryInRepo = $ lib ->getInRepoPath ();
@@ -160,6 +160,7 @@ public function checkGithubUpdates()
160
160
* Fetches the last commit sha of a repo. `sha` parameter can either be the name of a branch, or a commit
161
161
* sha. In the first case, the commit sha's of the branch are returned. In the second case, the commit sha's
162
162
* of the default branch are returned, as long as the have been written after the provided commit.
163
+ * Not providing any sha/branch will make Git API return the list of commits for the default branch.
163
164
* The API can also use a path parameter, in which case only commits that affect a specific directory are returned.
164
165
*
165
166
* @param $gitOwner
@@ -168,14 +169,16 @@ public function checkGithubUpdates()
168
169
* @param string $path
169
170
* @return mixed
170
171
*/
171
- public function getLastCommitFromGithub ($ gitOwner , $ gitRepo , $ sha = 'master ' , $ path = '' )
172
+ public function getLastCommitFromGithub ($ gitOwner , $ gitRepo , $ sha = '' , $ path = '' )
172
173
{
173
174
/*
174
175
* See the docs here https://developer.github.com/v3/repos/commits/
175
176
* for more info on the json returned.
176
177
*/
177
178
$ url = "https://api.github.com/repos/ " . $ gitOwner . "/ " . $ gitRepo . "/commits " ;
178
- $ queryParams = "?sha= " . $ sha ;
179
+ if ($ path != '' ) {
180
+ $ queryParams = "?sha= " . $ sha ;
181
+ }
179
182
if ($ path != '' ) {
180
183
$ queryParams .= "&path= $ path " ;
181
184
}
0 commit comments