@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 a "Create build step" transaction to Harbormaster

Summary:
Without this, build steps that have no options (like "wait for previous commits") don't actually save, since the transaction array is empty.

This also generally nice and consistent.

Test Plan: Created a new "wait" step, viewed transaction log.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

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

+109
+7
src/applications/harbormaster/controller/HarbormasterStepEditController.php
··· 81 81 // if we create plans elsewhere. 82 82 $steps = $plan->loadOrderedBuildSteps(); 83 83 $step->setSequence(count($steps) + 1); 84 + 85 + // When creating a new step, make sure we have a create transaction 86 + // so we'll apply the transactions even if the step has no 87 + // configurable options. 88 + $create_xaction = id(new HarbormasterBuildStepTransaction()) 89 + ->setTransactionType(HarbormasterBuildStepTransaction::TYPE_CREATE); 90 + array_unshift($xactions, $create_xaction); 84 91 } 85 92 86 93 try {
+56
src/applications/harbormaster/editor/HarbormasterBuildStepEditor.php
··· 3 3 final class HarbormasterBuildStepEditor 4 4 extends PhabricatorApplicationTransactionEditor { 5 5 6 + public function getTransactionTypes() { 7 + $types = parent::getTransactionTypes(); 8 + 9 + $types[] = HarbormasterBuildStepTransaction::TYPE_CREATE; 10 + 11 + return $types; 12 + } 13 + 14 + protected function getCustomTransactionOldValue( 15 + PhabricatorLiskDAO $object, 16 + PhabricatorApplicationTransaction $xaction) { 17 + 18 + switch ($xaction->getTransactionType()) { 19 + case HarbormasterBuildStepTransaction::TYPE_CREATE: 20 + return null; 21 + } 22 + 23 + return parent::getCustomTransactionOldValue($object, $xaction); 24 + } 25 + 26 + protected function getCustomTransactionNewValue( 27 + PhabricatorLiskDAO $object, 28 + PhabricatorApplicationTransaction $xaction) { 29 + 30 + switch ($xaction->getTransactionType()) { 31 + case HarbormasterBuildStepTransaction::TYPE_CREATE: 32 + return true; 33 + } 34 + 35 + return parent::getCustomTransactionNewValue($object, $xaction); 36 + } 37 + 38 + protected function applyCustomInternalTransaction( 39 + PhabricatorLiskDAO $object, 40 + PhabricatorApplicationTransaction $xaction) { 41 + 42 + switch ($xaction->getTransactionType()) { 43 + case HarbormasterBuildStepTransaction::TYPE_CREATE: 44 + return; 45 + } 46 + 47 + return parent::applyCustomInternalTransaction($object, $xaction); 48 + } 49 + 50 + protected function applyCustomExternalTransaction( 51 + PhabricatorLiskDAO $object, 52 + PhabricatorApplicationTransaction $xaction) { 53 + 54 + switch ($xaction->getTransactionType()) { 55 + case HarbormasterBuildStepTransaction::TYPE_CREATE: 56 + return; 57 + } 58 + 59 + return parent::applyCustomExternalTransaction($object, $xaction); 60 + } 61 + 6 62 }
+46
src/applications/harbormaster/storage/configuration/HarbormasterBuildStepTransaction.php
··· 3 3 final class HarbormasterBuildStepTransaction 4 4 extends PhabricatorApplicationTransaction { 5 5 6 + const TYPE_CREATE = 'harbormaster:step:create'; 7 + 6 8 public function getApplicationName() { 7 9 return 'harbormaster'; 8 10 } 9 11 10 12 public function getApplicationTransactionType() { 11 13 return HarbormasterPHIDTypeBuildStep::TYPECONST; 14 + } 15 + 16 + public function getTitle() { 17 + $author_phid = $this->getAuthorPHID(); 18 + 19 + $old = $this->getOldValue(); 20 + $new = $this->getNewValue(); 21 + 22 + switch ($this->getTransactionType()) { 23 + case self::TYPE_CREATE: 24 + return pht( 25 + '%s created this build step.', 26 + $this->renderHandleLink($author_phid)); 27 + } 28 + 29 + return parent::getTitle(); 30 + } 31 + 32 + public function getIcon() { 33 + $author_phid = $this->getAuthorPHID(); 34 + 35 + $old = $this->getOldValue(); 36 + $new = $this->getNewValue(); 37 + 38 + switch ($this->getTransactionType()) { 39 + case self::TYPE_CREATE: 40 + return 'create'; 41 + } 42 + 43 + return parent::getIcon(); 44 + } 45 + 46 + public function getColor() { 47 + $author_phid = $this->getAuthorPHID(); 48 + 49 + $old = $this->getOldValue(); 50 + $new = $this->getNewValue(); 51 + 52 + switch ($this->getTransactionType()) { 53 + case self::TYPE_CREATE: 54 + return 'green'; 55 + } 56 + 57 + return parent::getColor(); 12 58 } 13 59 14 60 }