Browse Source

Merge pull request #5272 from stefangr/bitbucket-https-fallback-to-ssh

Bitbucket https fallback to ssh
Jordi Boggiano 9 năm trước cách đây
mục cha
commit
14555de3ca
1 tập tin đã thay đổi với 8 bổ sung1 xóa
  1. 8 1
      src/Composer/Util/Git.php

+ 8 - 1
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])) {
@@ -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], '@')) {