Page MenuHomePhabricator

D8501.diff
No OneTemporary

D8501.diff

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
@@ -1281,6 +1281,8 @@
'PhabricatorChatLogEvent' => 'applications/chatlog/storage/PhabricatorChatLogEvent.php',
'PhabricatorChatLogEventType' => 'applications/chatlog/constants/PhabricatorChatLogEventType.php',
'PhabricatorChatLogQuery' => 'applications/chatlog/PhabricatorChatLogQuery.php',
+ 'PhabricatorCommitBranchesField' => 'applications/repository/customfield/PhabricatorCommitBranchesField.php',
+ 'PhabricatorCommitCustomField' => 'applications/repository/customfield/PhabricatorCommitCustomField.php',
'PhabricatorCommonPasswords' => 'applications/auth/constants/PhabricatorCommonPasswords.php',
'PhabricatorConduitAPIController' => 'applications/conduit/controller/PhabricatorConduitAPIController.php',
'PhabricatorConduitCertificateToken' => 'applications/conduit/storage/PhabricatorConduitCertificateToken.php',
@@ -3958,6 +3960,8 @@
),
'PhabricatorChatLogEventType' => 'PhabricatorChatLogConstants',
'PhabricatorChatLogQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'PhabricatorCommitBranchesField' => 'PhabricatorCommitCustomField',
+ 'PhabricatorCommitCustomField' => 'PhabricatorCustomField',
'PhabricatorCommonPasswords' => 'Phobject',
'PhabricatorConduitAPIController' => 'PhabricatorConduitController',
'PhabricatorConduitCertificateToken' => 'PhabricatorConduitDAO',
@@ -4668,6 +4672,7 @@
2 => 'PhabricatorFlaggableInterface',
3 => 'PhabricatorTokenReceiverInterface',
4 => 'HarbormasterBuildableInterface',
+ 5 => 'PhabricatorCustomFieldInterface',
),
'PhabricatorRepositoryCommitChangeParserWorker' => 'PhabricatorRepositoryCommitParserWorker',
'PhabricatorRepositoryCommitData' => 'PhabricatorRepositoryDAO',
diff --git a/src/applications/repository/customfield/PhabricatorCommitBranchesField.php b/src/applications/repository/customfield/PhabricatorCommitBranchesField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/repository/customfield/PhabricatorCommitBranchesField.php
@@ -0,0 +1,37 @@
+<?php
+
+final class PhabricatorCommitBranchesField
+ extends PhabricatorCommitCustomField {
+
+ public function getFieldKey() {
+ return 'diffusion:branches';
+ }
+
+ public function shouldAppearInApplicationTransactions() {
+ return true;
+ }
+
+ public function buildApplicationTransactionMailBody(
+ PhabricatorApplicationTransaction $xaction,
+ PhabricatorMetaMTAMailBody $body) {
+
+ $params = array(
+ 'contains' => $this->getObject()->getCommitIdentifier(),
+ 'callsign' => $this->getObject()->getRepository()->getCallsign(),
+ );
+
+ $branches_raw = id(new ConduitCall('diffusion.branchquery', $params))
+ ->setUser($this->getViewer())
+ ->execute();
+
+ $branches = DiffusionRepositoryRef::loadAllFromDictionaries($branches_raw);
+ if (!$branches) {
+ return;
+ }
+ $branch_names = mpull($branches, 'getShortName');
+ sort($branch_names);
+
+ $body->addTextSection(pht('BRANCHES'), implode(', ', $branch_names));
+ }
+
+}
diff --git a/src/applications/repository/customfield/PhabricatorCommitCustomField.php b/src/applications/repository/customfield/PhabricatorCommitCustomField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/repository/customfield/PhabricatorCommitCustomField.php
@@ -0,0 +1,7 @@
+<?php
+
+abstract class PhabricatorCommitCustomField
+ extends PhabricatorCustomField {
+
+
+}
diff --git a/src/applications/repository/storage/PhabricatorRepositoryCommit.php b/src/applications/repository/storage/PhabricatorRepositoryCommit.php
--- a/src/applications/repository/storage/PhabricatorRepositoryCommit.php
+++ b/src/applications/repository/storage/PhabricatorRepositoryCommit.php
@@ -6,7 +6,8 @@
PhabricatorPolicyInterface,
PhabricatorFlaggableInterface,
PhabricatorTokenReceiverInterface,
- HarbormasterBuildableInterface {
+ HarbormasterBuildableInterface,
+ PhabricatorCustomFieldInterface {
protected $repositoryID;
protected $phid;
@@ -29,6 +30,7 @@
private $commitData = self::ATTACHABLE;
private $audits;
private $repository = self::ATTACHABLE;
+ private $customFields = self::ATTACHABLE;
public function attachRepository(PhabricatorRepository $repository) {
$this->repository = $repository;
@@ -247,4 +249,27 @@
return $this->getRepository()->getPHID();
}
+
+/* -( PhabricatorCustomFieldInterface )------------------------------------ */
+
+
+ public function getCustomFieldSpecificationForRole($role) {
+ // TODO: We could make this configurable eventually, but just use the
+ // defaults for now.
+ return array();
+ }
+
+ public function getCustomFieldBaseClass() {
+ return 'PhabricatorCommitCustomField';
+ }
+
+ public function getCustomFields() {
+ return $this->assertAttached($this->customFields);
+ }
+
+ public function attachCustomFields(PhabricatorCustomFieldAttachment $fields) {
+ $this->customFields = $fields;
+ return $this;
+ }
+
}
diff --git a/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php b/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php
--- a/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php
+++ b/src/applications/repository/worker/PhabricatorRepositoryCommitHeraldWorker.php
@@ -24,6 +24,8 @@
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit) {
+ $commit->attachRepository($repository);
+
// Don't take any actions on an importing repository. Principally, this
// avoids generating thousands of audits or emails when you import an
// established repository on an existing install.
@@ -155,6 +157,21 @@
$body = new PhabricatorMetaMTAMailBody();
$body->addRawSection($description);
$body->addTextSection(pht('DETAILS'), $commit_uri);
+
+ // TODO: This should be integrated properly once we move to
+ // ApplicationTransactions.
+ $field_list = PhabricatorCustomField::getObjectFields(
+ $commit,
+ PhabricatorCustomField::ROLE_APPLICATIONTRANSACTIONS);
+ $field_list
+ ->setViewer(PhabricatorUser::getOmnipotentUser())
+ ->readFieldsFromStorage($commit);
+ foreach ($field_list->getFields() as $field) {
+ $field->buildApplicationTransactionMailBody(
+ new DifferentialTransaction(), // Bogus object to satisfy typehint.
+ $body);
+ }
+
$body->addTextSection(pht('DIFFERENTIAL REVISION'), $differential);
$body->addTextSection(pht('AFFECTED FILES'), $files);
$body->addReplySection($reply_handler->getReplyHandlerInstructions());
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
@@ -1002,6 +1002,23 @@
return false;
}
+ /**
+ * TODO: this is only used by Diffusion right now and everything is completely
+ * faked since Diffusion doesn't use ApplicationTransactions yet. This should
+ * get fleshed out as we have more use cases.
+ *
+ * @task appxaction
+ */
+ public function buildApplicationTransactionMailBody(
+ PhabricatorApplicationTransaction $xaction,
+ PhabricatorMetaMTAMailBody $body) {
+ if ($this->proxy) {
+ return $this->proxy->buildApplicationTransactionMailBody($xaction, $body);
+ }
+ return;
+ }
+
+
/* -( Edit View )---------------------------------------------------------- */
@@ -1194,5 +1211,4 @@
throw new PhabricatorCustomFieldImplementationIncompleteException($this);
}
-
}

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 29, 2:37 PM (9 h, 28 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6942512
Default Alt Text
D8501.diff (7 KB)

Event Timeline