3 final class ReleephBranchEditor
extends PhabricatorEditor
{
5 private $releephProject;
6 private $releephBranch;
8 public function setReleephProject(ReleephProject
$rp) {
9 $this->releephProject
= $rp;
13 public function setReleephBranch(ReleephBranch
$branch) {
14 $this->releephBranch
= $branch;
18 public function newBranchFromCommit(
19 PhabricatorRepositoryCommit
$cut_point,
21 $symbolic_name = null) {
23 $template = $this->releephProject
->getDetail('branchTemplate');
25 $template = ReleephBranchTemplate
::getRequiredDefaultTemplate();
28 $cut_point_handle = id(new PhabricatorHandleQuery())
29 ->setViewer($this->requireActor())
30 ->withPHIDs(array($cut_point->getPHID()))
33 list($name, $errors) = id(new ReleephBranchTemplate())
34 ->setCommitHandle($cut_point_handle)
35 ->setBranchDate($branch_date)
36 ->setReleephProjectName($this->releephProject
->getName())
37 ->interpolate($template);
39 $basename = last(explode('/', $name));
41 $table = id(new ReleephBranch());
42 $transaction = $table->openTransaction();
43 $branch = id(new ReleephBranch())
45 ->setBasename($basename)
46 ->setReleephProjectID($this->releephProject
->getID())
47 ->setCreatedByUserPHID($this->requireActor()->getPHID())
48 ->setCutPointCommitPHID($cut_point->getPHID())
50 ->setDetail('branchDate', $branch_date)
54 * Steal the symbolic name from any other branch that has it (in this
58 $others = id(new ReleephBranch())->loadAllWhere(
59 'releephProjectID = %d',
60 $this->releephProject
->getID());
61 foreach ($others as $other) {
62 if ($other->getSymbolicName() == $symbolic_name) {
64 ->setSymbolicName(null)
69 ->setSymbolicName($symbolic_name)
73 $table->saveTransaction();
77 // aka "close" and "reopen"
78 public function changeBranchAccess($is_active) {
79 $branch = $this->releephBranch
;
82 ->setIsActive((int)$is_active)