/** * Build an object log command * * @param \GitElephant\Objects\Object $obj the Object to get the log for * @param \GitElephant\Objects\Branch|string|null $branch the branch to consider * @param int|null $limit limit to n entries * @param int|null $offset skip n entries * * @throws \RuntimeException * @return string */ public function showObjectLog(Object $obj, $branch = null, $limit = null, $offset = null) { $subject = null; if (null !== $branch) { if ($branch instanceof Branch) { $subject .= $branch->getName(); } else { $subject .= (string) $branch; } } return $this->showLog($subject, $obj->getFullPath(), $limit, $offset); }
/** * test constructor */ public function testConstructor() { $this->getRepository()->init(); $this->addFile('test'); $this->getRepository()->commit('test commit', true); $b = new Branch($this->getRepository(), 'master'); $this->assertEquals('master', $b->getName()); $this->assertEquals('test commit', $b->getComment()); $this->assertTrue($b->getCurrent()); $this->getRepository()->createBranch('develop'); $b = new Branch($this->getRepository(), 'develop'); $this->assertEquals('develop', $b->getName()); $this->assertEquals('test commit', $b->getComment()); $this->assertFalse($b->getCurrent()); $this->setExpectedException('GitElephant\\Exception\\InvalidBranchNameException'); $this->fail(Branch::checkout($this->getRepository(), 'non-existent')); }
/** * Checkout a treeish reference * * @param string|Branch $ref the reference to checkout * * @throws \RuntimeException * @return string */ public function checkout($ref) { $this->clearAll(); $what = $ref; if ($ref instanceof Branch) { $what = $ref->getName(); } elseif ($ref instanceof TreeishInterface) { $what = $ref->getSha(); } $this->addCommandName(self::GIT_CHECKOUT); $this->addCommandArgument('-q'); $this->addCommandSubject($what); return $this->getCommand(); }