Determine auth URLs more intelligently
parent
e77435cd0c
commit
cfc632b019
|
@ -106,13 +106,26 @@ class Git
|
||||||
preg_match('{(https?://)([^/]+)(.*)$}i', $url, $match) &&
|
preg_match('{(https?://)([^/]+)(.*)$}i', $url, $match) &&
|
||||||
strpos($this->process->getErrorOutput(), 'fatal: Authentication failed') !== false
|
strpos($this->process->getErrorOutput(), 'fatal: Authentication failed') !== false
|
||||||
) {
|
) {
|
||||||
|
if (strpos($match[2], '@')) {
|
||||||
|
list($authParts, $match[2]) = explode('@', $match[2], 2);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO this should use an auth manager class that prompts and stores in the config
|
// TODO this should use an auth manager class that prompts and stores in the config
|
||||||
if ($this->io->hasAuthentication($match[2])) {
|
if ($this->io->hasAuthentication($match[2])) {
|
||||||
$auth = $this->io->getAuthentication($match[2]);
|
$auth = $this->io->getAuthentication($match[2]);
|
||||||
} else {
|
} else {
|
||||||
|
$defaultUsername = null;
|
||||||
|
if (isset($authParts) && $authParts) {
|
||||||
|
if (strpos($authParts, ':')) {
|
||||||
|
list($defaultUsername,) = explode(':', $authParts);
|
||||||
|
} else {
|
||||||
|
$defaultUsername = $authParts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->io->write($url.' requires Authentication');
|
$this->io->write($url.' requires Authentication');
|
||||||
$auth = array(
|
$auth = array(
|
||||||
'username' => $this->io->ask('Username: '),
|
'username' => $this->io->ask('Username: ', $defaultUsername),
|
||||||
'password' => $this->io->askAndHideAnswer('Password: '),
|
'password' => $this->io->askAndHideAnswer('Password: '),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue