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

Add `didParseCommit()` to DifferentialFieldSpecification

Summary:
This is mostly ripped from D2721, but doesn't implement the T945 part.

After we parse a commit message, give DifferentialFieldSpecifications an opportunity to react to the message as well (e.g., by updating related objects).

Test Plan: Impelmented a var_dump() body, ran `reparse.php` on a commit.

Reviewers: vrana, 20after4, btrahan, edward

Reviewed By: 20after4

CC: aran

Maniphest Tasks: T945, T1544

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

+54 -1
+19
src/applications/differential/field/specification/DifferentialFieldSpecification.php
··· 569 569 } 570 570 571 571 572 + /** 573 + * This method allows you to take action when a commit appears in a tracked 574 + * branch (for example, by closing tasks associated with the commit). 575 + * 576 + * @param PhabricatorRepository The repository the commit appeared in. 577 + * @param PhabricatorRepositoryCommit The commit itself. 578 + * @param PhabricatorRepostioryCommitData Commit data. 579 + * @return void 580 + * 581 + * @task commit 582 + */ 583 + public function didParseCommit( 584 + PhabricatorRepository $repo, 585 + PhabricatorRepositoryCommit $commit, 586 + PhabricatorRepositoryCommitData $data) { 587 + return; 588 + } 589 + 590 + 572 591 /* -( Loading Additional Data )-------------------------------------------- */ 573 592 574 593
+35 -1
src/applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php
··· 79 79 // revisit this and do something differently. (If we match several revisions 80 80 // someone probably did something very silly, though.) 81 81 82 + $revision = null; 83 + $should_autoclose = $repository->shouldAutocloseCommit($commit, $data); 82 84 $revision_id = $data->getCommitDetail('differential.revisionID'); 83 85 if (!$revision_id) { 84 86 $hashes = $this->getCommitHashes( ··· 142 144 143 145 $status_closed = ArcanistDifferentialRevisionStatus::CLOSED; 144 146 $should_close = ($revision->getStatus() != $status_closed) && 145 - $repository->shouldAutocloseCommit($commit, $data); 147 + $should_autoclose; 146 148 147 149 if ($should_close) { 148 150 $diff = $this->attachToRevision($revision, $actor_phid); ··· 169 171 $editor->setMessage($message)->save(); 170 172 } 171 173 174 + } 175 + } 176 + 177 + if ($should_autoclose && $author_phid) { 178 + $user = id(new PhabricatorUser())->loadOneWhere( 179 + 'phid = %s', 180 + $author_phid); 181 + 182 + $call = new ConduitCall( 183 + 'differential.parsecommitmessage', 184 + array( 185 + 'corpus' => $message, 186 + 'partial' => true, 187 + )); 188 + $call->setUser($user); 189 + $result = $call->execute(); 190 + 191 + $field_values = $result['fields']; 192 + 193 + $fields = DifferentialFieldSelector::newSelector() 194 + ->getFieldSpecifications(); 195 + foreach ($fields as $key => $field) { 196 + if (!$field->shouldAppearOnCommitMessage()) { 197 + continue; 198 + } 199 + $field->setUser($user); 200 + $value = idx($field_values, $field->getCommitMessageKey()); 201 + $field->setValueFromParsedCommitMessage($value); 202 + if ($revision) { 203 + $field->setRevision($revision); 204 + } 205 + $field->didParseCommit($repository, $commit, $data); 172 206 } 173 207 } 174 208