1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-23 05:50:55 +01:00

CC users mentioned in revision fields

Summary:
Users are used to this feature from comments.
Provide it also in title, summary and test plan.
It adds the users to CC only on creating the revision to avoid cases like:
"I mentioned this user but now I want to remove him from CC" or he unsubscribes.

Test Plan: Wrote `@epriestley` to summary.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D4050
This commit is contained in:
vrana 2012-11-28 23:01:07 -08:00
parent 150f711cc8
commit fc8d8b6f8c
5 changed files with 38 additions and 0 deletions

View file

@ -162,6 +162,18 @@ final class DifferentialRevisionEditor extends PhabricatorEditor {
$this->cc = $revision->getCCPHIDs();
}
if ($is_new) {
$content_blocks = array();
foreach ($this->auxiliaryFields as $field) {
if ($field->shouldExtractMentions()) {
$content_blocks[] = $field->renderValueForCommitMessage(false);
}
}
$phids = PhabricatorMarkupEngine::extractPHIDsFromMentions(
$content_blocks);
$this->cc = array_unique(array_merge($this->cc, $phids));
}
$diff = $this->getDiff();
if ($diff) {
$revision->setLineCount($diff->getLineCount());

View file

@ -165,6 +165,20 @@ abstract class DifferentialFieldSpecification {
return;
}
/**
* Determine if user mentions should be extracted from the value and added to
* CC when creating revision. Mentions are then extracted from the string
* returned by @{method:renderValueForCommitMessage}.
*
* By default, mentions are not extracted.
*
* @return bool
* @task edit
*/
public function shouldExtractMentions() {
return false;
}
/**
* Hook for applying revision changes via the editor. Normally, you should
* not implement this, but a number of builtin fields use the revision object

View file

@ -25,6 +25,10 @@ final class DifferentialSummaryFieldSpecification
->setValue($this->summary);
}
public function shouldExtractMentions() {
return true;
}
public function willWriteRevision(DifferentialRevisionEditor $editor) {
$this->getRevision()->setSummary($this->summary);
}

View file

@ -38,6 +38,10 @@ final class DifferentialTestPlanFieldSpecification
->setError($this->error);
}
public function shouldExtractMentions() {
return true;
}
public function willWriteRevision(DifferentialRevisionEditor $editor) {
$this->getRevision()->setTestPlan($this->plan);
}

View file

@ -29,6 +29,10 @@ final class DifferentialTitleFieldSpecification
->setValue($this->title);
}
public function shouldExtractMentions() {
return true;
}
public function willWriteRevision(DifferentialRevisionEditor $editor) {
$this->getRevision()->setTitle($this->title);
}