[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class ReleephBranchEditor extends PhabricatorEditor { 4 5 private $releephProject; 6 private $releephBranch; 7 8 public function setReleephProject(ReleephProject $rp) { 9 $this->releephProject = $rp; 10 return $this; 11 } 12 13 public function setReleephBranch(ReleephBranch $branch) { 14 $this->releephBranch = $branch; 15 return $this; 16 } 17 18 public function newBranchFromCommit(PhabricatorRepositoryCommit $cut_point, 19 $branch_date, 20 $symbolic_name = null) { 21 22 $template = $this->releephProject->getDetail('branchTemplate'); 23 if (!$template) { 24 $template = ReleephBranchTemplate::getRequiredDefaultTemplate(); 25 } 26 27 $cut_point_handle = id(new PhabricatorHandleQuery()) 28 ->setViewer($this->requireActor()) 29 ->withPHIDs(array($cut_point->getPHID())) 30 ->executeOne(); 31 32 list($name, $errors) = id(new ReleephBranchTemplate()) 33 ->setCommitHandle($cut_point_handle) 34 ->setBranchDate($branch_date) 35 ->setReleephProjectName($this->releephProject->getName()) 36 ->interpolate($template); 37 38 $basename = last(explode('/', $name)); 39 40 $table = id(new ReleephBranch()); 41 $transaction = $table->openTransaction(); 42 $branch = id(new ReleephBranch()) 43 ->setName($name) 44 ->setBasename($basename) 45 ->setReleephProjectID($this->releephProject->getID()) 46 ->setCreatedByUserPHID($this->requireActor()->getPHID()) 47 ->setCutPointCommitPHID($cut_point->getPHID()) 48 ->setIsActive(1) 49 ->setDetail('branchDate', $branch_date) 50 ->save(); 51 52 /** 53 * Steal the symbolic name from any other branch that has it (in this 54 * project). 55 */ 56 if ($symbolic_name) { 57 $others = id(new ReleephBranch())->loadAllWhere( 58 'releephProjectID = %d', 59 $this->releephProject->getID()); 60 foreach ($others as $other) { 61 if ($other->getSymbolicName() == $symbolic_name) { 62 $other 63 ->setSymbolicName(null) 64 ->save(); 65 } 66 } 67 $branch 68 ->setSymbolicName($symbolic_name) 69 ->save(); 70 } 71 72 $table->saveTransaction(); 73 return $branch; 74 } 75 76 // aka "close" and "reopen" 77 public function changeBranchAccess($is_active) { 78 $branch = $this->releephBranch; 79 80 $branch 81 ->setIsActive((int)$is_active) 82 ->save(); 83 } 84 85 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |