Example #1
0
 protected function mergeUp(Node $node, $mergeName = '', $pushedObjects = array())
 {
     // If it's a leaf, we do nothing!
     if ($node->isLeaf()) {
         return $pushedObjects;
     }
     // For the root node, we skip it, as it's a placeholder
     if ($node->getValue() == $this->config->getRootName()) {
         foreach ($node->getChildren() as $child) {
             $pushedObjects = $this->mergeUp($child, '', $pushedObjects);
         }
         return $pushedObjects;
     }
     // If it's any node with children, we merge self into those branches
     foreach ($node->getChildren() as $child) {
         // Get and prepare the from/to branches based on the node values
         $from = $this->bm->getBranchObjectByName($node->getValue());
         if (!empty($mergeName)) {
             $from->setMergeName($mergeName);
         }
         $to = $this->bm->getBranchObjectByName($child->getValue());
         if ($this->options['interactive']) {
             $this->dialog->askConfirmation($this->getOutput(), "Merge from {$from} to {$to}: ", FALSE);
         }
         $branchMerge = new BranchMerge($from, $to);
         $pushedObjectArr = $this->git->merge($branchMerge);
         // We want to merge the local branch into it's children, since the pull request will
         //    not have been merged immediately
         $child->setValue((string) $pushedObjectArr['remoteBranch']);
         if ($this->options['pull-request'] && !empty($pushedObjectArr['pullRequest'])) {
             if ($this->options['interactive']) {
                 $this->dialog->askConfirmation($this->getOutput(), "Submit pull request for {$pushedObjectArr['pullRequest']}: ", FALSE);
             }
             $this->git->submitPullRequest($pushedObjectArr['pullRequest']);
         }
         $pushedObjects[] = $pushedObjectArr;
         $pushedObjects = $this->mergeUp($child, $pushedObjectArr['remoteBranch']->getMergeName(), $pushedObjects);
     }
     return $pushedObjects;
 }
Example #2
0
 public function testIsLeaf()
 {
     $root = new Node();
     $this->assertTrue($root->isLeaf());
     $root->addChild(new Node('child'));
     $this->assertFalse($root->isLeaf());
 }