mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 05:50:55 +01:00
Fix repository interactions for SVN repositories using the SVN protocol with SASL
Summary: also makes the UI more general for this username + password business. Test Plan: - configure a phabricator repository from the svn server @asherwin provided which is configured for svn protocol with SASL - observed phabricator failing without my patch - upgraded my SVN client to support SASL (protip for mac users - http://www.wandisco.com/subversion/download#osx) - applied patch to phabricator - restarted daemons - noted daemon success - diffusion populating nicely Reviewers: epriestley Reviewed By: epriestley CC: aran, Koolvin Maniphest Tasks: T1260 Differential Revision: https://secure.phabricator.com/D2549
This commit is contained in:
parent
a438c87c52
commit
65710ee2d2
2 changed files with 45 additions and 8 deletions
|
@ -231,7 +231,7 @@ final class PhabricatorRepositoryEditController
|
|||
$has_branches = ($is_git || $is_mercurial);
|
||||
$has_local = ($is_git || $is_mercurial);
|
||||
$has_branch_filter = ($is_git);
|
||||
$has_http_support = $is_svn;
|
||||
$has_auth_support = $is_svn;
|
||||
|
||||
if ($request->isFormPost()) {
|
||||
$tracking = ($request->getStr('tracking') == 'enabled' ? true : false);
|
||||
|
@ -442,8 +442,9 @@ final class PhabricatorRepositoryEditController
|
|||
'Enter the <strong>Repository Root</strong> for this SVN repository. '.
|
||||
'You can figure this out by running <tt>svn info</tt> and looking at '.
|
||||
'the value in the <tt>Repository Root</tt> field. It should be a URI '.
|
||||
'and look like <tt>http://svn.example.org/svn/</tt> or '.
|
||||
'<tt>svn+ssh://svn.example.com/svnroot/</tt>';
|
||||
'and look like <tt>http://svn.example.org/svn/</tt>, '.
|
||||
'<tt>svn+ssh://svn.example.com/svnroot/</tt>, or '.
|
||||
'<tt>svn://svn.example.net/svn/</tt>';
|
||||
$inset->appendChild(
|
||||
'<p class="aphront-form-instructions">'.$instructions.'</p>');
|
||||
$uri_label = 'Repository Root';
|
||||
|
@ -489,23 +490,25 @@ final class PhabricatorRepositoryEditController
|
|||
'...specify a path on disk where the daemon should '.
|
||||
'look for a private key.'));
|
||||
|
||||
if ($has_http_support) {
|
||||
if ($has_auth_support) {
|
||||
$inset
|
||||
->appendChild(
|
||||
'<div class="aphront-form-instructions">'.
|
||||
'If you want to connect to this repository over HTTP Basic Auth, '.
|
||||
'If you want to connect to this repository with a username and '.
|
||||
'password, such as over HTTP Basic Auth or SVN with SASL, '.
|
||||
'enter the username and password to use. You can leave these '.
|
||||
'fields blank if the repository does not use HTTP Basic Auth.'.
|
||||
'fields blank if the repository does not use a username and '.
|
||||
'password for authentication.'.
|
||||
'</div>')
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setName('http-login')
|
||||
->setLabel('HTTP Basic Login')
|
||||
->setLabel('Username')
|
||||
->setValue($repository->getDetail('http-login')))
|
||||
->appendChild(
|
||||
id(new AphrontFormPasswordControl())
|
||||
->setName('http-pass')
|
||||
->setLabel('HTTP Basic Password')
|
||||
->setLabel('Password')
|
||||
->setValue($repository->getDetail('http-pass')));
|
||||
}
|
||||
|
||||
|
|
|
@ -228,6 +228,25 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO {
|
|||
throw new Exception(
|
||||
"No support for HTTP Basic Auth in this version control system.");
|
||||
}
|
||||
} else if ($this->shouldUseSVNProtocol()) {
|
||||
switch ($this->getVersionControlSystem()) {
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
||||
$pattern =
|
||||
"svn ".
|
||||
"--non-interactive ".
|
||||
"--no-auth-cache ".
|
||||
"--username %s ".
|
||||
"--password %s ".
|
||||
$pattern;
|
||||
array_unshift(
|
||||
$args,
|
||||
$this->getDetail('http-login'),
|
||||
$this->getDetail('http-pass'));
|
||||
break;
|
||||
default:
|
||||
throw new Exception(
|
||||
"SVN protocol is SVN only.");
|
||||
}
|
||||
} else {
|
||||
switch ($this->getVersionControlSystem()) {
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
||||
|
@ -320,6 +339,17 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO {
|
|||
}
|
||||
}
|
||||
|
||||
public function shouldUseSVNProtocol() {
|
||||
$uri = new PhutilURI($this->getRemoteURI());
|
||||
$protocol = $uri->getProtocol();
|
||||
if ($this->isSVNProtocol($protocol)) {
|
||||
return (bool)$this->getDetail('http-login');
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getPublicRemoteURI() {
|
||||
$uri = new PhutilURI($this->getRemoteURI());
|
||||
|
||||
|
@ -343,6 +373,10 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO {
|
|||
return ($protocol == 'http' || $protocol == 'https');
|
||||
}
|
||||
|
||||
private function isSVNProtocol($protocol) {
|
||||
return ($protocol == 'svn');
|
||||
}
|
||||
|
||||
public function isTracked() {
|
||||
return $this->getDetail('tracking-enabled', false);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue