From 4e43f849c7a89dd9c83136a78da19673aba12ee4 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 30 Oct 2019 12:56:08 +0100 Subject: [PATCH] Avoid overwriting credentials with existing ones from git repos, refs #8293 --- src/Composer/Util/Git.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Util/Git.php b/src/Composer/Util/Git.php index 73e3139ce..2da64d80d 100644 --- a/src/Composer/Util/Git.php +++ b/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])); } }