Skip to content

Commit

Permalink
quick workaround for Github API limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Adam authored and Seldaek committed Oct 18, 2012
1 parent 3742459 commit 1bd5d88
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Composer/Repository/Vcs/GitHubDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,19 @@ protected function fetchRootIdentifier()
$this->io->setAuthorization($this->originUrl, $username, $password);
break;

case 403:
if (!$this->io->hasAuthorization($this->originUrl)) {
if (!$this->io->isInteractive()) {
$this->io->write('<error>API limit exhausted. Failed to clone the '.$this->generateSshUrl().' repository, try running in interactive mode so that you can enter your username and password to increase the API limit</error>');
throw $e;
}
$this->io->write('API limit exhausted. Authentication required for larger API limit (<info>'.$this->url.'</info>):');
$username = $this->io->ask('Username: ');
$password = $this->io->askAndHideAnswer('Password: ');
$this->io->setAuthorization($this->originUrl, $username, $password);
}
break;

default:
throw $e;
break;
Expand Down
6 changes: 6 additions & 0 deletions src/Composer/Util/RemoteFilesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ protected function callbackGet($notificationCode, $severity, $message, $messageC
}
break;

case STREAM_NOTIFY_AUTH_RESULT:
if (403 === $messageCode) {
throw new TransportException($message, 403);
}
break;

case STREAM_NOTIFY_FILE_SIZE_IS:
if ($this->bytesMax < $bytesMax) {
$this->bytesMax = $bytesMax;
Expand Down

0 comments on commit 1bd5d88

Please sign in to comment.