/** * * @param int $limit - defaults to the ten lates * @return array() */ protected function getReferences() { $repository = new Gitonomy\Git\Repository($this->project->LocalCVSPath); 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 ($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[$reference->getCommitHash()] = DNTag::create($reference, $this->project, $this->data); } else { $name = $this->reference ? $this->reference->getName() : ''; $builds[$reference->getHash()] = DNCommit::create($reference, $this->project, $this->data, $name); } } return $builds; }
/** * @return array() */ protected function getReferences() { $branches = array(); // Placeholder to put master branch first $firstBranch = null; // return an empty array if the version control isn't checked out yet if (!file_exists($this->project->LocalCVSPath)) { return array(); } $repository = new Gitonomy\Git\Repository($this->project->LocalCVSPath); foreach ($repository->getReferences()->getBranches() as $branch) { $obj = new DNBranch($branch, $this->project, $this->data); if ($branch->getName() == 'master') { $firstBranch = array($branch->getName() => $obj); } else { $branches[$branch->getName()] = $obj; } } if ($firstBranch) { $branches = $firstBranch + $branches; } return $branches; }
/** * @return array */ protected function getReferences() { $branches = array(); // Placeholder to put master branch first $firstBranch = null; try { $repository = new Gitonomy\Git\Repository($this->project->getLocalCVSPath()); } catch (Exception $e) { return $branches; } foreach ($repository->getReferences()->getBranches() as $branch) { /** @var DNBranch $obj */ $obj = DNBranch::create($branch, $this->project, $this->data); if ($branch->getName() == 'master') { $firstBranch = array($branch->getName() => $obj); } else { $branches[$branch->getName()] = $obj; } } if ($firstBranch) { $branches = $firstBranch + $branches; } return $branches; }