|
| 1 | +<?php |
| 2 | + |
| 3 | +final class PhabricatorRepositoryManagementImportingWorkflow |
| 4 | + extends PhabricatorRepositoryManagementWorkflow { |
| 5 | + |
| 6 | + public function didConstruct() { |
| 7 | + $this |
| 8 | + ->setName('importing') |
| 9 | + ->setExamples('**importing** __repository__ ...') |
| 10 | + ->setSynopsis( |
| 11 | + 'Show commits in __repository__, named by callsign, which are still '. |
| 12 | + 'importing.') |
| 13 | + ->setArguments( |
| 14 | + array( |
| 15 | + array( |
| 16 | + 'name' => 'simple', |
| 17 | + 'help' => 'Show simpler output.', |
| 18 | + ), |
| 19 | + array( |
| 20 | + 'name' => 'repos', |
| 21 | + 'wildcard' => true, |
| 22 | + ), |
| 23 | + )); |
| 24 | + } |
| 25 | + |
| 26 | + public function execute(PhutilArgumentParser $args) { |
| 27 | + $repos = $this->loadRepositories($args, 'repos'); |
| 28 | + |
| 29 | + if (!$repos) { |
| 30 | + throw new PhutilArgumentUsageException( |
| 31 | + "Specify one or more repositories to find importing commits for, ". |
| 32 | + "by callsign."); |
| 33 | + } |
| 34 | + |
| 35 | + $repos = mpull($repos, null, 'getID'); |
| 36 | + |
| 37 | + $table = new PhabricatorRepositoryCommit(); |
| 38 | + $conn_r = $table->establishConnection('r'); |
| 39 | + |
| 40 | + $rows = queryfx_all( |
| 41 | + $conn_r, |
| 42 | + 'SELECT repositoryID, commitIdentifier, importStatus FROM %T |
| 43 | + WHERE repositoryID IN (%Ld) AND importStatus != %d', |
| 44 | + $table->getTableName(), |
| 45 | + array_keys($repos), |
| 46 | + PhabricatorRepositoryCommit::IMPORTED_ALL); |
| 47 | + |
| 48 | + $console = PhutilConsole::getConsole(); |
| 49 | + if ($rows) { |
| 50 | + foreach ($rows as $row) { |
| 51 | + $repo = $repos[$row['repositoryID']]; |
| 52 | + $identifier = $row['commitIdentifier']; |
| 53 | + |
| 54 | + $console->writeOut("%s", 'r'.$repo->getCallsign().$identifier); |
| 55 | + |
| 56 | + if (!$args->getArg('simple')) { |
| 57 | + $status = $row['importStatus']; |
| 58 | + $need = array(); |
| 59 | + if (!($status & PhabricatorRepositoryCommit::IMPORTED_MESSAGE)) { |
| 60 | + $need[] = 'Message'; |
| 61 | + } |
| 62 | + if (!($status & PhabricatorRepositoryCommit::IMPORTED_CHANGE)) { |
| 63 | + $need[] = 'Change'; |
| 64 | + } |
| 65 | + if (!($status & PhabricatorRepositoryCommit::IMPORTED_OWNERS)) { |
| 66 | + $need[] = 'Owners'; |
| 67 | + } |
| 68 | + if (!($status & PhabricatorRepositoryCommit::IMPORTED_HERALD)) { |
| 69 | + $need[] = 'Herald'; |
| 70 | + } |
| 71 | + |
| 72 | + $console->writeOut(" %s", implode(', ', $need)); |
| 73 | + } |
| 74 | + |
| 75 | + $console->writeOut("\n"); |
| 76 | + } |
| 77 | + } else { |
| 78 | + $console->writeErr( |
| 79 | + "%s\n", |
| 80 | + pht('No importing commits found.')); |
| 81 | + } |
| 82 | + |
| 83 | + return 0; |
| 84 | + } |
| 85 | + |
| 86 | +} |
0 commit comments