Skip to content

Commit e2b43c6

Browse files
authored
PhabricatorRepositoryCommitPublishWorker: move relevance logic (1963406) (#64)
- move repository matching check to PhabricatorRepositoryCommitPublishWorker Prior to this change, a commit that matches a revision was still going through code in both PhabricatorRepositoryCommitPublishWorker and DiffusionUpdateObjectAfterCommitWorker that was making changes to the revision other than changin the status. With this change, the revisions will still show a link to the commit, however none of the code in DiffusionUpdateObjectAfterCommitWorker will be triggered.
1 parent 5439f62 commit e2b43c6

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

src/applications/diffusion/worker/DiffusionUpdateObjectAfterCommitWorker.php

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -183,37 +183,20 @@ private function updateRevision(
183183

184184
$xactions = array();
185185

186-
$revisionRepositoryCallsign = $revision->getRepository()->getCallsign();
187-
$commitRepositoryCallsign = $commit->getRepository()->getCallsign();
188-
189-
$mustCloseRevision = false;
190-
if ($revisionRepositoryCallsign === $commitRepositoryCallsign) {
191-
$mustCloseRevision = true;
192-
} else {
193-
$config = PhabricatorEnv::getEnvConfig('diffusion.legacy-repos-mapping');
194-
if (array_key_exists($revisionRepositoryCallsign, $config)) {
195-
if ($config[$revisionRepositoryCallsign] === $commitRepositoryCallsign) {
196-
$mustCloseRevision = true;
197-
}
198-
}
199-
}
186+
$xactions[] = $this->newEdgeTransaction(
187+
$revision,
188+
$commit,
189+
DifferentialRevisionHasCommitEdgeType::EDGECONST);
200190

201-
if ($mustCloseRevision) {
202-
$xactions[] = $this->newEdgeTransaction(
203-
$revision,
204-
$commit,
205-
DifferentialRevisionHasCommitEdgeType::EDGECONST);
206-
207-
$match_data = $this->getUpdateProperty('revisionMatchData');
208-
209-
$type_close = DifferentialRevisionCloseTransaction::TRANSACTIONTYPE;
210-
$xactions[] = $revision->getApplicationTransactionTemplate()
211-
->setTransactionType($type_close)
212-
->setNewValue(true)
213-
->setMetadataValue('isCommitClose', true)
214-
->setMetadataValue('revisionMatchData', $match_data)
215-
->setMetadataValue('commitPHID', $commit->getPHID());
216-
}
191+
$match_data = $this->getUpdateProperty('revisionMatchData');
192+
193+
$type_close = DifferentialRevisionCloseTransaction::TRANSACTIONTYPE;
194+
$xactions[] = $revision->getApplicationTransactionTemplate()
195+
->setTransactionType($type_close)
196+
->setNewValue(true)
197+
->setMetadataValue('isCommitClose', true)
198+
->setMetadataValue('revisionMatchData', $match_data)
199+
->setMetadataValue('commitPHID', $commit->getPHID());
217200

218201
$extraction_engine = id(new DifferentialDiffExtractionEngine())
219202
->setViewer($viewer)

src/applications/repository/worker/PhabricatorRepositoryCommitPublishWorker.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,25 @@ private function closeRevisions(
456456
return;
457457
}
458458

459+
$revisionRepositoryCallsign = $revision->getRepository()->getCallsign();
460+
$commitRepositoryCallsign = $commit->getRepository()->getCallsign();
461+
462+
$mustCloseRevision = false;
463+
if ($revisionRepositoryCallsign === $commitRepositoryCallsign) {
464+
$mustCloseRevision = true;
465+
} else {
466+
$config = PhabricatorEnv::getEnvConfig('diffusion.legacy-repos-mapping');
467+
if (array_key_exists($revisionRepositoryCallsign, $config)) {
468+
if ($config[$revisionRepositoryCallsign] === $commitRepositoryCallsign) {
469+
$mustCloseRevision = true;
470+
}
471+
}
472+
}
473+
474+
if (!$mustCloseRevision) {
475+
return;
476+
}
477+
459478
// NOTE: This is very old code from when revisions had a single reviewer.
460479
// It still powers the "Reviewer (Deprecated)" field in Herald, but should
461480
// be removed.

0 commit comments

Comments
 (0)