/** * @return array */ protected function getReferences() { try { $repository = new Gitonomy\Git\Repository($this->project->getLocalCVSPath()); } catch (Exception $e) { return array(); } if ($this->getTags) { if ($this->reference) { throw new LogicException("Can't have \$reference and \$getTags both set"); } $log = $repository->getReferences()->getTags(); } else { if ($this->reference) { $log = $this->reference->getLog(); } else { $log = $repository->getLog(); } } if ($this->limit) { if (is_array($log)) { $limitedLog = array_slice($log, 0, $this->limit); } else { $limitedLog = $log->setLimit($this->limit); } } else { $limitedLog = $log; } // cache them for look up in byName $builds = array(); foreach ($limitedLog as $reference) { if (!empty($this->blockBranch)) { $branchesIncluding = GitonomyCache::getIncludingBranches($reference); foreach ($branchesIncluding as $candidate) { if ($candidate->getName() == $this->blockBranch) { // Break out of the function return $builds; } } } if ($this->getTags) { $builds[] = DNTag::create($reference, $this->project, $this->data); } else { $name = $this->reference ? $this->reference->getName() : ''; $builds[] = DNCommit::create($reference, $this->project, $this->data, $name); } } return $builds; }
/** * @inheritdoc */ public function generateReferenceUrl(Reference $reference) { if ($reference instanceof Branch) { return $this->generator->generate($this->routeNames['branch'], array($this->routeArgs['branch_repository'] => $this->getName($reference->getRepository()), $this->routeArgs['branch_name'] => $reference->getName())); } if ($reference instanceof Tag) { return $this->generator->generate($this->routeNames['tag'], array($this->routeArgs['tag_repository'] => $this->getName($reference->getRepository()), $this->routeArgs['tag_name'] => $reference->getName())); } throw new \InvalidArgumentException(sprintf('Expected a Branch, got a "%s".', is_object($reference) ? get_class($reference) : gettype($reference))); }
public function generateReferenceUrl(Reference $reference) { return $this->generator->generate('reference', array('fullname' => $reference->getFullname(), 'repository' => $this->getName($reference->getRepository()))); }
public function update(Reference $reference) { $fullname = $reference->getFullname(); $this->initialize(); $this->repository->run('update-ref', array($fullname, $reference->getCommitHash())); $this->references[$fullname] = $reference; return $reference; }
public static function create(Project $project, Reference $reference, User $user) { return new self(array('project_id' => $project->getId(), 'user_id' => $user->getId(), 'ref' => $reference->getFullname())); }