Example #1
0
 /**
  * Gets a list of commits in this branch
  * @return AGitCommit[] 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 AGitCommit($hash, $this->repository);
         }
     }
     return $this->_commits;
 }
Example #2
0
 /**
  * Pushes a tag to a remote repository.
  * @param null|string|AGitRemote $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}");
 }
Example #3
0
 /**
  * Gets the repository to use for testing
  * @return AGitRepository the respository for testing
  */
 protected function getRepository()
 {
     if ($this->_repository === null) {
         $this->_repository = new AGitRepository();
         $this->_repository->setPath($this->path, true, true);
         $this->assertTrue(file_exists($this->path));
     }
     return $this->_repository;
 }
Example #4
0
 /**
  * Gets a list of tags for this remote repository
  * @return AGitTag[] 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 AGitTag($tagName, $this->repository, $this);
         $tags[$tagName] = $tag;
     }
     return $tags;
 }
Example #5
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);
 }