コード例 #1
0
ファイル: CallerTest.php プロジェクト: ocubom/GitElephant
 /**
  * get output test
  */
 public function testGetOutput()
 {
     $binary = new GitBinary();
     $caller = new Caller($binary, $this->getRepository()->getPath());
     $mainCommand = new MainCommand();
     $caller->execute($mainCommand->init());
     $this->assertRegExp(sprintf('/^(.*)%s/', str_replace('/', '\\/', $this->getRepository()->getPath())), $caller->getOutput());
 }
コード例 #2
0
ファイル: CommitTest.php プロジェクト: ocubom/GitElephant
 /**
  * commit tests
  */
 public function testCommit()
 {
     $showCommand = new ShowCommand();
     $this->commit = Commit::pick($this->getRepository());
     $this->assertInstanceOf('\\GitElephant\\Objects\\Commit', $this->commit);
     $this->assertInstanceOf('\\GitElephant\\Objects\\Author', $this->commit->getAuthor());
     $this->assertInstanceOf('\\GitElephant\\Objects\\Author', $this->commit->getCommitter());
     $this->assertInstanceOf('\\Datetime', $this->commit->getDatetimeAuthor());
     $this->assertInstanceOf('\\Datetime', $this->commit->getDatetimeCommitter());
     $this->assertInstanceOf('\\GitElephant\\Objects\\Commit\\Message', $this->commit->getMessage());
     $this->assertEquals('first commit', $this->commit->getMessage()->toString());
     $this->assertRegExp('/^\\w{40}$/', $this->commit->getSha());
     $this->assertEquals(array(), $this->commit->getParents());
     $this->addFile('foo2');
     $mainCommand = new MainCommand();
     $this->getCaller()->execute($mainCommand->add());
     $this->getCaller()->execute($mainCommand->commit('second commit'));
     $this->getCaller()->execute($showCommand->showCommit('HEAD'));
     $this->commit = Commit::pick($this->getRepository());
     $parents = $this->commit->getParents();
     $this->assertRegExp('/^\\w{40}$/', $parents[0]);
 }
コード例 #3
0
ファイル: Commit.php プロジェクト: mlukman/gitsync
 /**
  * factory method to create a commit
  *
  * @param Repository    $repository repository instance
  * @param string        $message    commit message
  * @param bool          $stageAll   automatically stage the dirty working tree. Alternatively call stage() on the repo
  * @param string|Author $author     override the author for this commit
  *
  * @throws \RuntimeException
  * @throws \Symfony\Component\Process\Exception\LogicException
  * @throws \InvalidArgumentException
  * @throws \Symfony\Component\Process\Exception\InvalidArgumentException
  * @throws \Symfony\Component\Process\Exception\RuntimeException
  * @return Commit
  */
 public static function create(Repository $repository, $message, $stageAll = false, $author = null)
 {
     $repository->getCaller()->execute(MainCommand::getInstance($repository)->commit($message, $stageAll, $author));
     return $repository->getCommit();
 }
コード例 #4
0
ファイル: Repository.php プロジェクト: mlukman/gitsync
 /**
  * Checkout a branch
  * This function change the state of the repository on the filesystem
  *
  * @param string|TreeishInterface $ref    the reference to checkout
  * @param bool                    $create like -b on the command line
  *
  * @throws \RuntimeException
  * @throws \Symfony\Component\Process\Exception\LogicException
  * @throws \Symfony\Component\Process\Exception\InvalidArgumentException
  * @throws \Symfony\Component\Process\Exception\RuntimeException
  * @return Repository
  */
 public function checkout($ref, $create = false)
 {
     if ($create && is_null($this->getBranch($ref))) {
         $this->createBranch($ref);
     }
     $this->caller->execute(MainCommand::getInstance($this)->checkout($ref));
     return $this;
 }
コード例 #5
0
ファイル: Status.php プロジェクト: ocubom/GitElephant
 /**
  * create from git command
  */
 private function createFromCommand()
 {
     $command = MainCommand::getInstance($this->repository)->status(true);
     $lines = $this->repository->getCaller()->execute($command)->getOutputLines(true);
     $this->parseOutputLines($lines);
 }
コード例 #6
0
ファイル: Repository.php プロジェクト: ocubom/GitElephant
 /**
  * Checkout a branch
  * This function change the state of the repository on the filesystem
  *
  * @param string|TreeishInterface $ref the reference to checkout
  *
  * @throws \RuntimeException
  * @throws \Symfony\Component\Process\Exception\LogicException
  * @throws \Symfony\Component\Process\Exception\InvalidArgumentException
  * @throws \Symfony\Component\Process\Exception\RuntimeException
  * @return Repository
  */
 public function checkout($ref)
 {
     $this->caller->execute(MainCommand::getInstance($this)->checkout($ref));
     return $this;
 }