mirror of
https://github.com/composer/composer
synced 2025-05-09 16:42:57 +00:00
This commit is contained in:
parent
82e3059c6e
commit
cc33db9257
2 changed files with 7 additions and 8 deletions
|
@ -95,12 +95,14 @@ class GitDriver extends VcsDriver
|
||||||
$this->rootIdentifier = 'master';
|
$this->rootIdentifier = 'master';
|
||||||
|
|
||||||
$gitUtil = new GitUtil($this->io, $this->config, $this->process, new Filesystem());
|
$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)) {
|
||||||
if ($defaultBranch !== null) {
|
$defaultBranch = $gitUtil->getMirrorDefaultBranch($this->url, $this->repoDir, false);
|
||||||
return $this->rootIdentifier = $defaultBranch;
|
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);
|
$this->process->execute('git branch --no-color', $output, $this->repoDir);
|
||||||
$branches = $this->process->splitLines($output);
|
$branches = $this->process->splitLines($output);
|
||||||
if (!in_array('* master', $branches)) {
|
if (!in_array('* master', $branches)) {
|
||||||
|
|
|
@ -63,12 +63,9 @@ GIT;
|
||||||
|
|
||||||
$process
|
$process
|
||||||
->expects([[
|
->expects([[
|
||||||
'cmd' => 'git remote show origin',
|
|
||||||
'stdout' => $stdoutFailure,
|
|
||||||
], [
|
|
||||||
'cmd' => 'git branch --no-color',
|
'cmd' => 'git branch --no-color',
|
||||||
'stdout' => $stdout,
|
'stdout' => $stdout,
|
||||||
]]);
|
]], true);
|
||||||
|
|
||||||
$this->assertSame('main', $driver->getRootIdentifier());
|
$this->assertSame('main', $driver->getRootIdentifier());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue