Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15450417
D8657.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
11 KB
Referenced Files
None
Subscribers
None
D8657.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -327,6 +327,7 @@
'DifferentialBranchField' => 'applications/differential/customfield/DifferentialBranchField.php',
'DifferentialCapabilityDefaultView' => 'applications/differential/capability/DifferentialCapabilityDefaultView.php',
'DifferentialChangeType' => 'applications/differential/constants/DifferentialChangeType.php',
+ 'DifferentialChangesSinceLastUpdateField' => 'applications/differential/customfield/DifferentialChangesSinceLastUpdateField.php',
'DifferentialChangeset' => 'applications/differential/storage/DifferentialChangeset.php',
'DifferentialChangesetDetailView' => 'applications/differential/view/DifferentialChangesetDetailView.php',
'DifferentialChangesetFileTreeSideNavBuilder' => 'applications/differential/view/DifferentialChangesetFileTreeSideNavBuilder.php',
@@ -2893,6 +2894,7 @@
'DifferentialBlameRevisionField' => 'DifferentialStoredCustomField',
'DifferentialBranchField' => 'DifferentialCustomField',
'DifferentialCapabilityDefaultView' => 'PhabricatorPolicyCapability',
+ 'DifferentialChangesSinceLastUpdateField' => 'DifferentialCustomField',
'DifferentialChangeset' => 'DifferentialDAO',
'DifferentialChangesetDetailView' => 'AphrontView',
'DifferentialChangesetHTMLRenderer' => 'DifferentialChangesetRenderer',
diff --git a/src/applications/differential/config/PhabricatorDifferentialConfigOptions.php b/src/applications/differential/config/PhabricatorDifferentialConfigOptions.php
--- a/src/applications/differential/config/PhabricatorDifferentialConfigOptions.php
+++ b/src/applications/differential/config/PhabricatorDifferentialConfigOptions.php
@@ -37,6 +37,9 @@
new DifferentialJIRAIssuesField(),
new DifferentialAsanaRepresentationField(),
+ new DifferentialChangesSinceLastUpdateField(),
+ new DifferentialBranchField(),
+
new DifferentialBlameRevisionField(),
new DifferentialPathField(),
new DifferentialHostField(),
diff --git a/src/applications/differential/customfield/DifferentialBranchField.php b/src/applications/differential/customfield/DifferentialBranchField.php
--- a/src/applications/differential/customfield/DifferentialBranchField.php
+++ b/src/applications/differential/customfield/DifferentialBranchField.php
@@ -50,5 +50,30 @@
);
}
+ public function shouldAppearInTransactionMail() {
+ return true;
+ }
+
+ public function updateTransactionMailBody(
+ PhabricatorMetaMTAMailBody $body,
+ PhabricatorApplicationTransactionEditor $editor,
+ array $xactions) {
+
+ $status_accepted = ArcanistDifferentialRevisionStatus::ACCEPTED;
+
+ // Show the "BRANCH" section only if there's a new diff or the revision
+ // is "Accepted".
+ if ((!$editor->getDiffUpdateTransaction($xactions)) &&
+ ($this->getObject()->getStatus() != $status_accepted)) {
+ return;
+ }
+
+ $branch = $this->getBranchDescription($this->getObject()->getActiveDiff());
+ if ($branch === null) {
+ return;
+ }
+
+ $body->addTextSection(pht('BRANCH'), $branch);
+ }
}
diff --git a/src/applications/differential/customfield/DifferentialChangesSinceLastUpdateField.php b/src/applications/differential/customfield/DifferentialChangesSinceLastUpdateField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/customfield/DifferentialChangesSinceLastUpdateField.php
@@ -0,0 +1,60 @@
+<?php
+
+final class DifferentialChangesSinceLastUpdateField
+ extends DifferentialCustomField {
+
+ public function getFieldKey() {
+ return 'differential:changes-since-last-update';
+ }
+
+ public function getFieldName() {
+ return pht('Changes Since Last Update');
+ }
+
+ public function getFieldDescription() {
+ return pht('Links to changes since the last update in email.');
+ }
+
+ public function shouldAppearInTransactionMail() {
+ return true;
+ }
+
+ public function updateTransactionMailBody(
+ PhabricatorMetaMTAMailBody $body,
+ PhabricatorApplicationTransactionEditor $editor,
+ array $xactions) {
+
+ if ($editor->getIsNewObject()) {
+ return;
+ }
+
+ if ($editor->getIsCloseByCommit()) {
+ return;
+ }
+
+ $xaction = $editor->getDiffUpdateTransaction($xactions);
+ if (!$xaction) {
+ return;
+ }
+
+ $original = id(new DifferentialDiffQuery())
+ ->setViewer($this->getViewer())
+ ->withPHIDs(array($xaction->getOldValue()))
+ ->executeOne();
+ if (!$original) {
+ return;
+ }
+
+ $revision = $this->getObject();
+ $current = $revision->getActiveDiff();
+
+ $old_id = $original->getID();
+ $new_id = $current->getID();
+
+ $uri = '/'.$revision->getMonogram().'?vs='.$old_id.'&id='.$new_id;
+ $uri = PhabricatorEnv::getProductionURI($uri);
+
+ $body->addTextSection(pht('CHANGES SINCE LAST UPDATE'), $uri);
+ }
+
+}
diff --git a/src/applications/differential/customfield/DifferentialSummaryField.php b/src/applications/differential/customfield/DifferentialSummaryField.php
--- a/src/applications/differential/customfield/DifferentialSummaryField.php
+++ b/src/applications/differential/customfield/DifferentialSummaryField.php
@@ -147,4 +147,25 @@
return true;
}
+ public function shouldAppearInTransactionMail() {
+ return true;
+ }
+
+ public function updateTransactionMailBody(
+ PhabricatorMetaMTAMailBody $body,
+ PhabricatorApplicationTransactionEditor $editor,
+ array $xactions) {
+
+ if (!$editor->getIsNewObject()) {
+ return;
+ }
+
+ $summary = $this->getValue();
+ if (!strlen(trim($summary))) {
+ return;
+ }
+
+ $body->addTextSection(pht('REVISION SUMMARY'), $summary);
+ }
+
}
diff --git a/src/applications/differential/customfield/DifferentialTestPlanField.php b/src/applications/differential/customfield/DifferentialTestPlanField.php
--- a/src/applications/differential/customfield/DifferentialTestPlanField.php
+++ b/src/applications/differential/customfield/DifferentialTestPlanField.php
@@ -177,5 +177,26 @@
}
}
+ public function shouldAppearInTransactionMail() {
+ return true;
+ }
+
+ public function updateTransactionMailBody(
+ PhabricatorMetaMTAMailBody $body,
+ PhabricatorApplicationTransactionEditor $editor,
+ array $xactions) {
+
+ if (!$editor->getIsNewObject()) {
+ return;
+ }
+
+ $test_plan = $this->getValue();
+ if (!strlen(trim($test_plan))) {
+ return;
+ }
+
+ $body->addTextSection(pht('TEST PLAN'), $test_plan);
+ }
+
}
diff --git a/src/applications/differential/editor/DifferentialTransactionEditor.php b/src/applications/differential/editor/DifferentialTransactionEditor.php
--- a/src/applications/differential/editor/DifferentialTransactionEditor.php
+++ b/src/applications/differential/editor/DifferentialTransactionEditor.php
@@ -7,6 +7,18 @@
private $changedPriorToCommitURI;
private $isCloseByCommit;
+ public function getDiffUpdateTransaction(array $xactions) {
+ $type_update = DifferentialTransaction::TYPE_UPDATE;
+
+ foreach ($xactions as $xaction) {
+ if ($xaction->getTransactionType() == $type_update) {
+ return $xaction;
+ }
+ }
+
+ return null;
+ }
+
public function setIsCloseByCommit($is_close_by_commit) {
$this->isCloseByCommit = $is_close_by_commit;
return $this;
@@ -189,6 +201,7 @@
$object->setLineCount($diff->getLineCount());
$object->setRepositoryPHID($diff->getRepositoryPHID());
$object->setArcanistProjectPHID($diff->getArcanistProjectPHID());
+ $object->attachActiveDiff($diff);
// TODO: Update the `diffPHID` once we add that.
return;
@@ -1096,22 +1109,6 @@
$body = parent::buildMailBody($object, $xactions);
- if ($this->getIsNewObject()) {
- $summary = $object->getSummary();
- if (strlen(trim($summary))) {
- $body->addTextSection(
- pht('REVISION SUMMARY'),
- $summary);
- }
-
- $test_plan = $object->getTestPlan();
- if (strlen(trim($test_plan))) {
- $body->addTextSection(
- pht('TEST PLAN'),
- $test_plan);
- }
- }
-
$type_inline = DifferentialTransaction::TYPE_INLINE;
$inlines = array();
diff --git a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
--- a/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
+++ b/src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
@@ -103,7 +103,7 @@
return $this->parentMessageID;
}
- protected function getIsNewObject() {
+ public function getIsNewObject() {
return $this->isNewObject;
}
@@ -1888,6 +1888,21 @@
$body->addRawSection($comment);
}
+ if ($object instanceof PhabricatorCustomFieldInterface) {
+ $field_list = PhabricatorCustomField::getObjectFields(
+ $object,
+ PhabricatorCustomField::ROLE_TRANSACTIONMAIL);
+ $field_list->setViewer($this->getActor());
+ $field_list->readFieldsFromStorage($object);
+
+ foreach ($field_list->getFields() as $field) {
+ $field->updateTransactionMailBody(
+ $body,
+ $this,
+ $xactions);
+ }
+ }
+
return $body;
}
diff --git a/src/infrastructure/customfield/field/PhabricatorCustomField.php b/src/infrastructure/customfield/field/PhabricatorCustomField.php
--- a/src/infrastructure/customfield/field/PhabricatorCustomField.php
+++ b/src/infrastructure/customfield/field/PhabricatorCustomField.php
@@ -11,6 +11,7 @@
* @task list Integration with List views
* @task appsearch Integration with ApplicationSearch
* @task appxaction Integration with ApplicationTransactions
+ * @task xactionmail Integration with Transaction Mail
* @task globalsearch Integration with Global Search
*/
abstract class PhabricatorCustomField {
@@ -20,6 +21,7 @@
private $proxy;
const ROLE_APPLICATIONTRANSACTIONS = 'ApplicationTransactions';
+ const ROLE_TRANSACTIONMAIL = 'ApplicationTransactions.mail';
const ROLE_APPLICATIONSEARCH = 'ApplicationSearch';
const ROLE_STORAGE = 'storage';
const ROLE_DEFAULT = 'default';
@@ -264,6 +266,8 @@
return $this->shouldAppearInGlobalSearch();
case self::ROLE_CONDUIT:
return $this->shouldAppearInConduitDictionary();
+ case self::ROLE_TRANSACTIONMAIL:
+ return $this->shouldAppearInTransactionMail();
case self::ROLE_DEFAULT:
return true;
default:
@@ -1023,6 +1027,33 @@
}
+/* -( Transaction Mail )--------------------------------------------------- */
+
+
+ /**
+ * @task xactionmail
+ */
+ public function shouldAppearInTransactionMail() {
+ if ($this->proxy) {
+ return $this->proxy->shouldAppearInTransactionMail();
+ }
+ return false;
+ }
+
+
+ /**
+ * @task xactionmail
+ */
+ public function updateTransactionMailBody(
+ PhabricatorMetaMTAMailBody $body,
+ PhabricatorApplicationTransactionEditor $editor,
+ array $xactions) {
+ if ($this->proxy) {
+ return $this->proxy->updateTransactionMailBody($body, $editor, $xactions);
+ }
+ return;
+ }
+
/* -( Edit View )---------------------------------------------------------- */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 29, 3:36 PM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7551629
Default Alt Text
D8657.diff (11 KB)
Attached To
Mode
D8657: Restore "Branch" and "changes since last update" fields to Differential mail
Attached
Detach File
Event Timeline
Log In to Comment