diff --git a/src/Composer/Util/Git.php b/src/Composer/Util/Git.php index 81c685011..27bfe766f 100644 --- a/src/Composer/Util/Git.php +++ b/src/Composer/Util/Git.php @@ -97,6 +97,7 @@ class Git $auth = null; if ($bypassSshForGitHub || 0 !== $this->process->execute($command, $ignoredOutput, $cwd)) { + $errorMsg = $this->process->getErrorOutput(); // private github repository without ssh key access, try https with auth if (preg_match('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url, $match) || preg_match('{^https?://' . self::getGitHubDomainsRegex($this->config) . '/(.*)}', $url, $match) @@ -117,6 +118,8 @@ class Git if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) { return; } + + $errorMsg = $this->process->getErrorOutput(); } } elseif (preg_match('{^https://(bitbucket\.org)/(.*)(\.git)?$}U', $url, $match)) { //bitbucket oauth $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process); @@ -149,6 +152,8 @@ class Git if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) { return; } + + $errorMsg = $this->process->getErrorOutput(); } else { // Falling back to ssh $sshUrl = 'git@bitbucket.org:' . $match[2] . '.git'; $this->io->writeError(' No bitbucket authentication configured. Falling back to ssh.'); @@ -156,6 +161,8 @@ class Git if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) { return; } + + $errorMsg = $this->process->getErrorOutput(); } } elseif ( preg_match('{^(git)@' . self::getGitLabDomainsRegex($this->config) . ':(.+?)\.git$}i', $url, $match) @@ -186,6 +193,8 @@ class Git if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) { return; } + + $errorMsg = $this->process->getErrorOutput(); } } elseif ($this->isAuthenticationFailure($url, $match)) { // private non-github/gitlab/bitbucket repo that failed to authenticate if (strpos($match[2], '@')) { @@ -224,10 +233,11 @@ class Git return; } + + $errorMsg = $this->process->getErrorOutput(); } } - $errorMsg = $this->process->getErrorOutput(); if ($initialClone) { $this->filesystem->removeDirectory($origCwd); } @@ -248,6 +258,8 @@ class Git }; $this->runCommand($commandCallable, $url, $dir); } catch (\Exception $e) { + $this->io->writeError('Sync mirror failed: ' . $e->getMessage() . '', true, IOInterface::DEBUG); + return false; }