Bladeren bron

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.
Stefan Grootscholten 9 jaren geleden
bovenliggende
commit
591f68288b
1 gewijzigde bestanden met toevoegingen van 7 en 0 verwijderingen
  1. 7 0
      src/Composer/Util/Git.php

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