Skip to content

Commit 13d96e6

Browse files
author
epriestley
committed
Introduce "bin/repository" for repository management
Summary: Nothing new or exciting here yet, just moving the random scripts/repositories/ things to bin/repository. Also add `repository list`. (Console stuff comes from D2841.) Test Plan: Ran `repository list`, `repository pull`, `repository discover`, `repository discover --verbose`, `repository help`. Reviewers: jungejason, vrana Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D2849
1 parent 37df05c commit 13d96e6

9 files changed

+256
-70
lines changed

bin/repository

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../scripts/repository/manage_repositories.php

scripts/repository/discover.php

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,8 @@
1717
* limitations under the License.
1818
*/
1919

20-
$root = dirname(dirname(dirname(__FILE__)));
21-
require_once $root.'/scripts/__init_script__.php';
22-
23-
$args = new PhutilArgumentParser($argv);
24-
$args->setTagline('manually discover working copies');
25-
$args->setSynopsis(<<<EOHELP
26-
**discover.php** [__options__] __repository-callsign-or-phid ...__
27-
Manually discover commits in working copies for the named repositories.
28-
EOHELP
29-
);
30-
$args->parseStandardArguments();
31-
$args->parse(
32-
array(
33-
array(
34-
'name' => 'repositories',
35-
'wildcard' => true,
36-
),
37-
));
38-
39-
$repo_names = $args->getArg('repositories');
40-
if (!$repo_names) {
41-
echo "Specify one or more repositories to pull, by callsign or PHID.\n";
42-
exit(1);
43-
}
44-
45-
$repos = PhabricatorRepository::loadAllByPHIDOrCallsign($repo_names);
46-
foreach ($repos as $repo) {
47-
$callsign = $repo->getCallsign();
48-
echo "Discovering '{$callsign}'...\n";
49-
50-
$daemon = new PhabricatorRepositoryPullLocalDaemon(array());
51-
$daemon->setVerbose(true);
52-
$daemon->discoverRepository($repo);
53-
}
54-
echo "Done.\n";
20+
echo
21+
"This script has moved. All repository management is now performed through ".
22+
"'bin/repository'. Use this command instead:\n\n".
23+
" phabricator/ $ ./bin/repository discover ...\n";
24+
exit(1);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
/*
5+
* Copyright 2012 Facebook, Inc.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
$root = dirname(dirname(dirname(__FILE__)));
21+
require_once $root.'/scripts/__init_script__.php';
22+
23+
$args = new PhutilArgumentParser($argv);
24+
$args->setTagline('manage repositories');
25+
$args->setSynopsis(<<<EOSYNOPSIS
26+
**repository** __command__ [__options__]
27+
Manage and debug Phabricator repository configuration, tracking,
28+
discovery and import.
29+
30+
EOSYNOPSIS
31+
);
32+
$args->parseStandardArguments();
33+
34+
$workflows = array(
35+
new PhabricatorRepositoryManagementPullWorkflow(),
36+
new PhabricatorRepositoryManagementDiscoverWorkflow(),
37+
new PhabricatorRepositoryManagementListWorkflow(),
38+
new PhutilHelpArgumentWorkflow(),
39+
);
40+
41+
$args->parseWorkflows($workflows);

scripts/repository/pull.php

Lines changed: 5 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,8 @@
1717
* limitations under the License.
1818
*/
1919

