Load auth when updating a git repo mirror, fixes #3243
parent
1fff2afa1f
commit
4d522e40fb
|
@ -56,16 +56,22 @@ class GitDriver extends VcsDriver
|
|||
throw new \InvalidArgumentException('The source URL '.$this->url.' is invalid, ssh URLs should have a port number after ":".'."\n".'Use ssh://git@example.com:22/path or just git@example.com:path if you do not want to provide a password or custom port.');
|
||||
}
|
||||
|
||||
$gitUtil = new GitUtil($this->io, $this->config, $this->process, $fs);
|
||||
|
||||
// update the repo if it is a valid git repository
|
||||
if (is_dir($this->repoDir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $this->repoDir) && trim($output) === '.') {
|
||||
if (0 !== $this->process->execute('git remote update --prune origin', $output, $this->repoDir)) {
|
||||
$this->io->write('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
|
||||
try {
|
||||
$commandCallable = function ($url) {
|
||||
return sprintf('git remote set-url origin %s && git remote update --prune origin', escapeshellarg($url));
|
||||
};
|
||||
$gitUtil->runCommand($commandCallable, $this->url, $this->repoDir);
|
||||
} catch (\Exception $e) {
|
||||
$this->io->write('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$e->getMessage().')</error>');
|
||||
}
|
||||
} else {
|
||||
// clean up directory and do a fresh clone into it
|
||||
$fs->removeDirectory($this->repoDir);
|
||||
|
||||
$gitUtil = new GitUtil($this->io, $this->config, $this->process, $fs);
|
||||
$repoDir = $this->repoDir;
|
||||
$commandCallable = function ($url) use ($repoDir) {
|
||||
return sprintf('git clone --mirror %s %s', escapeshellarg($url), escapeshellarg($repoDir));
|
||||
|
|
Loading…
Reference in New Issue