1
0
Fork 0

Fix usage of svn user-provided credentials, fixes #7114, closes #7228

pull/7096/merge
Fabio Bas 2018-03-30 18:37:56 +02:00 committed by Jordi Boggiano
parent 5460e5d86f
commit c9aa9c0d2f
1 changed files with 8 additions and 13 deletions

View File

@ -107,9 +107,7 @@ class Svn
// Ensure we are allowed to use this URL by config // Ensure we are allowed to use this URL by config
$this->config->prohibitUrlByConfig($url, $this->io); $this->config->prohibitUrlByConfig($url, $this->io);
$svnCommand = $this->getCommand($command, $url, $path); return $this->executeWithAuthRetry($command, $cwd, $url, $path, $verbose);
return $this->executeWithAuthRetry($svnCommand, $cwd, $path, $verbose);
} }
/** /**
@ -126,18 +124,15 @@ class Svn
*/ */
public function executeLocal($command, $path, $cwd = null, $verbose = false) public function executeLocal($command, $path, $cwd = null, $verbose = false)
{ {
$svnCommand = sprintf('%s %s%s %s', // A local command has no remote url
$command, return $this->executeWithAuthRetry($command, $cwd, '', $path, $verbose);
'--non-interactive ',
$this->getCredentialString(),
ProcessExecutor::escape($path)
);
return $this->executeWithAuthRetry($svnCommand, $cwd, $path, $verbose);
} }
private function executeWithAuthRetry($command, $cwd, $path, $verbose) private function executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose)
{ {
// Regenerate the command at each try, to use the newly user-provided credentials
$command = $this->getCommand($svnCommand, $url, $path);
$output = null; $output = null;
$io = $this->io; $io = $this->io;
$handler = function ($type, $buffer) use (&$output, $io, $verbose) { $handler = function ($type, $buffer) use (&$output, $io, $verbose) {
@ -175,7 +170,7 @@ class Svn
// try to authenticate if maximum quantity of tries not reached // try to authenticate if maximum quantity of tries not reached
if ($this->qtyAuthTries++ < self::MAX_QTY_AUTH_TRIES) { if ($this->qtyAuthTries++ < self::MAX_QTY_AUTH_TRIES) {
// restart the process // restart the process
return $this->executeWithAuthRetry($command, $cwd, $path, $verbose); return $this->executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose);
} }
throw new \RuntimeException( throw new \RuntimeException(