20-
$root = dirname(dirname(dirname(__FILE__)));
21-
require_once $root.'/scripts/__init_script__.php';
22-
23-
$args = new PhutilArgumentParser($argv);
24-
$args->setTagline('manually pull working copies');
25-
$args->setSynopsis(<<<EOHELP
26-
**pull.php** [__options__] __repository-callsign-or-phid ...__
27-
Manually pull/fetch working copies for the named repositories.
28-
EOHELP
29-
);
30-
$args->parseStandardArguments();
31-
$args->parse(
32-
array(
33-
array(
34-
'name' => 'repositories',
35-
'wildcard' => true,
36-
),
37-
));
38-
39-
$repo_names = $args->getArg('repositories');
40-
if (!$repo_names) {
41-
echo "Specify one or more repositories to pull, by callsign or PHID.\n";
42-
exit(1);
43-
}
44-
45-
$repos = PhabricatorRepository::loadAllByPHIDOrCallsign($repo_names);
46-
foreach ($repos as $repo) {
47-
$callsign = $repo->getCallsign();
48-
echo "Pulling '{$callsign}'...\n";
49-
50-
$daemon = new PhabricatorRepositoryPullLocalDaemon(array());
51-
$daemon->setVerbose(true);
52-
$daemon->pullRepository($repo);
53-
}
54-
echo "Done.\n";
20+
echo
21+
"This script has moved. All repository management is now performed through ".
22+
"'bin/repository'. Use this command instead:\n\n".
23+
" phabricator/ $ ./bin/repository pull ...\n";
24+
exit(1);

