@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+256 -70
+1
bin/repository
··· 1 + ../scripts/repository/manage_repositories.php
+5 -35
scripts/repository/discover.php
··· 17 17 * limitations under the License. 18 18 */ 19 19 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);
+41
scripts/repository/manage_repositories.php
··· 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);
+5 -35
scripts/repository/pull.php
··· 17 17 * limitations under the License. 18 18 */ 19 19 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);
+8
src/__phutil_library_map__.php
··· 893 893 'PhabricatorRepositoryGitCommitChangeParserWorker' => 'applications/repository/worker/commitchangeparser/PhabricatorRepositoryGitCommitChangeParserWorker.php', 894 894 'PhabricatorRepositoryGitCommitMessageParserWorker' => 'applications/repository/worker/commitmessageparser/PhabricatorRepositoryGitCommitMessageParserWorker.php', 895 895 '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', 896 900 'PhabricatorRepositoryMercurialCommitChangeParserWorker' => 'applications/repository/worker/commitchangeparser/PhabricatorRepositoryMercurialCommitChangeParserWorker.php', 897 901 'PhabricatorRepositoryMercurialCommitMessageParserWorker' => 'applications/repository/worker/commitmessageparser/PhabricatorRepositoryMercurialCommitMessageParserWorker.php', 898 902 'PhabricatorRepositoryPullLocalDaemon' => 'applications/repository/daemon/PhabricatorRepositoryPullLocalDaemon.php', ··· 1854 1858 'PhabricatorRepositoryGitCommitChangeParserWorker' => 'PhabricatorRepositoryCommitChangeParserWorker', 1855 1859 'PhabricatorRepositoryGitCommitMessageParserWorker' => 'PhabricatorRepositoryCommitMessageParserWorker', 1856 1860 'PhabricatorRepositoryListController' => 'PhabricatorRepositoryController', 1861 + 'PhabricatorRepositoryManagementDiscoverWorkflow' => 'PhabricatorRepositoryManagementWorkflow', 1862 + 'PhabricatorRepositoryManagementListWorkflow' => 'PhabricatorRepositoryManagementWorkflow', 1863 + 'PhabricatorRepositoryManagementPullWorkflow' => 'PhabricatorRepositoryManagementWorkflow', 1864 + 'PhabricatorRepositoryManagementWorkflow' => 'PhutilArgumentWorkflow', 1857 1865 'PhabricatorRepositoryMercurialCommitChangeParserWorker' => 'PhabricatorRepositoryCommitChangeParserWorker', 1858 1866 'PhabricatorRepositoryMercurialCommitMessageParserWorker' => 'PhabricatorRepositoryCommitMessageParserWorker', 1859 1867 'PhabricatorRepositoryPullLocalDaemon' => 'PhabricatorDaemon',
+63
src/applications/repository/management/PhabricatorRepositoryManagementDiscoverWorkflow.php
··· 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 + }
+44
src/applications/repository/management/PhabricatorRepositoryManagementListWorkflow.php
··· 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 + }
+63
src/applications/repository/management/PhabricatorRepositoryManagementPullWorkflow.php
··· 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 + }
+26
src/applications/repository/management/PhabricatorRepositoryManagementWorkflow.php
··· 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 + }