From 591f68288b4319efc0563b81c99c71c700fa830d Mon Sep 17 00:00:00 2001 From: Stefan Grootscholten Date: Sun, 1 May 2016 11:27:16 +0200 Subject: [PATCH 1/2] Provide a fallback to ssh for https bitbucket URLs. When running in non-interactive mode, there is no way to ask for credentials. If there are no credentials available, no attempt is made to execute the command. This commit provides a fallback to SSH for non authenticated, non-interactive install/updates of bitbucket https URLs. --- src/Composer/Util/Git.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Composer/Util/Git.php b/src/Composer/Util/Git.php index a2b03bbb9..c90fde0b3 100644 --- a/src/Composer/Util/Git.php +++ b/src/Composer/Util/Git.php @@ -141,6 +141,13 @@ class Git if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) { return; } + } else { // Falling back to ssh + $sshUrl = 'git@bitbucket.org:' . $match[2] . '.git'; + $this->io->writeError(' No bitbucket authentication configured. Falling back to ssh.'); + $command = call_user_func($commandCallable, $sshUrl); + if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) { + return; + } } } elseif ($this->isAuthenticationFailure($url, $match)) { // private non-github repo that failed to authenticate if (strpos($match[2], '@')) { From 9b654048ed2c9966b1a7cc505cc52222656f0e96 Mon Sep 17 00:00:00 2001 From: Stefan Grootscholten Date: Sun, 1 May 2016 11:41:48 +0200 Subject: [PATCH 2/2] Fix regex for bitbucket https URLs. If the bitbucket URL has the .git extension, the compiling of the authUrl and sshUrl result in invalid URLs. --- src/Composer/Util/Git.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Util/Git.php b/src/Composer/Util/Git.php index c90fde0b3..54abcb1b8 100644 --- a/src/Composer/Util/Git.php +++ b/src/Composer/Util/Git.php @@ -112,7 +112,7 @@ class Git return; } } - } elseif (preg_match('{^https://(bitbucket.org)/(.*)}', $url, $match)) { //bitbucket oauth + } elseif (preg_match('{^https://(bitbucket\.org)/(.*)(\.git)?$}U', $url, $match)) { //bitbucket oauth $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process); if (!$this->io->hasAuthentication($match[1])) {