src/__phutil_library_map__.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,10 @@
893893
'PhabricatorRepositoryGitCommitChangeParserWorker' => 'applications/repository/worker/commitchangeparser/PhabricatorRepositoryGitCommitChangeParserWorker.php',
894894
'PhabricatorRepositoryGitCommitMessageParserWorker' => 'applications/repository/worker/commitmessageparser/PhabricatorRepositoryGitCommitMessageParserWorker.php',
895895
'PhabricatorRepositoryListController' => 'applications/repository/controller/PhabricatorRepositoryListController.php',
896+
'PhabricatorRepositoryManagementDiscoverWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementDiscoverWorkflow.php',
897+
'PhabricatorRepositoryManagementListWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementListWorkflow.php',
898+
'PhabricatorRepositoryManagementPullWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementPullWorkflow.php',
899+
'PhabricatorRepositoryManagementWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementWorkflow.php',
896900
'PhabricatorRepositoryMercurialCommitChangeParserWorker' => 'applications/repository/worker/commitchangeparser/PhabricatorRepositoryMercurialCommitChangeParserWorker.php',
897901
'PhabricatorRepositoryMercurialCommitMessageParserWorker' => 'applications/repository/worker/commitmessageparser/PhabricatorRepositoryMercurialCommitMessageParserWorker.php',
898902
'PhabricatorRepositoryPullLocalDaemon' => 'applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php',
@@ -1854,6 +1858,10 @@
18541858
'PhabricatorRepositoryGitCommitChangeParserWorker' => 'PhabricatorRepositoryCommitChangeParserWorker',
18551859
'PhabricatorRepositoryGitCommitMessageParserWorker' => 'PhabricatorRepositoryCommitMessageParserWorker',
18561860
'PhabricatorRepositoryListController' => 'PhabricatorRepositoryController',
1861+
'PhabricatorRepositoryManagementDiscoverWorkflow' => 'PhabricatorRepositoryManagementWorkflow',
1862+
'PhabricatorRepositoryManagementListWorkflow' => 'PhabricatorRepositoryManagementWorkflow',
1863+
'PhabricatorRepositoryManagementPullWorkflow' => 'PhabricatorRepositoryManagementWorkflow',
1864+
'PhabricatorRepositoryManagementWorkflow' => 'PhutilArgumentWorkflow',
18571865
'PhabricatorRepositoryMercurialCommitChangeParserWorker' => 'PhabricatorRepositoryCommitChangeParserWorker',
18581866
'PhabricatorRepositoryMercurialCommitMessageParserWorker' => 'PhabricatorRepositoryCommitMessageParserWorker',
18591867
'PhabricatorRepositoryPullLocalDaemon' => 'PhabricatorDaemon',
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
/*
4+
* Copyright 2012 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+
final class PhabricatorRepositoryManagementDiscoverWorkflow
20+
extends PhabricatorRepositoryManagementWorkflow {
21+
22+
public function didConstruct() {
23+
$this
24+
->setName('discover')
25+
->setExamples('**discover** __repository__ ...')
26+
->setSynopsis('Discover __repository__, named by callsign or PHID.')
27+
->setArguments(
28+
array(
29+
array(
30+
'name' => 'verbose',
31+
'help' => 'Show additional debugging information.',
32+
),
33+
array(
34+
'name' => 'repos',
35+
'wildcard' => true,
36+
),
37+
));
38+
}
39+
40+
public function execute(PhutilArgumentParser $args) {
41+
$names = $args->getArg('repos');
42+
$repos = PhabricatorRepository::loadAllByPHIDOrCallsign($names);
43+
44+
if (!$repos) {
45+
throw new PhutilArgumentUsageException(
46+
"Specify one or more repositories to discover, by callsign or PHID.");
47+
}
48+
49+
$console = PhutilConsole::getConsole();
50+
foreach ($repos as $repo) {
51+
$console->writeOut("Discovering '%s'...\n", $repo->getCallsign());
52+
53+
$daemon = new PhabricatorRepositoryPullLocalDaemon(array());
54+
$daemon->setVerbose($args->getArg('verbose'));
55+
$daemon->discoverRepository($repo);
56+
}
57+
58+
$console->writeOut("Done.\n");
59+
60+
return 0;
61+
}
62+
63+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/*
4+
* Copyright 2012 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+
final class PhabricatorRepositoryManagementListWorkflow
20+
extends PhabricatorRepositoryManagementWorkflow {
21+
22+
public function didConstruct() {
23+
$this
24+
->setName('list')
25+
->setSynopsis('Show a list of repositories.')
26+
->setArguments(array());
27+
}
28+
29+
public function execute(PhutilArgumentParser $args) {
30+
$console = PhutilConsole::getConsole();
31+
32+
$repos = id(new PhabricatorRepository())->loadAll();
33+
if ($repos) {
34+
foreach ($repos as $repo) {
35+
$console->writeOut("%s\n", $repo->getCallsign());
36+
}
37+
} else {
38+
$console->writeErr("%s\n", 'There are no repositories.');
39+
}
40+
41+
return 0;
42+
}
43+
44+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
/*
4+
* Copyright 2012 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+
final class PhabricatorRepositoryManagementPullWorkflow
20+
extends PhabricatorRepositoryManagementWorkflow {
21+
22+
public function didConstruct() {
23+
$this
24+
->setName('pull')
25+
->setExamples('**pull** __repository__ ...')
26+
->setSynopsis('Pull __repository__, named by callsign or PHID.')
27+
->setArguments(
28+
array(
29+
array(
30+
'name' => 'verbose',
31+
'help' => 'Show additional debugging information.',
32+
),
33+
array(
34+
'name' => 'repos',
35+
'wildcard' => true,
36+
),
37+
));
38+
}
39+
40+
public function execute(PhutilArgumentParser $args) {
41+
$names = $args->getArg('repos');
42+
$repos = PhabricatorRepository::loadAllByPHIDOrCallsign($names);
43+
44+
if (!$repos) {
45+
throw new PhutilArgumentUsageException(
46+
"Specify one or more repositories to pull, by callsign or PHID.");
47+
}
48+
49+
$console = PhutilConsole::getConsole();
50+
foreach ($repos as $repo) {
51+
$console->writeOut("Pulling '%s'...\n", $repo->getCallsign());
52+
53+
$daemon = new PhabricatorRepositoryPullLocalDaemon(array());
54+
$daemon->setVerbose($args->getArg('verbose'));
55+
$daemon->pullRepository($repo);
56+
}
57+
58+
$console->writeOut("Done.\n");
59+
60+
return 0;
61+
}
62+
63+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
/*
4+
* Copyright 2012 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+
abstract class PhabricatorRepositoryManagementWorkflow
20+
extends PhutilArgumentWorkflow {
21+
22+
public function isExecutable() {
23+
return true;
24+
}
25+
26+
}

0 commit comments

Comments
 (0)