1
0
Fork 0

Merge remote-tracking branch 'garoevans/intelligent-auth'

Conflicts:
	src/Composer/Util/Git.php
pull/3320/head
Jordi Boggiano 2014-10-07 15:14:59 +01:00
commit d093481ed5
1 changed files with 14 additions and 1 deletions

View File

@ -105,13 +105,26 @@ class Git
preg_match('{(https?://)([^/]+)(.*)$}i', $url, $match) &&
strpos($this->process->getErrorOutput(), 'fatal: Authentication failed') !== false
) {
if (strpos($match[2], '@')) {
list($authParts, $match[2]) = explode('@', $match[2], 2);
}
$storeAuth = false;
if ($this->io->hasAuthentication($match[2])) {
$auth = $this->io->getAuthentication($match[2]);
} elseif ($this->io->isInteractive()) {
$defaultUsername = null;
if (isset($authParts) && $authParts) {
if (false !== strpos($authParts, ':')) {
list($defaultUsername,) = explode(':', $authParts, 2);
} else {
$defaultUsername = $authParts;
}
}
$this->io->write(' Authentication required (<info>'.parse_url($url, PHP_URL_HOST).'</info>):');
$auth = array(
'username' => $this->io->ask(' Username: '),
'username' => $this->io->ask(' Username: ', $defaultUsername),
'password' => $this->io->askAndHideAnswer(' Password: '),
);
$storeAuth = $this->config->get('store-auths');