Skip to content

Commit

Permalink
GitDriver: try to fetch default branch form remote using auth (compos…
Browse files Browse the repository at this point in the history
  • Loading branch information
glaubinix authored and emahorvat52 committed Jan 18, 2023
1 parent d9c3115 commit 113ddaa
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/Composer/Repository/Vcs/GitDriver.php
Expand Up @@ -94,15 +94,10 @@ public function getRootIdentifier(): string
if (null === $this->rootIdentifier) {
$this->rootIdentifier = 'master';

if (!(bool) Platform::getEnv('COMPOSER_DISABLE_NETWORK')) {
try {
$this->process->execute('git remote show origin', $output, $this->repoDir);
if (Preg::isMatch('{^\s*HEAD branch:\s(.+)\s*$}m', $output, $matches)) {
return $this->rootIdentifier = $matches[1];
}
} catch (\Exception $e) {
$this->io->writeError('<error>Failed to fetch root identifier from remote: ' . $e->getMessage() . '</error>', true, IOInterface::DEBUG);
}
$gitUtil = new GitUtil($this->io, $this->config, $this->process, new Filesystem());
$defaultBranch = $gitUtil->getMirrorDefaultBranch($this->url, $this->repoDir, Filesystem::isLocalPath($this->url));
if ($defaultBranch !== null) {
return $this->rootIdentifier = $defaultBranch;
}

// select currently checked out branch if master is not available
Expand Down

0 comments on commit 113ddaa

Please sign in to comment.