Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php b/src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php
index 91d3715d2d..414f8bd94e 100644
--- a/src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php
+++ b/src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php
@@ -1,645 +1,702 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class PhabricatorRepositoryEditController
extends PhabricatorRepositoryController {
private $id;
private $view;
private $repository;
private $sideNav;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
$this->view = idx($data, 'view');
}
public function processRequest() {
$request = $this->getRequest();
$repository = id(new PhabricatorRepository())->load($this->id);
if (!$repository) {
return new Aphront404Response();
}
$views = array(
'basic' => 'Basics',
'tracking' => 'Tracking',
);
$vcs = $repository->getVersionControlSystem();
if ($vcs == DifferentialRevisionControlSystem::GIT) {
if (!$repository->getDetail('github-token')) {
$token = substr(base64_encode(Filesystem::readRandomBytes(8)), 0, 8);
$repository->setDetail('github-token', $token);
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
$repository->save();
unset($unguarded);
}
$views['github'] = 'GitHub';
}
$this->repository = $repository;
if (!isset($views[$this->view])) {
reset($views);
$this->view = key($views);
}
$nav = new AphrontSideNavView();
foreach ($views as $view => $name) {
$nav->addNavItem(
phutil_render_tag(
'a',
array(
'class' => ($view == $this->view
? 'aphront-side-nav-selected'
: null),
'href' => '/repository/edit/'.$repository->getID().'/'.$view.'/',
),
phutil_escape_html($name)));
}
$this->sideNav = $nav;
switch ($this->view) {
case 'basic':
return $this->processBasicRequest();
case 'tracking':
return $this->processTrackingRequest();
case 'github':
return $this->processGithubRequest();
default:
throw new Exception("Unknown view.");
}
}
protected function processBasicRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$repository = $this->repository;
$repository_id = $repository->getID();
$errors = array();
$e_name = true;
if ($request->isFormPost()) {
$repository->setName($request->getStr('name'));
if (!strlen($repository->getName())) {
$e_name = 'Required';
$errors[] = 'Repository name is required.';
} else {
$e_name = null;
}
$repository->setDetail('description', $request->getStr('description'));
if (!$errors) {
$repository->save();
return id(new AphrontRedirectResponse())
->setURI('/repository/edit/'.$repository_id.'/basic/?saved=true');
}
}
$error_view = null;
if ($errors) {
$error_view = new AphrontErrorView();
$error_view->setErrors($errors);
$error_view->setTitle('Form Errors');
} else if ($request->getStr('saved')) {
$error_view = new AphrontErrorView();
$error_view->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
$error_view->setTitle('Changes Saved');
$error_view->appendChild(
'Repository changes were saved.');
}
$form = new AphrontFormView();
$form
->setUser($user)
->setAction('/repository/edit/'.$repository->getID().'/')
->appendChild(
id(new AphrontFormTextControl())
->setLabel('Name')
->setName('name')
->setValue($repository->getName())
->setError($e_name)
->setCaption('Human-readable repository name.'))
->appendChild(
id(new AphrontFormTextAreaControl())
->setLabel('Description')
->setName('description')
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT)
->setValue($repository->getDetail('description')))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Callsign')
->setName('callsign')
->setValue($repository->getCallsign()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Type')
->setName('type')
->setValue($repository->getVersionControlSystem()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('ID')
->setValue($repository->getID()))
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('PHID')
->setValue($repository->getPHID()))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Save'));
$panel = new AphrontPanelView();
$panel->setHeader('Edit Repository');
$panel->appendChild($form);
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$nav = $this->sideNav;
$nav->appendChild($error_view);
$nav->appendChild($panel);
return $this->buildStandardPageResponse(
$nav,
array(
'title' => 'Edit Repository',
));
}
private function processTrackingRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$repository = $this->repository;
$repository_id = $repository->getID();
$errors = array();
$e_uri = null;
$e_path = null;
$is_git = false;
$is_svn = false;
+ $e_ssh_key = null;
+ $e_ssh_keyfile = null;
+
switch ($repository->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
$is_git = true;
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$is_svn = true;
break;
default:
throw new Exception("Unsupported VCS!");
}
if ($request->isFormPost()) {
$tracking = ($request->getStr('tracking') == 'enabled' ? true : false);
$repository->setDetail('tracking-enabled', $tracking);
$repository->setDetail('remote-uri', $request->getStr('uri'));
if ($is_git) {
$repository->setDetail('local-path', $request->getStr('path'));
}
$repository->setDetail(
'pull-frequency',
max(1, $request->getInt('frequency')));
if ($is_git) {
$repository->setDetail(
'default-branch',
$request->getStr('default-branch'));
}
$repository->setDetail(
'default-owners-path',
$request->getStr(
'default-owners-path',
'/'));
$repository->setDetail('ssh-login', $request->getStr('ssh-login'));
$repository->setDetail('ssh-key', $request->getStr('ssh-key'));
+ $repository->setDetail('ssh-keyfile', $request->getStr('ssh-keyfile'));
+
+ $repository->setDetail('http-login', $request->getStr('http-login'));
+ $repository->setDetail('http-pass', $request->getStr('http-pass'));
+
+ if ($repository->getDetail('ssh-key') &&
+ $repository->getDetail('ssh-keyfile')) {
+ $errors[] =
+ "Specify only one of 'SSH Private Key' and 'SSH Private Key File', ".
+ "not both.";
+ $e_ssh_key = 'Choose Only One';
+ $e_ssh_keyfile = 'Choose Only One';
+ }
$repository->setDetail(
'herald-disabled',
$request->getInt('herald-disabled', 0));
if ($is_svn) {
$repository->setUUID($request->getStr('uuid'));
$subpath = ltrim($request->getStr('svn-subpath'), '/');
if ($subpath) {
$subpath = rtrim($subpath, '/').'/';
}
$repository->setDetail('svn-subpath', $subpath);
}
$repository->setDetail(
'detail-parser',
$request->getStr(
'detail-parser',
'PhabricatorRepositoryDefaultCommitMessageDetailParser'));
if ($tracking) {
if (!$repository->getDetail('remote-uri')) {
$e_uri = 'Required';
$errors[] = "Repository URI is required.";
} else if ($is_svn &&
!preg_match('@/$@', $repository->getDetail('remote-uri'))) {
$e_uri = 'Invalid';
$errors[] = 'Subversion Repository Root must end in a slash ("/").';
} else {
$e_uri = null;
}
if ($is_git) {
if (!$repository->getDetail('local-path')) {
$e_path = 'Required';
$errors[] = "Local path is required.";
} else {
$e_path = null;
}
}
}
if (!$errors) {
$repository->save();
return id(new AphrontRedirectResponse())
->setURI('/repository/edit/'.$repository_id.'/tracking/?saved=true');
}
}
$error_view = null;
if ($errors) {
$error_view = new AphrontErrorView();
$error_view->setErrors($errors);
$error_view->setTitle('Form Errors');
} else if ($request->getStr('saved')) {
$error_view = new AphrontErrorView();
$error_view->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
$error_view->setTitle('Changes Saved');
$error_view->appendChild(
'Tracking changes were saved. You may need to restart the daemon '.
'before changes will take effect.');
}
switch ($repository->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
$is_git = true;
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
$is_svn = true;
break;
}
$doc_href = PhabricatorEnv::getDoclink('article/Diffusion_User_Guide.html');
$user_guide_link = phutil_render_tag(
'a',
array(
'href' => $doc_href,
),
'Diffusion User Guide');
$form = new AphrontFormView();
$form
->setUser($user)
->setAction('/repository/edit/'.$repository->getID().'/tracking/')
->appendChild(
'<p class="aphront-form-instructions">Phabricator can track '.
'repositories, importing commits as they happen and notifying '.
'Differential, Diffusion, Herald, and other services. To enable '.
'tracking for a repository, configure it here and then start (or '.
'restart) the daemons. More information is available in the '.
'<strong>'.$user_guide_link.'</strong>.</p>');
$form
->appendChild(
'<h1>Basics</h1><div class="aphront-form-inset">')
->appendChild(
id(new AphrontFormStaticControl())
->setLabel('Repository Name')
->setValue($repository->getName()))
->appendChild(
id(new AphrontFormSelectControl())
->setName('tracking')
->setLabel('Tracking')
->setOptions(array(
'disabled' => 'Disabled',
'enabled' => 'Enabled',
))
->setValue(
$repository->getDetail('tracking-enabled')
? 'enabled'
: 'disabled'))
->appendChild('</div>');
$form->appendChild(
'<h1>Remote URI</h1>'.
'<div class="aphront-form-inset">');
$uri_label = 'Repository URI';
if ($is_git) {
$instructions =
'Enter the URI to clone this repository from. It should look like '.
'<tt>git@github.com:example/example.git</tt> or '.
'<tt>ssh://user@host.com/git/example.git</tt>';
$form->appendChild(
'<p class="aphront-form-instructions">'.$instructions.'</p>');
} else if ($is_svn) {
$instructions =
'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>';
$form->appendChild(
'<p class="aphront-form-instructions">'.$instructions.'</p>');
$uri_label = 'Repository Root';
}
$form
->appendChild(
id(new AphrontFormTextControl())
->setName('uri')
->setLabel($uri_label)
->setID('remote-uri')
->setValue($repository->getDetail('remote-uri'))
->setError($e_uri));
$form->appendChild(
'<div class="aphront-form-instructions">'.
'If you want to connect to this repository over SSH, enter the '.
'username and private key to use. You can leave these fields blank if '.
- 'the repository does not use SSH. <strong>NOTE: This feature is not '.
- 'yet fully supported.</strong>'.
+ 'the repository does not use SSH.'.
+ ' <strong>NOTE: This feature is not yet fully supported.</strong>'.
'</div>');
$form
->appendChild(
id(new AphrontFormTextControl())
->setName('ssh-login')
->setLabel('SSH User')
->setValue($repository->getDetail('ssh-login')))
->appendChild(
id(new AphrontFormTextAreaControl())
->setName('ssh-key')
->setLabel('SSH Private Key')
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT)
- ->setValue($repository->getDetail('ssh-key')))
+ ->setValue($repository->getDetail('ssh-key'))
+ ->setError($e_ssh_key)
+ ->setCaption('Specify the entire private key, <em>or</em>...'))
->appendChild(
- id(new AphrontFormMarkupControl())
- ->setLabel('Test Connection')
- ->setValue(
- 'To test these credentials, <strong>save this form</strong> and '.
- 'then run: <code>phabricator/scripts/repository/test_connection'.
- '.php '.phutil_escape_html($repository->getCallsign()).'</code>'));
+ id(new AphrontFormTextControl())
+ ->setName('ssh-keyfile')
+ ->setLabel('SSH Private Key File')
+ ->setValue($repository->getDetail('ssh-keyfile'))
+ ->setError($e_ssh_keyfile)
+ ->setCaption(
+ '...specify a path on disk where the daemon should '.
+ 'look for a private key.'));
+
+ $supports_http = $is_svn;
+
+ if ($supports_http) {
+ $form
+ ->appendChild(
+ '<div class="aphront-form-instructions">'.
+ 'If you want to connect to this repository over HTTP Basic Auth, '.
+ 'enter the username and password to use. You can leave these '.
+ 'fields blank if the repository does not use HTTP Basic Auth.'.
+ ' <strong>NOTE: This feature is not yet fully supported.</strong>'.
+ '</div>')
+ ->appendChild(
+ id(new AphrontFormTextControl())
+ ->setName('http-login')
+ ->setLabel('HTTP Basic Login')
+ ->setValue($repository->getDetail('http-login')))
+ ->appendChild(
+ id(new AphrontFormTextControl())
+ ->setName('http-pass')
+ ->setLabel('HTTP Basic Password')
+ ->setValue($repository->getDetail('http-pass')));
+ }
+
+ $form
+ ->appendChild(
+ '<div class="aphront-form-important">'.
+ 'To test your authentication configuration, <strong>save this '.
+ 'form</strong> and then run this script:'.
+ '<code>'.
+ 'phabricator/ $ ./scripts/repository/test_connection.php '.
+ phutil_escape_html($repository->getCallsign()).
+ '</code>'.
+ 'This will verify that your configuration is correct and the '.
+ 'daemons can connect to the remote repository and pull changes '.
+ 'from it.'.
+ '</div>');
$form->appendChild('</div>');
$form->appendChild(
'<h1>Importing Repository Information</h1>'.
'<div class="aphront-form-inset">');
if ($is_git) {
$form->appendChild(
'<p class="aphront-form-instructions">Select a path on local disk '.
'which the daemons should <tt>git clone</tt> the repository into. '.
'This must be readable and writable by the daemons, and readable by '.
'the webserver. The daemons will <tt>git fetch</tt> and keep this '.
'repository up to date.</p>');
$form->appendChild(
id(new AphrontFormTextControl())
->setName('path')
->setLabel('Local Path')
->setValue($repository->getDetail('local-path'))
->setError($e_path));
} else if ($is_svn) {
$form->appendChild(
'<p class="aphront-form-instructions">If you only want to parse one '.
'subpath of the repository, specify it here, relative to the '.
'repository root (e.g., <tt>trunk/</tt> or <tt>projects/wheel/</tt>). '.
'If you want to parse multiple subdirectories, create a separate '.
'Phabricator repository for each one.</p>');
$form->appendChild(
id(new AphrontFormTextControl())
->setName('svn-subpath')
->setLabel('Subpath')
->setValue($repository->getDetail('svn-subpath'))
->setError($e_path));
}
$form
->appendChild(
id(new AphrontFormTextControl())
->setName('frequency')
->setLabel('Pull Frequency')
->setValue($repository->getDetail('pull-frequency', 15))
->setCaption(
'Number of seconds daemon should sleep between requests. Larger '.
'numbers reduce load but also decrease responsiveness.'));
$form->appendChild('</div>');
$form->appendChild(
'<h1>Application Configuration</h1>'.
'<div class="aphront-form-inset">');
if ($is_git) {
$form
->appendChild(
id(new AphrontFormTextControl())
->setName('default-branch')
->setLabel('Default Branch')
->setValue(
$repository->getDetail(
'default-branch',
'origin/master'))
->setCaption(
'Default <strong>remote</strong> branch to show in Diffusion.'));
}
$form
->appendChild(
id(new AphrontFormTextControl())
->setName('default-owners-path')
->setLabel('Default Owners Path')
->setValue(
$repository->getDetail(
'default-owners-path',
'/'))
->setCaption('Default path in Owners tool.'));
$form
->appendChild(
id(new AphrontFormSelectControl())
->setName('herald-disabled')
->setLabel('Herald Enabled')
->setValue($repository->getDetail('herald-disabled', 0))
->setOptions(
array(
0 => 'Enabled - Send Email',
1 => 'Disabled - Do Not Send Email',
))
->setCaption(
'You can temporarily disable Herald commit notifications when '.
'reparsing a repository or importing a new repository.'));
$parsers = id(new PhutilSymbolLoader())
->setAncestorClass('PhabricatorRepositoryCommitMessageDetailParser')
->selectSymbolsWithoutLoading();
$parsers = ipull($parsers, 'name', 'name');
$form
->appendChild(
'<p class="aphront-form-instructions">If you extend the commit '.
'message format, you can provide a new parser which will extract '.
'extra information from it when commits are imported. This is an '.
'advanced feature, and using the default parser will be suitable '.
'in most cases.</p>')
->appendChild(
id(new AphrontFormSelectControl())
->setName('detail-parser')
->setLabel('Detail Parser')
->setOptions($parsers)
->setValue(
$repository->getDetail(
'detail-parser',
'PhabricatorRepositoryDefaultCommitMessageDetailParser')));
if ($is_svn) {
$form
->appendChild(
id(new AphrontFormTextControl())
->setName('uuid')
->setLabel('UUID')
->setValue($repository->getUUID())
->setCaption('Repository UUID from <tt>svn info</tt>.'));
}
$form->appendChild('</div>');
$form
->appendChild(
id(new AphrontFormSubmitControl())
->setValue('Save Configuration'));
$panel = new AphrontPanelView();
$panel->setHeader('Repository Tracking');
$panel->appendChild($form);
$panel->setWidth(AphrontPanelView::WIDTH_WIDE);
$nav = $this->sideNav;
$nav->appendChild($error_view);
$nav->appendChild($panel);
return $this->buildStandardPageResponse(
$nav,
array(
'title' => 'Edit Repository Tracking',
));
}
private function processGithubRequest() {
$request = $this->getRequest();
$repository = $this->repository;
$repository_id = $repository->getID();
$token = $repository->getDetail('github-token');
$path = '/github-post-receive/'.$repository_id.'/'.$token.'/';
$post_uri = PhabricatorEnv::getURI($path);
$gitform = new AphrontFormLayoutView();
$gitform
->setBackgroundShading(true)
->setPadded(true)
->appendChild(
'<p class="aphront-form-instructions">You can configure GitHub to '.
'notify Phabricator after changes are pushed. Log into GitHub, go '.
'to "Admin" &rarr; "Service Hooks" &rarr; "Post-Receive URLs", and '.
'add this URL to the list. Obviously, this will only work if your '.
'Phabricator installation is accessible from the internet.</p>')
->appendChild(
'<p class="aphront-form-instructions"> If things are working '.
'properly, push notifications should appear below once you make some '.
'commits.</p>')
->appendChild(
id(new AphrontFormTextControl())
->setLabel('URL')
->setCaption('Set this as a GitHub "Post-Receive URL".')
->setValue($post_uri))
->appendChild('<br /><br />')
->appendChild('<h1>Recent Commit Notifications</h1>');
$notifications = id(new PhabricatorRepositoryGitHubNotification())
->loadAllWhere(
'repositoryPHID = %s ORDER BY id DESC limit 10',
$repository->getPHID());
$rows = array();
foreach ($notifications as $notification) {
$rows[] = array(
phutil_escape_html($notification->getRemoteAddress()),
phabricator_format_timestamp($notification->getDateCreated()),
$notification->getPayload()
? phutil_escape_html(substr($notification->getPayload(), 0, 32).'...')
: 'Empty',
);
}
$notification_table = new AphrontTableView($rows);
$notification_table->setHeaders(
array(
'Remote Address',
'Received',
'Payload',
));
$notification_table->setColumnClasses(
array(
null,
null,
'wide',
));
$notification_table->setNoDataString(
'Phabricator has not yet received any commit notifications for this '.
'repository from GitHub.');
$gitform->appendChild($notification_table);
$github = new AphrontPanelView();
$github->setHeader('GitHub Integration');
$github->appendChild($gitform);
$github->setWidth(AphrontPanelView::WIDTH_FORM);
$nav = $this->sideNav;
$nav->appendChild($github);
return $this->buildStandardPageResponse(
$nav,
array(
'title' => 'Repository Github Integration',
));
}
}
diff --git a/src/applications/repository/controller/edit/__init__.php b/src/applications/repository/controller/edit/__init__.php
index 4f61cde518..7da55db338 100644
--- a/src/applications/repository/controller/edit/__init__.php
+++ b/src/applications/repository/controller/edit/__init__.php
@@ -1,38 +1,37 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('phabricator', 'aphront/response/404');
phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'aphront/writeguard');
phutil_require_module('phabricator', 'applications/differential/constants/revisioncontrolsystem');
phutil_require_module('phabricator', 'applications/repository/constants/repositorytype');
phutil_require_module('phabricator', 'applications/repository/controller/base');
phutil_require_module('phabricator', 'applications/repository/storage/githubnotification');
phutil_require_module('phabricator', 'applications/repository/storage/repository');
phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phabricator', 'view/form/base');
-phutil_require_module('phabricator', 'view/form/control/markup');
phutil_require_module('phabricator', 'view/form/control/select');
phutil_require_module('phabricator', 'view/form/control/static');
phutil_require_module('phabricator', 'view/form/control/submit');
phutil_require_module('phabricator', 'view/form/control/text');
phutil_require_module('phabricator', 'view/form/control/textarea');
phutil_require_module('phabricator', 'view/form/error');
phutil_require_module('phabricator', 'view/form/layout');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phabricator', 'view/layout/sidenav');
phutil_require_module('phabricator', 'view/utils');
phutil_require_module('phutil', 'filesystem');
phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'symbols');
phutil_require_module('phutil', 'utils');
phutil_require_source('PhabricatorRepositoryEditController.php');
diff --git a/src/applications/repository/storage/repository/PhabricatorRepository.php b/src/applications/repository/storage/repository/PhabricatorRepository.php
index bb1181ceea..d0e5e29808 100644
--- a/src/applications/repository/storage/repository/PhabricatorRepository.php
+++ b/src/applications/repository/storage/repository/PhabricatorRepository.php
@@ -1,239 +1,283 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class PhabricatorRepository extends PhabricatorRepositoryDAO {
const TABLE_PATH = 'repository_path';
const TABLE_PATHCHANGE = 'repository_pathchange';
const TABLE_FILESYSTEM = 'repository_filesystem';
const TABLE_SUMMARY = 'repository_summary';
const TABLE_BADCOMMIT = 'repository_badcommit';
protected $phid;
protected $name;
protected $callsign;
protected $uuid;
protected $versionControlSystem;
protected $details = array();
private $sshKeyfile;
public function getConfiguration() {
return array(
self::CONFIG_AUX_PHID => true,
self::CONFIG_SERIALIZATION => array(
'details' => self::SERIALIZATION_JSON,
),
) + parent::getConfiguration();
}
public function generatePHID() {
return PhabricatorPHID::generateNewPHID(
PhabricatorPHIDConstants::PHID_TYPE_REPO);
}
public function getDetail($key, $default = null) {
return idx($this->details, $key, $default);
}
public function setDetail($key, $value) {
$this->details[$key] = $value;
return $this;
}
public function getRemoteURI() {
$raw_uri = $this->getDetail('remote-uri');
$vcs = $this->getVersionControlSystem();
$is_git = ($vcs == PhabricatorRepositoryType::REPOSITORY_TYPE_GIT);
// If there's no protocol (git implicit SSH) reformat the URI to be a
// normal URI. These git URIs look like "user@domain.com:path" instead of
// "ssh://user@domain/path".
$uri = new PhutilURI($raw_uri);
if ($is_git && !$uri->getProtocol()) {
list($domain, $path) = explode(':', $raw_uri, 2);
$uri = new PhutilURI('ssh://'.$domain.'/'.$path);
}
if ($this->isSSHProtocol($uri->getProtocol())) {
if ($this->getSSHLogin()) {
$uri->setUser($this->getSSHLogin());
}
}
return (string)$uri;
}
public function getLocalPath() {
return $this->getDetail('local-path');
}
public function execRemoteCommand($pattern /*, $arg, ... */) {
$args = func_get_args();
$args = $this->formatRemoteCommand($args);
return call_user_func_array('exec_manual', $args);
}
public function execxRemoteCommand($pattern /*, $arg, ... */) {
$args = func_get_args();
$args = $this->formatRemoteCommand($args);
return call_user_func_array('execx', $args);
}
public function passthruRemoteCommand($pattern /*, $arg, ... */) {
$args = func_get_args();
$args = $this->formatRemoteCommand($args);
return call_user_func_array('phutil_passthru', $args);
}
public function execLocalCommand($pattern /*, $arg, ... */) {
$args = func_get_args();
$args = $this->formatLocalCommand($args);
return call_user_func_array('exec_manual', $args);
}
public function execxLocalCommand($pattern /*, $arg, ... */) {
$args = func_get_args();
$args = $this->formatLocalCommand($args);
return call_user_func_array('execx', $args);
}
public function passthruLocalCommand($pattern /*, $arg, ... */) {
$args = func_get_args();
$args = $this->formatLocalCommand($args);
return call_user_func_array('phutil_passthru', $args);
}
private function formatRemoteCommand(array $args) {
$pattern = $args[0];
$args = array_slice($args, 1);
if ($this->shouldUseSSH()) {
switch ($this->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
- $pattern = "SVN_SSH=%s svn {$pattern}";
+ $pattern = "SVN_SSH=%s svn --non-interactive {$pattern}";
array_unshift(
$args,
csprintf(
'ssh -l %s -i %s',
$this->getSSHLogin(),
$this->getSSHKeyfile()));
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
$command = call_user_func_array(
'csprintf',
array_merge(
array(
"(ssh-add %s && git {$pattern})",
$this->getSSHKeyfile(),
),
$args));
$pattern = "ssh-agent sh -c %s";
$args = array($command);
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
$pattern = "hg --config ui.ssh=%s {$pattern}";
array_unshift(
$args,
csprintf(
'ssh -l %s -i %s',
$this->getSSHLogin(),
$this->getSSHKeyfile()));
break;
default:
throw new Exception("Unrecognized version control system.");
}
+ } else if ($this->shouldUseHTTP()) {
+ switch ($this->getVersionControlSystem()) {
+ case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
+ $pattern =
+ "svn ".
+ "--non-interactive ".
+ "--no-auth-cache ".
+ "--trust-server-cert ".
+ "--username %s ".
+ "--password %s ".
+ $pattern;
+ array_unshift(
+ $args,
+ $this->getDetail('http-login'),
+ $this->getDetail('http-pass'));
+ break;
+ default:
+ throw new Exception(
+ "No support for HTTP Basic Auth in this version control system.");
+ }
} else {
switch ($this->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
- $pattern = "svn {$pattern}";
+ $pattern = "svn --non-interactive {$pattern}";
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
$pattern = "git {$pattern}";
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
$pattern = "hg {$pattern}";
break;
default:
throw new Exception("Unrecognized version control system.");
}
}
array_unshift($args, $pattern);
return $args;
}
private function formatLocalCommand(array $args) {
$pattern = $args[0];
$args = array_slice($args, 1);
switch ($this->getVersionControlSystem()) {
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
- $pattern = "(cd %s && svn {$pattern})";
+ $pattern = "(cd %s && svn --non-interactive {$pattern})";
array_unshift($args, $this->getLocalPath());
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
$pattern = "(cd %s && git {$pattern})";
array_unshift($args, $this->getLocalPath());
break;
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
$pattern = "(cd %s && hg {$pattern})";
array_unshift($args, $this->getLocalPath());
break;
default:
throw new Exception("Unrecognized version control system.");
}
array_unshift($args, $pattern);
return $args;
}
private function getSSHLogin() {
return $this->getDetail('ssh-login');
}
private function getSSHKeyfile() {
- if (!$this->sshKeyfile) {
- $keyfile = new TempFile('phabricator-repository-ssh-key');
- chmod($keyfile, 0600);
- Filesystem::writeFile($keyfile, $this->getDetail('ssh-key'));
- $this->sshKeyfile = $keyfile;
+ if ($this->sshKeyfile === null) {
+ $key = $this->getDetail('ssh-key');
+ $keyfile = $this->getDetail('ssh-keyfile');
+ if ($keyfile) {
+ // Make sure we can read the file, that it exists, etc.
+ Filesystem::readFile($keyfile);
+ $this->sshKeyfile = $keyfile;
+ } else if ($key) {
+ $keyfile = new TempFile('phabricator-repository-ssh-key');
+ chmod($keyfile, 0600);
+ Filesystem::writeFile($keyfile, $key);
+ $this->sshKeyfile = $keyfile;
+ } else {
+ $this->sshKeyfile = '';
+ }
}
return (string)$this->sshKeyfile;
}
public function shouldUseSSH() {
$uri = new PhutilURI($this->getRemoteURI());
$protocol = $uri->getProtocol();
if ($this->isSSHProtocol($protocol)) {
- return (bool)$this->getDetail('ssh-key');
+ return (bool)$this->getSSHKeyfile();
+ } else {
+ return false;
+ }
+ }
+
+ public function shouldUseHTTP() {
+ $uri = new PhutilURI($this->getRemoteURI());
+ $protocol = $uri->getProtocol();
+ if ($this->isHTTPProtocol($protocol)) {
+ return (bool)$this->getDetail('http-login');
} else {
return false;
}
}
private function isSSHProtocol($protocol) {
return ($protocol == 'ssh' || $protocol == 'svn+ssh');
}
+ private function isHTTPProtocol($protocol) {
+ return ($protocol == 'http' || $protocol == 'https');
+ }
+
}
diff --git a/webroot/rsrc/css/aphront/form-view.css b/webroot/rsrc/css/aphront/form-view.css
index 6c228cc51a..f05e957d3f 100644
--- a/webroot/rsrc/css/aphront/form-view.css
+++ b/webroot/rsrc/css/aphront/form-view.css
@@ -1,140 +1,152 @@
/**
* @provides aphront-form-view-css
*/
/**
* These styles are overrides for .aphront-form-view
*/
.aphront-form-view-shaded {
border: 1px solid #c4c4c4;
background: #e7e7e7;
}
.aphront-form-view-padded {
padding: 1em;
}
.aphront-form-view label.aphront-form-label {
padding-top: 4px;
width: 19%;
float: left;
text-align: right;
font-weight: bold;
font-size: 13px;
color: #666666;
}
.aphront-form-input {
margin-left: 20%;
margin-right: 25%;
width: 55%;
}
.aphront-form-error {
width: 23%;
float: right;
color: #aa0000;
font-weight: bold;
padding-top: 4px;
}
.aphront-form-input input,
.aphront-form-input textarea {
font-size: 12px;
width: 100%;
}
.aphront-form-input textarea {
height: 12em;
}
.aphront-form-control {
padding: 4px;
}
.aphront-form-control-submit button,
.aphront-form-control-submit a.button {
float: right;
margin: 0.5em 0 0em 2%;
}
.aphront-form-control-textarea textarea.aphront-textarea-very-short {
height: 3em;
}
.aphront-form-control-textarea textarea.aphront-textarea-very-tall {
height: 24em;
}
.aphront-form-control-select .aphront-form-input {
padding-top: 2px;
}
.aphront-form-view .aphront-form-caption {
font-size: 11px;
color: #444444;
text-align: right;
clear: both;
margin-right: 25%;
margin-left: 20%;
}
.aphront-form-instructions {
margin: 0.75em 3% 1.25em;
}
+.aphront-form-important {
+ margin: .5em 0;
+ background: #ffffdd;
+ padding: .5em 1em;
+}
+.aphront-form-important code {
+ display: block;
+ padding: .25em;
+ margin: .5em 2em;
+}
+
+
.aphront-form-control-static .aphront-form-input {
padding-top: 4px;
font-size: 13px;
}
.aphront-form-control-togglebuttons .aphront-form-input {
padding-top: 5px;
}
table.aphront-form-control-checkbox-layout {
margin-top: 3px;
font-size: 13px;
}
table.aphront-form-control-checkbox-layout th {
padding-top: 2px;
padding-left: 0.35em;
}
.aphront-form-control-checkbox-layout td input {
width: auto;
}
.aphront-form-input hr {
border: none;
background: #bbbbbb;
height: 1px;
position: relative;
}
.aphront-form-inset {
margin: 0 0 1em;
padding: .75em;
background: #f3f3f3;
border: 1px solid #afafaf;
}
.aphront-form-drag-and-drop-file-list {
width: 400px;
}
.drag-and-drop-instructions {
color: #333333;
font-size: 11px;
padding: 6px 8px;
}
.aphront-textarea-drag-and-drop {
background: #99ff99;
border-color: #669966;
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Jul 28, 8:58 AM (1 w, 21 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
186616
Default Alt Text
(38 KB)

Event Timeline