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

Remove nearly all remaining references to "Autoclose"

Summary:
Depends on D20464. Ref T13277. Broadly:

- Move all the "should publish X" and "why aren't we publishing X" stuff to a separate class (`PhabricatorRepositoryPublisher`).
- Rename things to be more consistent with modern terminology ("Publish", "Permanent Refs").

Test Plan:
This could use some trial-by-fire on `secure`, but:

- Grepped for all symbols.
- Viewed various commits.
- Reparsed commits.
- Here's a commit with an explanation:

{F6394569}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13277

Differential Revision: https://secure.phabricator.com/D20465

+184 -368
+2 -2
src/__phutil_library_map__.php
··· 688 688 'DiffusionBranchListView' => 'applications/diffusion/view/DiffusionBranchListView.php', 689 689 'DiffusionBranchQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionBranchQueryConduitAPIMethod.php', 690 690 'DiffusionBranchTableController' => 'applications/diffusion/controller/DiffusionBranchTableController.php', 691 - 'DiffusionBranchTableView' => 'applications/diffusion/view/DiffusionBranchTableView.php', 692 691 'DiffusionBrowseController' => 'applications/diffusion/controller/DiffusionBrowseController.php', 693 692 'DiffusionBrowseQueryConduitAPIMethod' => 'applications/diffusion/conduit/DiffusionBrowseQueryConduitAPIMethod.php', 694 693 'DiffusionBrowseResultSet' => 'applications/diffusion/data/DiffusionBrowseResultSet.php', ··· 4408 4407 'PhabricatorRepositoryOldRef' => 'applications/repository/storage/PhabricatorRepositoryOldRef.php', 4409 4408 'PhabricatorRepositoryParsedChange' => 'applications/repository/data/PhabricatorRepositoryParsedChange.php', 4410 4409 'PhabricatorRepositoryPermanentRefsTransaction' => 'applications/repository/xaction/PhabricatorRepositoryPermanentRefsTransaction.php', 4410 + 'PhabricatorRepositoryPublisher' => 'applications/repository/query/PhabricatorRepositoryPublisher.php', 4411 4411 'PhabricatorRepositoryPullEngine' => 'applications/repository/engine/PhabricatorRepositoryPullEngine.php', 4412 4412 'PhabricatorRepositoryPullEvent' => 'applications/repository/storage/PhabricatorRepositoryPullEvent.php', 4413 4413 'PhabricatorRepositoryPullEventPHIDType' => 'applications/repository/phid/PhabricatorRepositoryPullEventPHIDType.php', ··· 6352 6352 'DiffusionBranchListView' => 'DiffusionView', 6353 6353 'DiffusionBranchQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod', 6354 6354 'DiffusionBranchTableController' => 'DiffusionController', 6355 - 'DiffusionBranchTableView' => 'DiffusionView', 6356 6355 'DiffusionBrowseController' => 'DiffusionController', 6357 6356 'DiffusionBrowseQueryConduitAPIMethod' => 'DiffusionQueryConduitAPIMethod', 6358 6357 'DiffusionBrowseResultSet' => 'Phobject', ··· 10690 10689 ), 10691 10690 'PhabricatorRepositoryParsedChange' => 'Phobject', 10692 10691 'PhabricatorRepositoryPermanentRefsTransaction' => 'PhabricatorRepositoryTransactionType', 10692 + 'PhabricatorRepositoryPublisher' => 'Phobject', 10693 10693 'PhabricatorRepositoryPullEngine' => 'PhabricatorRepositoryEngine', 10694 10694 'PhabricatorRepositoryPullEvent' => array( 10695 10695 'PhabricatorRepositoryDAO',
+4 -2
src/applications/audit/editor/PhabricatorAuditEditor.php
··· 718 718 switch ($xaction->getTransactionType()) { 719 719 case PhabricatorAuditTransaction::TYPE_COMMIT: 720 720 $repository = $object->getRepository(); 721 - if (!$repository->shouldPublishCommit($object)) { 721 + $publisher = $repository->newPublisher(); 722 + if (!$publisher->shouldPublishCommit($object)) { 722 723 return false; 723 724 } 724 725 return true; ··· 779 780 // TODO: They should, and then we should simplify this. 780 781 $repository = $object->getRepository($assert_attached = false); 781 782 if ($repository != PhabricatorLiskDAO::ATTACHABLE) { 782 - if (!$repository->shouldPublishCommit($object)) { 783 + $publisher = $repository->newPublisher(); 784 + if (!$publisher->shouldPublishCommit($object)) { 783 785 return false; 784 786 } 785 787 }
+1 -1
src/applications/diffusion/controller/DiffusionCommitController.php
··· 243 243 if (!$commit->isPermanentCommit()) { 244 244 $nonpermanent_tag = id(new PHUITagView()) 245 245 ->setType(PHUITagView::TYPE_SHADE) 246 - ->setName(pht('Not Permanent')) 246 + ->setName(pht('Unpublished')) 247 247 ->setColor(PHUITagView::COLOR_ORANGE); 248 248 249 249 $header->addTag($nonpermanent_tag);
+8 -22
src/applications/diffusion/editor/DiffusionCommitEditEngine.php
··· 113 113 ->setConduitTypeDescription(pht('New auditors.')) 114 114 ->setValue($object->getAuditorPHIDsForEdit()); 115 115 116 - $reason = $data->getCommitDetail('autocloseReason', false); 117 - if ($reason !== false) { 118 - switch ($reason) { 119 - case PhabricatorRepository::BECAUSE_REPOSITORY_IMPORTING: 120 - $desc = pht('No, Repository Importing'); 121 - break; 122 - case PhabricatorRepository::BECAUSE_AUTOCLOSE_DISABLED: 123 - $desc = pht('No, Repository Publishing Disabled'); 124 - break; 125 - case PhabricatorRepository::BECAUSE_NOT_ON_AUTOCLOSE_BRANCH: 126 - $desc = pht('No, Not Reachable from Permanent Ref'); 127 - break; 128 - // Old commits which were manually reparsed with "--force-autoclose" 129 - // may have this constant. This flag is no longer supported. 130 - case 'auto/forced': 131 - case null: 132 - $desc = pht('Yes'); 133 - break; 134 - default: 135 - $desc = pht('Unknown'); 136 - break; 116 + $holds = $data->getPublisherHoldReasons(); 117 + if ($holds) { 118 + $hold_names = array(); 119 + foreach ($holds as $hold) { 120 + $hold_names[] = id(new PhabricatorRepositoryPublisher()) 121 + ->getHoldName($hold); 137 122 } 123 + $desc = implode('; ', $hold_names); 138 124 139 125 $doc_href = PhabricatorEnv::getDoclink( 140 126 'Diffusion User Guide: Permanent Refs'); ··· 147 133 pht('Learn More')); 148 134 149 135 $fields[] = id(new PhabricatorStaticEditField()) 150 - ->setLabel(pht('Published?')) 136 + ->setLabel(pht('Unpublished')) 151 137 ->setValue(array($desc, " \xC2\xB7 ", $doc_link)); 152 138 } 153 139
+3 -1
src/applications/diffusion/management/DiffusionRepositoryBranchesManagementPanel.php
··· 129 129 $branches = $pager->sliceResults($branches); 130 130 $can_close_branches = ($repository->isHg()); 131 131 132 + $publisher = $repository->newPublisher(); 133 + 132 134 $rows = array(); 133 135 foreach ($branches as $branch) { 134 136 $branch_name = $branch->getShortName(); 135 - $permanent = $repository->shouldAutocloseBranch($branch_name); 137 + $permanent = $publisher->shouldPublishRef($branch); 136 138 137 139 $default = $repository->getDefaultBranch(); 138 140 $icon = null;
-166
src/applications/diffusion/view/DiffusionBranchTableView.php
··· 1 - <?php 2 - 3 - final class DiffusionBranchTableView extends DiffusionView { 4 - 5 - private $branches; 6 - private $commits = array(); 7 - 8 - public function setBranches(array $branches) { 9 - assert_instances_of($branches, 'DiffusionRepositoryRef'); 10 - $this->branches = $branches; 11 - return $this; 12 - } 13 - 14 - public function setCommits(array $commits) { 15 - assert_instances_of($commits, 'PhabricatorRepositoryCommit'); 16 - $this->commits = mpull($commits, null, 'getCommitIdentifier'); 17 - return $this; 18 - } 19 - 20 - public function render() { 21 - $drequest = $this->getDiffusionRequest(); 22 - $current_branch = $drequest->getBranch(); 23 - $repository = $drequest->getRepository(); 24 - $commits = $this->commits; 25 - $viewer = $this->getUser(); 26 - 27 - $buildables = $this->loadBuildables($commits); 28 - $have_builds = false; 29 - 30 - $can_close_branches = ($repository->isHg()); 31 - 32 - Javelin::initBehavior('phabricator-tooltips'); 33 - 34 - $doc_href = PhabricatorEnv::getDoclink( 35 - 'Diffusion User Guide: Permanent Refs'); 36 - 37 - $rows = array(); 38 - $rowc = array(); 39 - foreach ($this->branches as $branch) { 40 - $commit = idx($commits, $branch->getCommitIdentifier()); 41 - if ($commit) { 42 - $details = $commit->getSummary(); 43 - $datetime = $viewer->formatShortDateTime($commit->getEpoch()); 44 - $buildable = idx($buildables, $commit->getPHID()); 45 - if ($buildable) { 46 - $build_status = $this->renderBuildable($buildable); 47 - $have_builds = true; 48 - } else { 49 - $build_status = null; 50 - } 51 - } else { 52 - $datetime = null; 53 - $details = null; 54 - $build_status = null; 55 - } 56 - 57 - switch ($repository->shouldSkipAutocloseBranch($branch->getShortName())) { 58 - case PhabricatorRepository::BECAUSE_REPOSITORY_IMPORTING: 59 - $icon = 'fa-times bluegrey'; 60 - $tip = pht('Repository Importing'); 61 - break; 62 - case PhabricatorRepository::BECAUSE_AUTOCLOSE_DISABLED: 63 - $icon = 'fa-times bluegrey'; 64 - $tip = pht('Repository Publishing Disabled'); 65 - break; 66 - case PhabricatorRepository::BECAUSE_BRANCH_UNTRACKED: 67 - $icon = 'fa-times bluegrey'; 68 - $tip = pht('Branch Untracked'); 69 - break; 70 - case PhabricatorRepository::BECAUSE_BRANCH_NOT_AUTOCLOSE: 71 - $icon = 'fa-times bluegrey'; 72 - $tip = pht('Branch Not Permanent'); 73 - break; 74 - case null: 75 - $icon = 'fa-check bluegrey'; 76 - $tip = pht('Permanent Branch'); 77 - break; 78 - default: 79 - $icon = 'fa-question'; 80 - $tip = pht('Status Unknown'); 81 - break; 82 - } 83 - 84 - $status_icon = id(new PHUIIconView()) 85 - ->setIcon($icon) 86 - ->addSigil('has-tooltip') 87 - ->setHref($doc_href) 88 - ->setMetadata( 89 - array( 90 - 'tip' => $tip, 91 - 'size' => 200, 92 - )); 93 - 94 - $fields = $branch->getRawFields(); 95 - $closed = idx($fields, 'closed'); 96 - if ($closed) { 97 - $status = pht('Closed'); 98 - } else { 99 - $status = pht('Open'); 100 - } 101 - 102 - $rows[] = array( 103 - $this->linkBranchHistory($branch->getShortName()), 104 - phutil_tag( 105 - 'a', 106 - array( 107 - 'href' => $drequest->generateURI( 108 - array( 109 - 'action' => 'browse', 110 - 'branch' => $branch->getShortName(), 111 - )), 112 - ), 113 - $branch->getShortName()), 114 - self::linkCommit( 115 - $drequest->getRepository(), 116 - $branch->getCommitIdentifier()), 117 - $build_status, 118 - $status, 119 - AphrontTableView::renderSingleDisplayLine($details), 120 - $status_icon, 121 - $datetime, 122 - ); 123 - if ($branch->getShortName() == $current_branch) { 124 - $rowc[] = 'highlighted'; 125 - } else { 126 - $rowc[] = null; 127 - } 128 - } 129 - 130 - $view = new AphrontTableView($rows); 131 - $view->setHeaders( 132 - array( 133 - null, 134 - pht('Branch'), 135 - pht('Head'), 136 - null, 137 - pht('State'), 138 - pht('Details'), 139 - null, 140 - pht('Committed'), 141 - )); 142 - $view->setColumnClasses( 143 - array( 144 - '', 145 - 'pri', 146 - '', 147 - 'icon', 148 - '', 149 - 'wide', 150 - '', 151 - 'right', 152 - )); 153 - $view->setColumnVisibility( 154 - array( 155 - true, 156 - true, 157 - true, 158 - $have_builds, 159 - $can_close_branches, 160 - )); 161 - $view->setRowClasses($rowc); 162 - return $view->render(); 163 - } 164 - 165 - 166 - }
+4 -2
src/applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php
··· 127 127 */ 128 128 private function discoverGitCommits() { 129 129 $repository = $this->getRepository(); 130 + $publisher = $repository->newPublisher(); 130 131 131 132 $heads = id(new DiffusionLowLevelGitRefQuery()) 132 133 ->setRepository($repository) ··· 185 186 $head_refs = $this->discoverStreamAncestry( 186 187 new PhabricatorGitGraphStream($repository, $commit), 187 188 $commit, 188 - $repository->shouldAutocloseRef($ref)); 189 + $publisher->shouldPublishRef($ref)); 189 190 190 191 $this->didDiscoverRefs($head_refs); 191 192 ··· 514 515 */ 515 516 private function sortRefs(array $refs) { 516 517 $repository = $this->getRepository(); 518 + $publisher = $repository->newPublisher(); 517 519 518 520 $head_refs = array(); 519 521 $tail_refs = array(); 520 522 foreach ($refs as $ref) { 521 - if ($repository->shouldAutocloseRef($ref)) { 523 + if ($publisher->shouldPublishRef($ref)) { 522 524 $head_refs[] = $ref; 523 525 } else { 524 526 $tail_refs[] = $ref;
+1 -1
src/applications/repository/engine/PhabricatorRepositoryRefEngine.php
··· 347 347 return false; 348 348 } 349 349 350 - return $this->getRepository()->shouldAutocloseBranch($ref_name); 350 + return $this->getRepository()->isBranchPermanentRef($ref_name); 351 351 } 352 352 353 353 /**
+120
src/applications/repository/query/PhabricatorRepositoryPublisher.php
··· 1 + <?php 2 + 3 + final class PhabricatorRepositoryPublisher 4 + extends Phobject { 5 + 6 + private $repository; 7 + 8 + const HOLD_IMPORTING = 'auto/importing'; 9 + const HOLD_PUBLISHING_DISABLED = 'auto/disabled'; 10 + const HOLD_REF_NOT_BRANCH = 'not-branch'; 11 + const HOLD_NOT_REACHABLE_FROM_PERMANENT_REF = 'auto/nobranch'; 12 + const HOLD_UNTRACKED = 'auto/notrack'; 13 + const HOLD_NOT_PERMANENT_REF = 'auto/noclose'; 14 + 15 + public function setRepository(PhabricatorRepository $repository) { 16 + $this->repository = $repository; 17 + return $this; 18 + } 19 + 20 + public function getRepository() { 21 + if (!$this->repository) { 22 + throw new PhutilInvalidStateException('setRepository'); 23 + } 24 + return $this->repository; 25 + } 26 + 27 + /* -( Publishing )--------------------------------------------------------- */ 28 + 29 + public function shouldPublishRepository() { 30 + return !$this->getRepositoryHoldReasons(); 31 + } 32 + 33 + public function shouldPublishRef(DiffusionRepositoryRef $ref) { 34 + return !$this->getRefHoldReasons($ref); 35 + } 36 + 37 + public function shouldPublishCommit(PhabricatorRepositoryCommit $commit) { 38 + return !$this->getCommitHoldReasons($commit); 39 + } 40 + 41 + /* -( Hold Reasons )------------------------------------------------------- */ 42 + 43 + public function getRepositoryHoldReasons() { 44 + $repository = $this->getRepository(); 45 + 46 + $reasons = array(); 47 + if ($repository->isImporting()) { 48 + $reasons[] = self::HOLD_IMPORTING; 49 + } 50 + 51 + if ($repository->isPublishingDisabled()) { 52 + $reasons[] = self::HOLD_PUBLISHING_DISABLED; 53 + } 54 + 55 + return $reasons; 56 + } 57 + 58 + public function getRefHoldReasons(DiffusionRepositoryRef $ref) { 59 + $repository = $this->getRepository(); 60 + $reasons = $this->getRepositoryHoldReasons(); 61 + 62 + if (!$ref->isBranch()) { 63 + $reasons[] = self::HOLD_REF_NOT_BRANCH; 64 + } else { 65 + $branch_name = $ref->getShortName(); 66 + 67 + if (!$repository->shouldTrackBranch($branch_name)) { 68 + $reasons[] = self::HOLD_UNTRACKED; 69 + } 70 + 71 + if (!$repository->isBranchPermanentRef($branch_name)) { 72 + $reasons[] = self::HOLD_NOT_PERMANENT_REF; 73 + } 74 + } 75 + 76 + return $reasons; 77 + } 78 + 79 + public function getCommitHoldReasons(PhabricatorRepositoryCommit $commit) { 80 + $repository = $this->getRepository(); 81 + $reasons = $this->getRepositoryHoldReasons(); 82 + 83 + if ($repository->isGit()) { 84 + if (!$commit->isPermanentCommit()) { 85 + $reasons[] = self::HOLD_NOT_REACHABLE_FROM_PERMANENT_REF; 86 + } 87 + } 88 + 89 + return $reasons; 90 + } 91 + 92 + /* -( Rendering )---------------------------------------------------------- */ 93 + 94 + public function getHoldName($hold) { 95 + $map = array( 96 + self::HOLD_IMPORTING => array( 97 + 'name' => pht('Repository Importing'), 98 + ), 99 + self::HOLD_PUBLISHING_DISABLED => array( 100 + 'name' => pht('Repository Publishing Disabled'), 101 + ), 102 + self::HOLD_REF_NOT_BRANCH => array( 103 + 'name' => pht('Not a Branch'), 104 + ), 105 + self::HOLD_NOT_REACHABLE_FROM_PERMANENT_REF => array( 106 + 'name' => pht('Not Reachable from Permanent Ref'), 107 + ), 108 + self::HOLD_UNTRACKED => array( 109 + 'name' => pht('Untracked Ref'), 110 + ), 111 + self::HOLD_NOT_PERMANENT_REF => array( 112 + 'name' => pht('Not a Permanent Ref'), 113 + ), 114 + ); 115 + 116 + $spec = idx($map, $hold, array()); 117 + return idx($spec, 'name', pht('Unknown ("%s")', $hold)); 118 + } 119 + 120 + }
+9 -160
src/applications/repository/storage/PhabricatorRepository.php
··· 2 2 3 3 /** 4 4 * @task uri Repository URI Management 5 - * @task autoclose Autoclose 5 + * @task publishing Publishing 6 6 * @task sync Cluster Synchronization 7 7 */ 8 8 final class PhabricatorRepository extends PhabricatorRepositoryDAO ··· 41 41 const TABLE_LINTMESSAGE = 'repository_lintmessage'; 42 42 const TABLE_PARENTS = 'repository_parents'; 43 43 const TABLE_COVERAGE = 'repository_coverage'; 44 - 45 - const BECAUSE_REPOSITORY_IMPORTING = 'auto/importing'; 46 - const BECAUSE_AUTOCLOSE_DISABLED = 'auto/disabled'; 47 - const BECAUSE_NOT_ON_AUTOCLOSE_BRANCH = 'auto/nobranch'; 48 - const BECAUSE_BRANCH_UNTRACKED = 'auto/notrack'; 49 - const BECAUSE_BRANCH_NOT_AUTOCLOSE = 'auto/noclose'; 50 44 51 45 const STATUS_ACTIVE = 'active'; 52 46 const STATUS_INACTIVE = 'inactive'; ··· 952 946 return $this->isBranchInFilter($branch, 'branch-filter'); 953 947 } 954 948 949 + public function isBranchPermanentRef($branch) { 950 + return $this->isBranchInFilter($branch, 'close-commits-filter'); 951 + } 952 + 955 953 public function formatCommitName($commit_identifier, $local = false) { 956 954 $vcs = $this->getVersionControlSystem(); 957 955 ··· 1036 1034 return $ratio; 1037 1035 } 1038 1036 1039 - /** 1040 - * Should this repository publish feed, notifications, audits, and email? 1041 - * 1042 - * We do not publish information about repositories during initial import, 1043 - * or if the repository has been set not to publish. 1044 - */ 1045 - public function shouldPublish() { 1046 - if ($this->isImporting()) { 1047 - return false; 1048 - } 1049 - 1050 - if ($this->isPublishingDisabled()) { 1051 - return false; 1052 - } 1037 + /* -( Publishing )--------------------------------------------------------- */ 1053 1038 1054 - return true; 1039 + public function newPublisher() { 1040 + return id(new PhabricatorRepositoryPublisher()) 1041 + ->setRepository($this); 1055 1042 } 1056 1043 1057 1044 public function isPublishingDisabled() { 1058 1045 return $this->getDetail('herald-disabled'); 1059 - } 1060 - 1061 - public function shouldPublishCommit(PhabricatorRepositoryCommit $commit) { 1062 - if (!$this->shouldPublish()) { 1063 - return false; 1064 - } 1065 - 1066 - if (!$commit->isPermanentCommit()) { 1067 - return false; 1068 - } 1069 - 1070 - return true; 1071 - } 1072 - 1073 - 1074 - /* -( Autoclose )---------------------------------------------------------- */ 1075 - 1076 - 1077 - public function shouldAutocloseRef(DiffusionRepositoryRef $ref) { 1078 - if (!$ref->isBranch()) { 1079 - return false; 1080 - } 1081 - 1082 - return $this->shouldAutocloseBranch($ref->getShortName()); 1083 - } 1084 - 1085 - /** 1086 - * Determine if autoclose is active for a branch. 1087 - * 1088 - * For more details about why, use @{method:shouldSkipAutocloseBranch}. 1089 - * 1090 - * @param string Branch name to check. 1091 - * @return bool True if autoclose is active for the branch. 1092 - * @task autoclose 1093 - */ 1094 - public function shouldAutocloseBranch($branch) { 1095 - return ($this->shouldSkipAutocloseBranch($branch) === null); 1096 - } 1097 - 1098 - /** 1099 - * Determine if autoclose is active for a commit. 1100 - * 1101 - * For more details about why, use @{method:shouldSkipAutocloseCommit}. 1102 - * 1103 - * @param PhabricatorRepositoryCommit Commit to check. 1104 - * @return bool True if autoclose is active for the commit. 1105 - * @task autoclose 1106 - */ 1107 - public function shouldAutocloseCommit(PhabricatorRepositoryCommit $commit) { 1108 - return ($this->shouldSkipAutocloseCommit($commit) === null); 1109 - } 1110 - 1111 - 1112 - /** 1113 - * Determine why autoclose should be skipped for a branch. 1114 - * 1115 - * This method gives a detailed reason why autoclose will be skipped. To 1116 - * perform a simple test, use @{method:shouldAutocloseBranch}. 1117 - * 1118 - * @param string Branch name to check. 1119 - * @return const|null Constant identifying reason to skip this branch, or null 1120 - * if autoclose is active. 1121 - * @task autoclose 1122 - */ 1123 - public function shouldSkipAutocloseBranch($branch) { 1124 - $all_reason = $this->shouldSkipAllAutoclose(); 1125 - if ($all_reason) { 1126 - return $all_reason; 1127 - } 1128 - 1129 - if (!$this->shouldTrackBranch($branch)) { 1130 - return self::BECAUSE_BRANCH_UNTRACKED; 1131 - } 1132 - 1133 - if (!$this->isBranchInFilter($branch, 'close-commits-filter')) { 1134 - return self::BECAUSE_BRANCH_NOT_AUTOCLOSE; 1135 - } 1136 - 1137 - return null; 1138 - } 1139 - 1140 - 1141 - /** 1142 - * Determine why autoclose should be skipped for a commit. 1143 - * 1144 - * This method gives a detailed reason why autoclose will be skipped. To 1145 - * perform a simple test, use @{method:shouldAutocloseCommit}. 1146 - * 1147 - * @param PhabricatorRepositoryCommit Commit to check. 1148 - * @return const|null Constant identifying reason to skip this commit, or null 1149 - * if autoclose is active. 1150 - * @task autoclose 1151 - */ 1152 - public function shouldSkipAutocloseCommit( 1153 - PhabricatorRepositoryCommit $commit) { 1154 - 1155 - $all_reason = $this->shouldSkipAllAutoclose(); 1156 - if ($all_reason) { 1157 - return $all_reason; 1158 - } 1159 - 1160 - switch ($this->getVersionControlSystem()) { 1161 - case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN: 1162 - case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL: 1163 - return null; 1164 - case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT: 1165 - break; 1166 - default: 1167 - throw new Exception(pht('Unrecognized version control system.')); 1168 - } 1169 - 1170 - if (!$commit->isPermanentCommit()) { 1171 - return self::BECAUSE_NOT_ON_AUTOCLOSE_BRANCH; 1172 - } 1173 - 1174 - return null; 1175 - } 1176 - 1177 - 1178 - /** 1179 - * Determine why all autoclose operations should be skipped for this 1180 - * repository. 1181 - * 1182 - * @return const|null Constant identifying reason to skip all autoclose 1183 - * operations, or null if autoclose operations are not blocked at the 1184 - * repository level. 1185 - * @task autoclose 1186 - */ 1187 - private function shouldSkipAllAutoclose() { 1188 - if ($this->isImporting()) { 1189 - return self::BECAUSE_REPOSITORY_IMPORTING; 1190 - } 1191 - 1192 - if ($this->isPublishingDisabled()) { 1193 - return self::BECAUSE_AUTOCLOSE_DISABLED; 1194 - } 1195 - 1196 - return null; 1197 1046 } 1198 1047 1199 1048 public function getPermanentRefRules() {
+19
src/applications/repository/storage/PhabricatorRepositoryCommitData.php
··· 68 68 ->loadFromArray($dict); 69 69 } 70 70 71 + public function getPublisherHoldReasons() { 72 + $holds = $this->getCommitDetail('holdReasons'); 73 + 74 + // Look for the legacy "autocloseReason" if we don't have a modern list 75 + // of hold reasons. 76 + if (!$holds) { 77 + $old_hold = $this->getCommitDetail('autocloseReason'); 78 + if ($old_hold) { 79 + $holds = array($old_hold); 80 + } 81 + } 82 + 83 + if (!$holds) { 84 + $holds = array(); 85 + } 86 + 87 + return $holds; 88 + } 89 + 71 90 }
+2 -1
src/applications/repository/worker/PhabricatorRepositoryCommitOwnersWorker.php
··· 30 30 PhabricatorRepositoryCommit $commit) { 31 31 $viewer = PhabricatorUser::getOmnipotentUser(); 32 32 33 - if (!$repository->shouldPublishCommit($commit)) { 33 + $publisher = $repository->newPublisher(); 34 + if (!$publisher->shouldPublishCommit($commit)) { 34 35 return; 35 36 } 36 37
+3 -1
src/applications/repository/worker/PhabricatorRepositoryPushMailWorker.php
··· 22 22 ->executeOne(); 23 23 24 24 $repository = $event->getRepository(); 25 - if (!$repository->shouldPublish()) { 25 + 26 + $publisher = $repository->newPublisher(); 27 + if (!$publisher->shouldPublishRepository()) { 26 28 // If the repository is still importing, don't send email. 27 29 return; 28 30 }
+8 -9
src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
··· 157 157 $commit->setSummary($data->getSummary()); 158 158 $commit->save(); 159 159 160 - // Figure out if we're going to try to "autoclose" related objects (e.g., 161 - // close linked tasks and related revisions) and, if not, record why we 162 - // aren't. Autoclose can be disabled for various reasons at the repository 163 - // or commit levels. 160 + // If we're publishing this commit, we're going to queue tasks to update 161 + // referenced objects (like tasks and revisions). Otherwise, record some 162 + // details about why we are not publishing it yet. 164 163 165 - $autoclose_reason = $repository->shouldSkipAutocloseCommit($commit); 166 - $data->setCommitDetail('autocloseReason', $autoclose_reason); 167 - $should_autoclose = $repository->shouldAutocloseCommit($commit); 168 - 169 - if ($should_autoclose) { 164 + $publisher = $repository->newPublisher(); 165 + if ($publisher->shouldPublishCommit($commit)) { 170 166 $actor = PhabricatorUser::getOmnipotentUser(); 171 167 $this->closeRevisions($actor, $ref, $commit, $data); 172 168 $this->closeTasks($actor, $ref, $commit, $data); 169 + } else { 170 + $hold_reasons = $publisher->getCommitHoldReasons($commit); 171 + $data->setCommitDetail('holdReasons', $hold_reasons); 173 172 } 174 173 175 174 $data->save();