@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.

at recaptime-dev/main 125 lines 3.2 kB view raw
1<?php 2 3abstract class PhabricatorAuditManagementWorkflow 4 extends PhabricatorManagementWorkflow { 5 6 7 protected function getCommitConstraintArguments() { 8 return array( 9 array( 10 'name' => 'all', 11 'help' => pht('Update all commits in all repositories.'), 12 ), 13 array( 14 'name' => 'objects', 15 'wildcard' => true, 16 'help' => pht('Update named commits and repositories.'), 17 ), 18 ); 19 } 20 21 protected function loadCommitsWithConstraints(PhutilArgumentParser $args) { 22 $viewer = $this->getViewer(); 23 24 $all = $args->getArg('all'); 25 $names = $args->getArg('objects'); 26 27 if (!$names && !$all) { 28 throw new PhutilArgumentUsageException( 29 pht( 30 'Specify "--all" to affect everything, or a list of specific '. 31 'commits or repositories to affect.')); 32 } else if ($names && $all) { 33 throw new PhutilArgumentUsageException( 34 pht( 35 'Specify either a list of objects to affect or "--all", but not '. 36 'both.')); 37 } 38 39 if ($all) { 40 $objects = new LiskMigrationIterator(new PhabricatorRepository()); 41 } else { 42 $query = id(new PhabricatorObjectQuery()) 43 ->setViewer($viewer) 44 ->withNames($names); 45 46 $query->execute(); 47 48 $objects = array(); 49 50 $results = $query->getNamedResults(); 51 foreach ($names as $name) { 52 if (!isset($results[$name])) { 53 throw new PhutilArgumentUsageException( 54 pht( 55 'Object "%s" is not a valid object.', 56 $name)); 57 } 58 59 $object = $results[$name]; 60 if (!($object instanceof PhabricatorRepository) && 61 !($object instanceof PhabricatorRepositoryCommit)) { 62 throw new PhutilArgumentUsageException( 63 pht( 64 'Object "%s" is not a valid repository or commit.', 65 $name)); 66 } 67 68 $objects[] = $object; 69 } 70 } 71 72 return $objects; 73 } 74 75 protected function loadCommitsForConstraintObject($object) { 76 $viewer = $this->getViewer(); 77 78 if ($object instanceof PhabricatorRepository) { 79 $commits = id(new DiffusionCommitQuery()) 80 ->setViewer($viewer) 81 ->withRepository($object) 82 ->execute(); 83 } else { 84 $commits = array($object); 85 } 86 87 return $commits; 88 } 89 90 protected function synchronizeCommitAuditState($commit_phid) { 91 $viewer = $this->getViewer(); 92 93 $commit = id(new DiffusionCommitQuery()) 94 ->setViewer($viewer) 95 ->withPHIDs(array($commit_phid)) 96 ->needAuditRequests(true) 97 ->executeOne(); 98 if (!$commit) { 99 return; 100 } 101 102 $old_status = $commit->getAuditStatusObject(); 103 $commit->updateAuditStatus($commit->getAudits()); 104 $new_status = $commit->getAuditStatusObject(); 105 106 if ($old_status->getKey() == $new_status->getKey()) { 107 echo tsprintf( 108 "%s\n", 109 pht( 110 'No synchronization changes for "%s".', 111 $commit->getDisplayName())); 112 } else { 113 echo tsprintf( 114 "%s\n", 115 pht( 116 'Synchronizing "%s": "%s" -> "%s".', 117 $commit->getDisplayName(), 118 $old_status->getName(), 119 $new_status->getName())); 120 121 $commit->save(); 122 } 123 } 124 125}