/**
  * set up
  */
 public function testRootDiff()
 {
     $dtc = DiffTreeCommand::getInstance();
     $commit = $this->getRepository()->getCommit();
     $command = $dtc->rootDiff($commit);
     $this->assertEquals(sprintf("diff-tree '--cc' '--root' '--dst-prefix=DST/' '--src-prefix=SRC/' '%s'", $commit), $command);
     $this->addFile('test');
     $this->getRepository()->commit('test commit', true);
     $this->setExpectedException('InvalidArgumentException');
     $this->fail($dtc->rootDiff($this->getRepository()->getCommit()));
 }
Example #2
0
 /**
  * get the commit properties from command
  *
  * @param null $commit1 commit 1
  * @param null $commit2 commit 2
  * @param null $path    path
  *
  * @throws \RuntimeException
  * @throws \Symfony\Component\Process\Exception\InvalidArgumentException
  * @throws \Symfony\Component\Process\Exception\LogicException
  * @throws \InvalidArgumentException
  * @throws \Symfony\Component\Process\Exception\RuntimeException
  * @see ShowCommand::commitInfo
  */
 public function createFromCommand($commit1 = null, $commit2 = null, $path = null)
 {
     if (null === $commit1) {
         $commit1 = $this->getRepository()->getCommit();
     }
     if (is_string($commit1)) {
         $commit1 = $this->getRepository()->getCommit($commit1);
     }
     if ($commit2 === null) {
         if ($commit1->isRoot()) {
             $command = DiffTreeCommand::getInstance($this->repository)->rootDiff($commit1);
         } else {
             $command = DiffCommand::getInstance($this->repository)->diff($commit1);
         }
     } else {
         if (is_string($commit2)) {
             $commit2 = $this->getRepository()->getCommit($commit2);
         }
         $command = DiffCommand::getInstance($this->repository)->diff($commit1, $commit2, $path);
     }
     $outputLines = $this->getCaller()->execute($command)->getOutputLines();
     $this->parseOutputLines($outputLines);
 }