1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-25 16:22:43 +01:00

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
This commit is contained in:
epriestley 2012-06-25 12:35:37 -07:00
parent 37df05c7a5
commit 13d96e6377
9 changed files with 256 additions and 70 deletions

1
bin/repository Symbolic link
View file

@ -0,0 +1 @@
../scripts/repository/manage_repositories.php

View file

@ -17,38 +17,8 @@
* limitations under the License. * limitations under the License.
*/ */
$root = dirname(dirname(dirname(__FILE__))); echo
require_once $root.'/scripts/__init_script__.php'; "This script has moved. All repository management is now performed through ".
"'bin/repository'. Use this command instead:\n\n".
$args = new PhutilArgumentParser($argv); " phabricator/ $ ./bin/repository discover ...\n";
$args->setTagline('manually discover working copies');
$args->setSynopsis(<<<EOHELP
**discover.php** [__options__] __repository-callsign-or-phid ...__
Manually discover commits in working copies for the named repositories.
EOHELP
);
$args->parseStandardArguments();
$args->parse(
array(
array(
'name' => 'repositories',
'wildcard' => true,
),
));
$repo_names = $args->getArg('repositories');
if (!$repo_names) {
echo "Specify one or more repositories to pull, by callsign or PHID.\n";
exit(1); exit(1);
}
$repos = PhabricatorRepository::loadAllByPHIDOrCallsign($repo_names);
foreach ($repos as $repo) {
$callsign = $repo->getCallsign();
echo "Discovering '{$callsign}'...\n";
$daemon = new PhabricatorRepositoryPullLocalDaemon(array());
$daemon->setVerbose(true);
$daemon->discoverRepository($repo);
}
echo "Done.\n";

View file

@ -0,0 +1,41 @@
#!/usr/bin/env php
<?php
/*
* Copyright 2012 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.
*/
$root = dirname(dirname(dirname(__FILE__)));
require_once $root.'/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline('manage repositories');
$args->setSynopsis(<<<EOSYNOPSIS
**repository** __command__ [__options__]
Manage and debug Phabricator repository configuration, tracking,
discovery and import.
EOSYNOPSIS
);
$args->parseStandardArguments();
$workflows = array(
new PhabricatorRepositoryManagementPullWorkflow(),
new PhabricatorRepositoryManagementDiscoverWorkflow(),
new PhabricatorRepositoryManagementListWorkflow(),
new PhutilHelpArgumentWorkflow(),
);
$args->parseWorkflows($workflows);

View file

@ -17,38 +17,8 @@
* limitations under the License. * limitations under the License.
*/ */
$root = dirname(dirname(dirname(__FILE__))); echo
require_once $root.'/scripts/__init_script__.php'; "This script has moved. All repository management is now performed through ".
"'bin/repository'. Use this command instead:\n\n".
$args = new PhutilArgumentParser($argv); " phabricator/ $ ./bin/repository pull ...\n";
$args->setTagline('manually pull working copies');
$args->setSynopsis(<<<EOHELP
**pull.php** [__options__] __repository-callsign-or-phid ...__
Manually pull/fetch working copies for the named repositories.
EOHELP
);
$args->parseStandardArguments();
$args->parse(
array(
array(
'name' => 'repositories',
'wildcard' => true,
),
));
$repo_names = $args->getArg('repositories');
if (!$repo_names) {
echo "Specify one or more repositories to pull, by callsign or PHID.\n";
exit(1); exit(1);
}
$repos = PhabricatorRepository::loadAllByPHIDOrCallsign($repo_names);
foreach ($repos as $repo) {
$callsign = $repo->getCallsign();
echo "Pulling '{$callsign}'...\n";
$daemon = new PhabricatorRepositoryPullLocalDaemon(array());
$daemon->setVerbose(true);
$daemon->pullRepository($repo);
}
echo "Done.\n";

View file

