/**
  * get tag commit command via rev-list
  *
  * @param \GitElephant\Objects\Tag $tag a tag instance
  *
  * @throws \RuntimeException
  * @return string
  */
 public function getTagCommit(Tag $tag)
 {
     $this->clearAll();
     $this->addCommandName(static::GIT_REVLIST);
     // only the last commit
     $this->addCommandArgument('-n1');
     $this->addCommandSubject($tag->getFullRef());
     return $this->getCommand();
 }
Exemple #2
0
 /**
  * testCreate
  */
 public function testCreate()
 {
     $this->getRepository()->init();
     $this->addFile('test');
     $this->repository->commit('test', true);
     $this->assertCount(0, $this->repository->getTags());
     Tag::create($this->repository, 'test-tag');
     $this->assertCount(1, $this->repository->getTags());
     Tag::create($this->repository, 'test-tag2', 'test-tag');
     $this->assertCount(2, $this->repository->getTags());
 }
Exemple #3
0
 /**
  * Delete a tag
  *
  * @param string|Tag $tag The name of tag, or the Tag instance to delete
  *
  * @throws \RuntimeException
  * @return string the command
  */
 public function delete($tag)
 {
     $this->clearAll();
     $name = $tag;
     if ($tag instanceof Tag) {
         $name = $tag->getName();
     }
     $this->addCommandName(self::TAG_COMMAND);
     $this->addCommandArgument('-d');
     $this->addCommandSubject($name);
     return $this->getCommand();
 }
Exemple #4
0
 /**
  * Return the last created tag
  *
  * @throws \LogicException
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  * @return Tag|null
  */
 public function getLastTag()
 {
     $finder = Finder::create()->files()->in(sprintf('%s/.git/refs/tags', $this->path))->sortByChangedTime();
     if ($finder->count() == 0) {
         return null;
     }
     $files = iterator_to_array($finder->getIterator(), false);
     $files = array_reverse($files);
     /** @var $firstFile SplFileInfo */
     $firstFile = $files[0];
     $tagName = $firstFile->getFilename();
     return Tag::pick($this, $tagName);
 }