Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / repository / management / PhabricatorRepositoryManagementImportingWorkflow.php
blob25389ce6a195ea1126f3317c38568e343f1d7df3
1 <?php
3 final class PhabricatorRepositoryManagementImportingWorkflow
4 extends PhabricatorRepositoryManagementWorkflow {
6 protected function didConstruct() {
7 $this
8 ->setName('importing')
9 ->setExamples('**importing** __repository__ ...')
10 ->setSynopsis(
11 pht(
12 'Show commits in __repository__ which are still importing.'))
13 ->setArguments(
14 array(
15 array(
16 'name' => 'simple',
17 'help' => pht('Show simpler output.'),
19 array(
20 'name' => 'repos',
21 'wildcard' => true,
23 ));
26 public function execute(PhutilArgumentParser $args) {
27 $repos = $this->loadRepositories($args, 'repos');
29 if (!$repos) {
30 throw new PhutilArgumentUsageException(
31 pht(
32 'Specify one or more repositories to find importing commits for.'));
35 $repos = mpull($repos, null, 'getID');
37 $table = new PhabricatorRepositoryCommit();
38 $conn_r = $table->establishConnection('r');
40 $rows = queryfx_all(
41 $conn_r,
42 'SELECT repositoryID, commitIdentifier, importStatus FROM %T
43 WHERE repositoryID IN (%Ld)
44 AND (importStatus & %d) != %d
45 AND (importStatus & %d) != %d',
46 $table->getTableName(),
47 array_keys($repos),
48 PhabricatorRepositoryCommit::IMPORTED_ALL,
49 PhabricatorRepositoryCommit::IMPORTED_ALL,
50 PhabricatorRepositoryCommit::IMPORTED_UNREACHABLE,
51 PhabricatorRepositoryCommit::IMPORTED_UNREACHABLE);
53 $console = PhutilConsole::getConsole();
54 if ($rows) {
55 foreach ($rows as $row) {
56 $repo = $repos[$row['repositoryID']];
57 $identifier = $row['commitIdentifier'];
59 $console->writeOut('%s', $repo->formatCommitName($identifier));
61 if (!$args->getArg('simple')) {
62 $status = $row['importStatus'];
63 $need = array();
64 if (!($status & PhabricatorRepositoryCommit::IMPORTED_MESSAGE)) {
65 $need[] = pht('Message');
67 if (!($status & PhabricatorRepositoryCommit::IMPORTED_CHANGE)) {
68 $need[] = pht('Change');
70 if (!($status & PhabricatorRepositoryCommit::IMPORTED_PUBLISH)) {
71 $need[] = pht('Publish');
74 $console->writeOut(' %s', implode(', ', $need));
77 $console->writeOut("\n");
79 } else {
80 $console->writeErr(
81 "%s\n",
82 pht('No importing commits found.'));
85 return 0;