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

Use DifferentialCommitMessageParser and Modular Transactions to implement "Auditors: ..."

Summary:
Ref T10978. Updates how we implement "Auditors: ..." in commit messages:

- Use the same parsing code as everything else.
- (Also: parse package names.)
- Use the new transaction code.

Also, fix some UI strings.

Test Plan: Used `bin/repository reparse --herald <commit>` to re-run this code on commits with various messages (valid Auditors, invalid Auditors, no Auditors). Saw appropriate auditors added in the UI.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10978

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

+32 -20
+11 -20
src/applications/audit/editor/PhabricatorAuditEditor.php
··· 375 375 private function createAuditRequestTransactionFromCommitMessage( 376 376 PhabricatorRepositoryCommit $commit) { 377 377 378 + $actor = $this->getActor(); 378 379 $data = $commit->getCommitData(); 379 380 $message = $data->getCommitMessage(); 380 381 381 - $matches = null; 382 - if (!preg_match('/^Auditors?:\s*(.*)$/im', $message, $matches)) { 383 - return array(); 384 - } 382 + $result = DifferentialCommitMessageParser::newStandardParser($actor) 383 + ->setRaiseMissingFieldErrors(false) 384 + ->parseFields($message); 385 385 386 - $phids = id(new PhabricatorObjectListQuery()) 387 - ->setViewer($this->getActor()) 388 - ->setAllowPartialResults(true) 389 - ->setAllowedTypes( 390 - array( 391 - PhabricatorPeopleUserPHIDType::TYPECONST, 392 - PhabricatorProjectProjectPHIDType::TYPECONST, 393 - )) 394 - ->setObjectList($matches[1]) 395 - ->execute(); 396 - 386 + $field_key = DifferentialAuditorsCommitMessageField::FIELDKEY; 387 + $phids = idx($result, $field_key, null); 397 388 if (!$phids) { 398 389 return array(); 399 390 } 400 391 401 - foreach ($phids as $phid) { 402 - $this->addAuditReason($phid, pht('Requested by Author')); 403 - } 404 392 return id(new PhabricatorAuditTransaction()) 405 - ->setTransactionType(PhabricatorAuditActionConstants::ADD_AUDITORS) 406 - ->setNewValue(array_fuse($phids)); 393 + ->setTransactionType(DiffusionCommitAuditorsTransaction::TRANSACTIONTYPE) 394 + ->setNewValue( 395 + array( 396 + '+' => array_fuse($phids), 397 + )); 407 398 } 408 399 409 400 protected function sortTransactions(array $xactions) {
+1
src/applications/differential/field/DifferentialAuditorsCommitMessageField.php
··· 15 15 array( 16 16 PhabricatorPeopleUserPHIDType::TYPECONST, 17 17 PhabricatorProjectProjectPHIDType::TYPECONST, 18 + PhabricatorOwnersPackagePHIDType::TYPECONST, 18 19 )); 19 20 } 20 21
+20
src/infrastructure/internationalization/translation/PhabricatorUSEnglishTranslation.php
··· 1588 1588 ), 1589 1589 ), 1590 1590 1591 + '%s added %s auditor(s): %s.' => array( 1592 + array( 1593 + '%s added an auditor: %3$s.', 1594 + '%s added auditors: %3$s.', 1595 + ), 1596 + ), 1597 + 1598 + '%s removed %s auditor(s): %s.' => array( 1599 + array( 1600 + '%s removed an auditor: %3$s.', 1601 + '%s removed auditors: %3$s.', 1602 + ), 1603 + ), 1604 + 1605 + '%s edited %s auditor(s), removed %s: %s; added %s: %s.' => array( 1606 + array( 1607 + '%s edited auditors, removed: %4$s; added: %6$s.', 1608 + ), 1609 + ), 1610 + 1591 1611 ); 1592 1612 } 1593 1613