1
0
Fork 0

Only fetch remote default branch for mirrored git repos, not local ones, refs #10949 (#10996)

pull/9792/merge
Jordi Boggiano 2022-08-16 16:53:57 +03:00 committed by GitHub
parent 82e3059c6e
commit cc33db9257
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 8 deletions

View File

@ -95,12 +95,14 @@ class GitDriver extends VcsDriver
$this->rootIdentifier = 'master';
$gitUtil = new GitUtil($this->io, $this->config, $this->process, new Filesystem());
$defaultBranch = $gitUtil->getMirrorDefaultBranch($this->url, $this->repoDir, Filesystem::isLocalPath($this->url));
if (!Filesystem::isLocalPath($this->url)) {
$defaultBranch = $gitUtil->getMirrorDefaultBranch($this->url, $this->repoDir, false);
if ($defaultBranch !== null) {
return $this->rootIdentifier = $defaultBranch;
}
}
// select currently checked out branch if master is not available
// select currently checked out branch as default branch
$this->process->execute('git branch --no-color', $output, $this->repoDir);
$branches = $this->process->splitLines($output);
if (!in_array('* master', $branches)) {

View File

@ -63,12 +63,9 @@ GIT;
$process
->expects([[
'cmd' => 'git remote show origin',
'stdout' => $stdoutFailure,
], [
'cmd' => 'git branch --no-color',
'stdout' => $stdout,
]]);
]], true);
$this->assertSame('main', $driver->getRootIdentifier());
}