From 243ee9b1e41c15a32df430383339e541fed255b6 Mon Sep 17 00:00:00 2001 From: Stephan Vock Date: Wed, 12 Feb 2020 10:13:22 +0000 Subject: [PATCH] Git: log error for sync mirror with existing local copy --- src/Composer/Util/Git.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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; }