/** * Creates a new repository on the specified path * * @param string $path Path where the new repository will be created * @return Repository Instance of Repository */ public function createRepository($path, $bare = null) { if (file_exists($path . '/.git/HEAD') && !file_exists($path . '/HEAD')) { throw new \RuntimeException('A GIT repository already exists at ' . $path); } $repository = new Repository($path, $this); return $repository->create($bare); }
/** * Constructor * * @param string $path * @param Client $client Git client * @param StatisticsFormatter $statisticsFormatter * @return \GitPrettyStats\Repository */ public function __construct($path, Client $client = null, StatisticsFormatter $statisticsFormatter = null) { $this->statisticsFormatter = $statisticsFormatter ?: new StatisticsFormatter($this); $emailAliases = Config::get('git-pretty-stats.emailAliases'); $this->emailAliases = $emailAliases && is_array($emailAliases) ? $emailAliases : null; $client = $client ? $client : new Client(); parent::__construct($path, $client); }
/** * Get the current branch, returning a default value when HEAD is detached. */ public function getHead($default = null) { $client = $this->getClient(); return parent::getHead($client->getDefaultBranch()); }
protected function findTag(Repository $repository, $tag) { $tags = (array) $repository->getTags(); $tagExpression = new SemanticExpression($tag); return $this->getMappedVersionTag($tags, $tagExpression->maxSatisfying($tags)); }