Pārlūkot izejas kodu

Avoid overwriting credentials with existing ones from git repos, refs #8293

Jordi Boggiano 6 gadi atpakaļ
vecāks
revīzija
4e43f849c7
1 mainītis faili ar 2 papildinājumiem un 2 dzēšanām
  1. 2 2
      src/Composer/Util/Git.php

+ 2 - 2
src/Composer/Util/Git.php

@@ -54,9 +54,9 @@ class Git
         }
 
         if (!$initialClone) {
-            // capture username/password from URL if there is one
+            // capture username/password from URL if there is one and we have no auth configured yet
             $this->process->execute('git remote -v', $output, $cwd);
-            if (preg_match('{^(?:composer|origin)\s+https?://(.+):(.+)@([^/]+)}im', $output, $match)) {
+            if (preg_match('{^(?:composer|origin)\s+https?://(.+):(.+)@([^/]+)}im', $output, $match) && !$this->io->hasAuthentication($match[3])) {
                 $this->io->setAuthentication($match[3], rawurldecode($match[1]), rawurldecode($match[2]));
             }
         }