Skip to content

Commit 1c1f749

Browse files
author
epriestley
committedSep 21, 2011
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
1 parent 93b3bc8 commit 1c1f749

11 files changed

+139
-6
lines changed
 

‎scripts/daemon/phabricator_daemon_launcher.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ function phd_load_tracked_repositories() {
243243

244244
$repositories = id(new PhabricatorRepository())->loadAll();
245245
foreach ($repositories as $key => $repository) {
246-
if (!$repository->getDetail('tracking-enabled')) {
246+
if (!$repository->isTracked()) {
247247
unset($repositories[$key]);
248248
}
249249
}

‎src/__phutil_library_map__.php

+4
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
'CelerityStaticResourceResponse' => 'infrastructure/celerity/response',
8787
'ConduitAPIMethod' => 'applications/conduit/method/base',
8888
'ConduitAPIRequest' => 'applications/conduit/protocol/request',
89+
'ConduitAPI_arcanist_Method' => 'applications/conduit/method/arcanist/base',
90+
'ConduitAPI_arcanist_projectinfo_Method' => 'applications/conduit/method/arcanist/projectinfo',
8991
'ConduitAPI_conduit_connect_Method' => 'applications/conduit/method/conduit/connect',
9092
'ConduitAPI_conduit_getcertificate_Method' => 'applications/conduit/method/conduit/getcertificate',
9193
'ConduitAPI_conduit_ping_Method' => 'applications/conduit/method/conduit/ping',
@@ -783,6 +785,8 @@
783785
'AphrontTypeaheadTemplateView' => 'AphrontView',
784786
'AphrontWebpageResponse' => 'AphrontResponse',
785787
'CelerityResourceController' => 'AphrontController',
788+
'ConduitAPI_arcanist_Method' => 'ConduitAPIMethod',
789+
'ConduitAPI_arcanist_projectinfo_Method' => 'ConduitAPI_arcanist_Method',
786790
'ConduitAPI_conduit_connect_Method' => 'ConduitAPIMethod',
787791
'ConduitAPI_conduit_getcertificate_Method' => 'ConduitAPIMethod',
788792
'ConduitAPI_conduit_ping_Method' => 'ConduitAPIMethod',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
/*
4+
* Copyright 2011 Facebook, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/**
20+
* @group conduit
21+
*/
22+
abstract class ConduitAPI_arcanist_Method extends ConduitAPIMethod {
23+
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
/**
3+
* This file is automatically generated. Lint this module to rebuild it.
4+
* @generated
5+
*/
6+
7+
8+
9+
phutil_require_module('phabricator', 'applications/conduit/method/base');
10+
11+
12+
phutil_require_source('ConduitAPI_arcanist_Method.php');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
3+
/*
4+
* Copyright 2011 Facebook, Inc.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/**
20+
* @group conduit
21+
*/
22+
class ConduitAPI_arcanist_projectinfo_Method
23+
extends ConduitAPI_arcanist_Method {
24+
25+
public function getMethodDescription() {
26+
return "Get information about Arcanist projects.";
27+
}
28+
29+
public function defineParamTypes() {
30+
return array(
31+
'name' => 'required string',
32+
);
33+
}
34+
35+
public function defineReturnType() {
36+
return 'nonempty dict';
37+
}
38+
39+
public function defineErrorTypes() {
40+
return array(
41+
'ERR-BAD-ARCANIST-PROJECT' => 'No such project exists.',
42+
);
43+
}
44+
45+
protected function execute(ConduitAPIRequest $request) {
46+
$name = $request->getValue('name');
47+
48+
$project = id(new PhabricatorRepositoryArcanistProject())->loadOneWhere(
49+
'name = %s',
50+
$name);
51+
52+
if (!$project) {
53+
throw new ConduitException('ERR-BAD-ARCANIST-PROJECT');
54+
}
55+
56+
$repository = $project->loadRepository();
57+
58+
$repository_phid = null;
59+
$tracked = false;
60+
if ($repository) {
61+
$repository_phid = $repository->getPHID();
62+
$tracked = $repository->isTracked();
63+
}
64+
65+
return array(
66+
'name' => $project->getName(),
67+
'phid' => $project->getPHID(),
68+
'repositoryPHID' => $repository_phid,
69+
'tracked' => $tracked,
70+
);
71+
}
72+
73+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
/**
3+
* This file is automatically generated. Lint this module to rebuild it.
4+
* @generated
5+
*/
6+
7+
8+
9+
phutil_require_module('phabricator', 'applications/conduit/method/arcanist/base');
10+
phutil_require_module('phabricator', 'applications/conduit/protocol/exception');
11+
phutil_require_module('phabricator', 'applications/repository/storage/arcanistproject');
12+
13+
phutil_require_module('phutil', 'utils');
14+
15+
16+
phutil_require_source('ConduitAPI_arcanist_projectinfo_Method.php');

‎src/applications/diffusion/controller/home/DiffusionHomeController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function processRequest() {
6262

6363
$repositories = $repository->loadAll();
6464
foreach ($repositories as $key => $repository) {
65-
if (!$repository->getDetail('tracking-enabled')) {
65+
if (!$repository->isTracked()) {
6666
unset($repositories[$key]);
6767
}
6868
}

‎src/applications/repository/controller/edit/PhabricatorRepositoryEditController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ private function processTrackingRequest() {
327327
$error_view->appendChild(
328328
'Tracking changes were saved. You may need to restart the daemon '.
329329
'before changes will take effect.');
330-
} else if (!$repository->getDetail('tracking-enabled')) {
330+
} else if (!$repository->isTracked()) {
331331
$error_view = new AphrontErrorView();
332332
$error_view->setSeverity(AphrontErrorView::SEVERITY_WARNING);
333333
$error_view->setTitle('Repository Not Tracked');
@@ -381,7 +381,7 @@ private function processTrackingRequest() {
381381
'enabled' => 'Enabled',
382382
))
383383
->setValue(
384-
$repository->getDetail('tracking-enabled')
384+
$repository->isTracked()
385385
? 'enabled'
386386
: 'disabled'))
387387
->appendChild('</div>');

‎src/applications/repository/controller/list/PhabricatorRepositoryListController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function processRequest() {
3434
$rows = array();
3535
foreach ($repos as $repo) {
3636

37-
if ($repo->getDetail('tracking-enabled')) {
37+
if ($repo->isTracked()) {
3838
$diffusion_link = phutil_render_tag(
3939
'a',
4040
array(

‎src/applications/repository/daemon/pulllocal/PhabricatorRepositoryPullLocalDaemon.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ final public function run() {
3939
"repository '{$repo_name}' is a '{$repo_type_name}' repository.");
4040
}
4141

42-
$tracked = $repository->getDetail('tracking-enabled');
42+
$tracked = $repository->isTracked();
4343
if (!$tracked) {
4444
throw new Exception("Tracking is not enabled for this repository.");
4545
}

‎src/applications/repository/storage/repository/PhabricatorRepository.php

+4
Original file line numberDiff line numberDiff line change
@@ -293,4 +293,8 @@ private function isHTTPProtocol($protocol) {
293293
return ($protocol == 'http' || $protocol == 'https');
294294
}
295295

296+
public function isTracked() {
297+
return $this->getDetail('tracking-enabled', false);
298+
}
299+
296300
}

0 commit comments

Comments
 (0)
Failed to load comments.