1
0
Fork 0

Merge pull request #2754 from naderman/github-no-api

Make the github driver behave like git if "no-api" is specified.
pull/2753/merge
Jordi Boggiano 2014-02-25 13:19:03 +01:00
commit c698c8655c
2 changed files with 23 additions and 8 deletions

View File

@ -292,6 +292,11 @@ The VCS driver to be used is detected automatically based on the URL. However,
should you need to specify one for whatever reason, you can use `git`, `svn` or should you need to specify one for whatever reason, you can use `git`, `svn` or
`hg` as the repository type instead of `vcs`. `hg` as the repository type instead of `vcs`.
If you set the `no-api` key to `true` on a github repository it will clone the
repository as it would with any other git repository instead of using the
GitHub API. But unlike using the `git` driver directly, composer will still
attempt to use github's zip files.
#### Subversion Options #### Subversion Options
Since Subversion has no native concept of branches and tags, Composer assumes Since Subversion has no native concept of branches and tags, Composer assumes

View File

@ -52,6 +52,11 @@ class GitHubDriver extends VcsDriver
$this->originUrl = !empty($match[1]) ? $match[1] : $match[2]; $this->originUrl = !empty($match[1]) ? $match[1] : $match[2];
$this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository); $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository);
if (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api']) {
$this->setupGitDriver();
return;
}
$this->fetchRootIdentifier(); $this->fetchRootIdentifier();
} }
@ -405,14 +410,7 @@ class GitHubDriver extends VcsDriver
// GitHub returns 404 for private repositories) and we // GitHub returns 404 for private repositories) and we
// cannot ask for authentication credentials (because we // cannot ask for authentication credentials (because we
// are not interactive) then we fallback to GitDriver. // are not interactive) then we fallback to GitDriver.
$this->gitDriver = new GitDriver( $this->setupGitDriver();
array('url' => $this->generateSshUrl()),
$this->io,
$this->config,
$this->process,
$this->remoteFilesystem
);
$this->gitDriver->initialize();
return; return;
} catch (\RuntimeException $e) { } catch (\RuntimeException $e) {
@ -422,4 +420,16 @@ class GitHubDriver extends VcsDriver
throw $e; throw $e;
} }
} }
protected function setupGitDriver()
{
$this->gitDriver = new GitDriver(
array('url' => $this->generateSshUrl()),
$this->io,
$this->config,
$this->process,
$this->remoteFilesystem
);
$this->gitDriver->initialize();
}
} }