mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-16 16:58:38 +01:00
Add an "arcanist.projectinfo" Conduit call
Summary: We currently rely on "remote_hooks_enabled" in .arcconfig to determine whether commands like "arc amend" and "arc merge" should imply "arc mark-committed". However, this is a historical artifact that is now bad for a bunch of reasons: - The option name is confusing, it really means 'repository is tracked'. - The option is hard to discover and generally sucks. - We can empirically determine the right answer since we now know if a project is in a tracked repository. Add a call which arcanist can make on these workflows to figure out if it is interacting with a project in a tracked repository or not. Also added an "isTracked()" convenience method to reduce the number of magic strings all over the place. Test Plan: Ran "arcanist.projectinfo" for nonexistent, untracked and tracked projects. Reviewers: Makinde, jungejason, nh, tuomaspelkonen, aran Reviewed By: Makinde CC: aran, epriestley, Makinde Differential Revision: 945
This commit is contained in:
parent
93b3bc8e89
commit
1c1f749eba
11 changed files with 139 additions and 6 deletions
|
@ -243,7 +243,7 @@ function phd_load_tracked_repositories() {
|
||||||
|
|
||||||
$repositories = id(new PhabricatorRepository())->loadAll();
|
$repositories = id(new PhabricatorRepository())->loadAll();
|
||||||
foreach ($repositories as $key => $repository) {
|
foreach ($repositories as $key => $repository) {
|
||||||
if (!$repository->getDetail('tracking-enabled')) {
|
if (!$repository->isTracked()) {
|
||||||
unset($repositories[$key]);
|
unset($repositories[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,8 @@ phutil_register_library_map(array(
|
||||||
'CelerityStaticResourceResponse' => 'infrastructure/celerity/response',
|
'CelerityStaticResourceResponse' => 'infrastructure/celerity/response',
|
||||||
'ConduitAPIMethod' => 'applications/conduit/method/base',
|
'ConduitAPIMethod' => 'applications/conduit/method/base',
|
||||||
'ConduitAPIRequest' => 'applications/conduit/protocol/request',
|
'ConduitAPIRequest' => 'applications/conduit/protocol/request',
|
||||||
|
'ConduitAPI_arcanist_Method' => 'applications/conduit/method/arcanist/base',
|
||||||
|
'ConduitAPI_arcanist_projectinfo_Method' => 'applications/conduit/method/arcanist/projectinfo',
|
||||||
'ConduitAPI_conduit_connect_Method' => 'applications/conduit/method/conduit/connect',
|
'ConduitAPI_conduit_connect_Method' => 'applications/conduit/method/conduit/connect',
|
||||||
'ConduitAPI_conduit_getcertificate_Method' => 'applications/conduit/method/conduit/getcertificate',
|
'ConduitAPI_conduit_getcertificate_Method' => 'applications/conduit/method/conduit/getcertificate',
|
||||||
'ConduitAPI_conduit_ping_Method' => 'applications/conduit/method/conduit/ping',
|
'ConduitAPI_conduit_ping_Method' => 'applications/conduit/method/conduit/ping',
|
||||||
|
@ -783,6 +785,8 @@ phutil_register_library_map(array(
|
||||||
'AphrontTypeaheadTemplateView' => 'AphrontView',
|
'AphrontTypeaheadTemplateView' => 'AphrontView',
|
||||||
'AphrontWebpageResponse' => 'AphrontResponse',
|
'AphrontWebpageResponse' => 'AphrontResponse',
|
||||||
'CelerityResourceController' => 'AphrontController',
|
'CelerityResourceController' => 'AphrontController',
|
||||||
|
'ConduitAPI_arcanist_Method' => 'ConduitAPIMethod',
|
||||||
|
'ConduitAPI_arcanist_projectinfo_Method' => 'ConduitAPI_arcanist_Method',
|
||||||
'ConduitAPI_conduit_connect_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_conduit_connect_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_conduit_getcertificate_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_conduit_getcertificate_Method' => 'ConduitAPIMethod',
|
||||||
'ConduitAPI_conduit_ping_Method' => 'ConduitAPIMethod',
|
'ConduitAPI_conduit_ping_Method' => 'ConduitAPIMethod',
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group conduit
|
||||||
|
*/
|
||||||
|
abstract class ConduitAPI_arcanist_Method extends ConduitAPIMethod {
|
||||||
|
|
||||||
|
}
|
12
src/applications/conduit/method/arcanist/base/__init__.php
Normal file
12
src/applications/conduit/method/arcanist/base/__init__.php
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/conduit/method/base');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('ConduitAPI_arcanist_Method.php');
|
|
@ -0,0 +1,73 @@
|
||||||
|
<?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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group conduit
|
||||||
|
*/
|
||||||
|
class ConduitAPI_arcanist_projectinfo_Method
|
||||||
|
extends ConduitAPI_arcanist_Method {
|
||||||
|
|
||||||
|
public function getMethodDescription() {
|
||||||
|
return "Get information about Arcanist projects.";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defineParamTypes() {
|
||||||
|
return array(
|
||||||
|
'name' => 'required string',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defineReturnType() {
|
||||||
|
return 'nonempty dict';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function defineErrorTypes() {
|
||||||
|
return array(
|
||||||
|
'ERR-BAD-ARCANIST-PROJECT' => 'No such project exists.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(ConduitAPIRequest $request) {
|
||||||
|
$name = $request->getValue('name');
|
||||||
|
|
||||||
|
$project = id(new PhabricatorRepositoryArcanistProject())->loadOneWhere(
|
||||||
|
'name = %s',
|
||||||
|
$name);
|
||||||
|
|
||||||
|
if (!$project) {
|
||||||
|
throw new ConduitException('ERR-BAD-ARCANIST-PROJECT');
|
||||||
|
}
|
||||||
|
|
||||||
|
$repository = $project->loadRepository();
|
||||||
|
|
||||||
|
$repository_phid = null;
|
||||||
|
$tracked = false;
|
||||||
|
if ($repository) {
|
||||||
|
$repository_phid = $repository->getPHID();
|
||||||
|
$tracked = $repository->isTracked();
|
||||||
|
}
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'name' => $project->getName(),
|
||||||
|
'phid' => $project->getPHID(),
|
||||||
|
'repositoryPHID' => $repository_phid,
|
||||||
|
'tracked' => $tracked,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is automatically generated. Lint this module to rebuild it.
|
||||||
|
* @generated
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_module('phabricator', 'applications/conduit/method/arcanist/base');
|
||||||
|
phutil_require_module('phabricator', 'applications/conduit/protocol/exception');
|
||||||
|
phutil_require_module('phabricator', 'applications/repository/storage/arcanistproject');
|
||||||
|
|
||||||
|
phutil_require_module('phutil', 'utils');
|
||||||
|
|
||||||
|
|
||||||
|
phutil_require_source('ConduitAPI_arcanist_projectinfo_Method.php');
|
|
@ -62,7 +62,7 @@ class DiffusionHomeController extends DiffusionController {
|
||||||
|
|
||||||
$repositories = $repository->loadAll();
|
$repositories = $repository->loadAll();
|
||||||
foreach ($repositories as $key => $repository) {
|
foreach ($repositories as $key => $repository) {
|
||||||
if (!$repository->getDetail('tracking-enabled')) {
|
if (!$repository->isTracked()) {
|
||||||
unset($repositories[$key]);
|
unset($repositories[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -327,7 +327,7 @@ class PhabricatorRepositoryEditController
|
||||||
$error_view->appendChild(
|
$error_view->appendChild(
|
||||||
'Tracking changes were saved. You may need to restart the daemon '.
|
'Tracking changes were saved. You may need to restart the daemon '.
|
||||||
'before changes will take effect.');
|
'before changes will take effect.');
|
||||||
} else if (!$repository->getDetail('tracking-enabled')) {
|
} else if (!$repository->isTracked()) {
|
||||||
$error_view = new AphrontErrorView();
|
$error_view = new AphrontErrorView();
|
||||||
$error_view->setSeverity(AphrontErrorView::SEVERITY_WARNING);
|
$error_view->setSeverity(AphrontErrorView::SEVERITY_WARNING);
|
||||||
$error_view->setTitle('Repository Not Tracked');
|
$error_view->setTitle('Repository Not Tracked');
|
||||||
|
@ -381,7 +381,7 @@ class PhabricatorRepositoryEditController
|
||||||
'enabled' => 'Enabled',
|
'enabled' => 'Enabled',
|
||||||
))
|
))
|
||||||
->setValue(
|
->setValue(
|
||||||
$repository->getDetail('tracking-enabled')
|
$repository->isTracked()
|
||||||
? 'enabled'
|
? 'enabled'
|
||||||
: 'disabled'))
|
: 'disabled'))
|
||||||
->appendChild('</div>');
|
->appendChild('</div>');
|
||||||
|
|
|
@ -34,7 +34,7 @@ class PhabricatorRepositoryListController
|
||||||
$rows = array();
|
$rows = array();
|
||||||
foreach ($repos as $repo) {
|
foreach ($repos as $repo) {
|
||||||
|
|
||||||
if ($repo->getDetail('tracking-enabled')) {
|
if ($repo->isTracked()) {
|
||||||
$diffusion_link = phutil_render_tag(
|
$diffusion_link = phutil_render_tag(
|
||||||
'a',
|
'a',
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -39,7 +39,7 @@ abstract class PhabricatorRepositoryPullLocalDaemon
|
||||||
"repository '{$repo_name}' is a '{$repo_type_name}' repository.");
|
"repository '{$repo_name}' is a '{$repo_type_name}' repository.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$tracked = $repository->getDetail('tracking-enabled');
|
$tracked = $repository->isTracked();
|
||||||
if (!$tracked) {
|
if (!$tracked) {
|
||||||
throw new Exception("Tracking is not enabled for this repository.");
|
throw new Exception("Tracking is not enabled for this repository.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,4 +293,8 @@ class PhabricatorRepository extends PhabricatorRepositoryDAO {
|
||||||
return ($protocol == 'http' || $protocol == 'https');
|
return ($protocol == 'http' || $protocol == 'https');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isTracked() {
|
||||||
|
return $this->getDetail('tracking-enabled', false);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue