1
0
Fork 0

Merge remote-tracking branch 'dunlop-lello/master'

pull/5463/head
Jordi Boggiano 2016-06-21 11:27:45 +01:00
commit f8c3ef4136
1 changed files with 21 additions and 1 deletions

View File

@ -325,7 +325,27 @@ class GitHubDriver extends VcsDriver
return $this->attemptCloneFallback();
}
$gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'Your GitHub credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
$scopes_issued = array();
$scopes_needed = array();
if (!is_null($headers = $e->getHeaders())) {
// Check if X-OAuth-Scopes and X-Accepted-OAuth-Scopes should let us in...
foreach ($headers as $header) {
$k = substr($header, 0, strpos($header, ":"));
$v = trim(substr($header, strpos($header, ":")+1));
switch ($k) {
case 'X-OAuth-Scopes':
$scopes_issued = explode(" ", $v);
break;
case 'X-Accepted-OAuth-Scopes':
$scopes_needed = explode(" ", $v);
break;
}
}
}
$scopes_failed = array_diff($scopes_needed, $scopes_issued);
if (is_null($headers) || count($scopes_failed)) {
$gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'Your GitHub credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
}
return parent::getContents($url);