@ -893,6 +893,10 @@ phutil_register_library_map(array(
'PhabricatorRepositoryGitCommitChangeParserWorker' => 'applications/repository/worker/commitchangeparser/PhabricatorRepositoryGitCommitChangeParserWorker.php', 'PhabricatorRepositoryGitCommitChangeParserWorker' => 'applications/repository/worker/commitchangeparser/PhabricatorRepositoryGitCommitChangeParserWorker.php',
'PhabricatorRepositoryGitCommitMessageParserWorker' => 'applications/repository/worker/commitmessageparser/PhabricatorRepositoryGitCommitMessageParserWorker.php', 'PhabricatorRepositoryGitCommitMessageParserWorker' => 'applications/repository/worker/commitmessageparser/PhabricatorRepositoryGitCommitMessageParserWorker.php',
'PhabricatorRepositoryListController' => 'applications/repository/controller/PhabricatorRepositoryListController.php', 'PhabricatorRepositoryListController' => 'applications/repository/controller/PhabricatorRepositoryListController.php',
'PhabricatorRepositoryManagementDiscoverWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementDiscoverWorkflow.php',
'PhabricatorRepositoryManagementListWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementListWorkflow.php',
'PhabricatorRepositoryManagementPullWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementPullWorkflow.php',
'PhabricatorRepositoryManagementWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementWorkflow.php',
'PhabricatorRepositoryMercurialCommitChangeParserWorker' => 'applications/repository/worker/commitchangeparser/PhabricatorRepositoryMercurialCommitChangeParserWorker.php', 'PhabricatorRepositoryMercurialCommitChangeParserWorker' => 'applications/repository/worker/commitchangeparser/PhabricatorRepositoryMercurialCommitChangeParserWorker.php',
'PhabricatorRepositoryMercurialCommitMessageParserWorker' => 'applications/repository/worker/commitmessageparser/PhabricatorRepositoryMercurialCommitMessageParserWorker.php', 'PhabricatorRepositoryMercurialCommitMessageParserWorker' => 'applications/repository/worker/commitmessageparser/PhabricatorRepositoryMercurialCommitMessageParserWorker.php',
'PhabricatorRepositoryPullLocalDaemon' => 'applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php', 'PhabricatorRepositoryPullLocalDaemon' => 'applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php',
@ -1854,6 +1858,10 @@ phutil_register_library_map(array(
'PhabricatorRepositoryGitCommitChangeParserWorker' => 'PhabricatorRepositoryCommitChangeParserWorker', 'PhabricatorRepositoryGitCommitChangeParserWorker' => 'PhabricatorRepositoryCommitChangeParserWorker',
'PhabricatorRepositoryGitCommitMessageParserWorker' => 'PhabricatorRepositoryCommitMessageParserWorker', 'PhabricatorRepositoryGitCommitMessageParserWorker' => 'PhabricatorRepositoryCommitMessageParserWorker',
'PhabricatorRepositoryListController' => 'PhabricatorRepositoryController', 'PhabricatorRepositoryListController' => 'PhabricatorRepositoryController',
'PhabricatorRepositoryManagementDiscoverWorkflow' => 'PhabricatorRepositoryManagementWorkflow',
'PhabricatorRepositoryManagementListWorkflow' => 'PhabricatorRepositoryManagementWorkflow',
'PhabricatorRepositoryManagementPullWorkflow' => 'PhabricatorRepositoryManagementWorkflow',
'PhabricatorRepositoryManagementWorkflow' => 'PhutilArgumentWorkflow',
'PhabricatorRepositoryMercurialCommitChangeParserWorker' => 'PhabricatorRepositoryCommitChangeParserWorker', 'PhabricatorRepositoryMercurialCommitChangeParserWorker' => 'PhabricatorRepositoryCommitChangeParserWorker',
'PhabricatorRepositoryMercurialCommitMessageParserWorker' => 'PhabricatorRepositoryCommitMessageParserWorker', 'PhabricatorRepositoryMercurialCommitMessageParserWorker' => 'PhabricatorRepositoryCommitMessageParserWorker',
'PhabricatorRepositoryPullLocalDaemon' => 'PhabricatorDaemon', 'PhabricatorRepositoryPullLocalDaemon' => 'PhabricatorDaemon',

View file

@ -0,0 +1,63 @@
<?php
/*
* Copyright 2012 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.
*/
final class PhabricatorRepositoryManagementDiscoverWorkflow
extends PhabricatorRepositoryManagementWorkflow {
public function didConstruct() {
$this
->setName('discover')
->setExamples('**discover** __repository__ ...')
->setSynopsis('Discover __repository__, named by callsign or PHID.')
->setArguments(
array(
array(
'name' => 'verbose',
'help' => 'Show additional debugging information.',
),
array(
'name' => 'repos',
'wildcard' => true,
),
));
}
public function execute(PhutilArgumentParser $args) {
$names = $args->getArg('repos');
$repos = PhabricatorRepository::loadAllByPHIDOrCallsign($names);
if (!$repos) {
throw new PhutilArgumentUsageException(
"Specify one or more repositories to discover, by callsign or PHID.");
}
$console = PhutilConsole::getConsole();
foreach ($repos as $repo) {
$console->writeOut("Discovering '%s'...\n", $repo->getCallsign());
$daemon = new PhabricatorRepositoryPullLocalDaemon(array());
$daemon->setVerbose($args->getArg('verbose'));
$daemon->discoverRepository($repo);
}
$console->writeOut("Done.\n");
return 0;
}
}

View file

@ -0,0 +1,44 @@
<?php
/*
* Copyright 2012 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.
*/
final class PhabricatorRepositoryManagementListWorkflow
extends PhabricatorRepositoryManagementWorkflow {
public function didConstruct() {
$this
->setName('list')
->setSynopsis('Show a list of repositories.')
->setArguments(array());
}
public function execute(PhutilArgumentParser $args) {
$console = PhutilConsole::getConsole();
$repos = id(new PhabricatorRepository())->loadAll();
if ($repos) {
foreach ($repos as $repo) {
$console->writeOut("%s\n", $repo->getCallsign());
}
} else {
$console->writeErr("%s\n", 'There are no repositories.');
}
return 0;
}
}

View file

@ -0,0 +1,63 @@
<?php
/*
* Copyright 2012 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.
*/
final class PhabricatorRepositoryManagementPullWorkflow
extends PhabricatorRepositoryManagementWorkflow {
public function didConstruct() {
$this
->setName('pull')
->setExamples('**pull** __repository__ ...')
->setSynopsis('Pull __repository__, named by callsign or PHID.')
->setArguments(
array(
array(
'name' => 'verbose',
'help' => 'Show additional debugging information.',
),
array(
'name' => 'repos',
'wildcard' => true,
),
));
}
public function execute(PhutilArgumentParser $args) {
$names = $args->getArg('repos');
$repos = PhabricatorRepository::loadAllByPHIDOrCallsign($names);
if (!$repos) {
throw new PhutilArgumentUsageException(
"Specify one or more repositories to pull, by callsign or PHID.");
}
$console = PhutilConsole::getConsole();
foreach ($repos as $repo) {
$console->writeOut("Pulling '%s'...\n", $repo->getCallsign());
$daemon = new PhabricatorRepositoryPullLocalDaemon(array());
$daemon->setVerbose($args->getArg('verbose'));
$daemon->pullRepository($repo);
}
$console->writeOut("Done.\n");
return 0;
}
}

View file

@ -0,0 +1,26 @@
<?php
/*
* Copyright 2012 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.
*/
abstract class PhabricatorRepositoryManagementWorkflow
extends PhutilArgumentWorkflow {
public function isExecutable() {
return true;
}
}