示例#1
0
 /**
  * Pushes a tag to a remote repository.
  *
  * @param null|string|GitRemote $remote the remote repository to push to. If null, falls back to repository $defaultRemote.
  * @return string the response from git
  */
 public function push($remote = null)
 {
     if (is_null($remote)) {
         $remote = $this->repository->remote;
     }
     return $this->repository->run("push {$remote} tag {$this->name}");
 }
示例#2
0
 /**
  * Gets a list of commits in this branch
  * @return GitCommit[] an array of git commits, indexed by hash
  */
 public function getCommits()
 {
     if (is_null($this->_commits)) {
         $this->_commits = array();
         $branchName = $this->remote ? $this->remote->name . '/' . $this->name : $this->name;
         $command = 'log --pretty=format:"%H" ' . $branchName;
         foreach (explode("\n", $this->repository->run($command)) as $hash) {
             $hash = trim($hash);
             if (!$hash) {
                 continue;
             }
             $this->_commits[$hash] = new GitCommit($hash, $this->repository);
         }
     }
     return $this->_commits;
 }
示例#3
0
 /**
  * Loads the metadata for the commit
  */
 protected function loadData()
 {
     $delimiter = '|||---|||---|||';
     $command = 'show --pretty=format:"%an' . $delimiter . '%ae' . $delimiter . '%cd' . $delimiter . '%s' . $delimiter . '%B' . $delimiter . '%N" ' . $this->hash;
     $response = $this->repository->run($command);
     $parts = explode($delimiter, $response);
     $this->_authorName = array_shift($parts);
     $this->_authorEmail = array_shift($parts);
     $this->_time = array_shift($parts);
     $this->_subject = array_shift($parts);
     $this->_message = array_shift($parts);
     $this->_notes = array_shift($parts);
 }
示例#4
0
 /**
  * Gets a list of tags for this remote repository
  *
  * @return GitTag[] an array of tags
  */
 public function getTags()
 {
     $tags = array();
     foreach (explode("\n", $this->repository->run('ls-remote --tags ' . $this->name)) as $i => $ref) {
         if ($i == 0) {
             continue;
         }
         //ignore first line "From: repository..."
         if (substr_count($ref, '^{}')) {
             continue;
         }
         //ignore dereferenced tag objects for annotated tags
         $ref = explode('refs/tags/', trim($ref), 2);
         $tagName = $ref[1];
         $tag = new GitTag($tagName, $this->repository, $this);
         $tags[$tagName] = $tag;
     }
     return $tags;
 }