config = $config; $this->logger = $logger; $this->system = $system; } /** * Initialize a new repository * * @return bool */ public function init(): bool { if (!$this->isGitRepository()) { $this->system->exec('git init'); } return $this->isGitRepository(); } /** * Get the current branch name * * @return string */ public function getCurrentBranchName(): string { if (!$this->isGitRepository()) { return $this->config->get('output.docname'); } return $this->system->exec('git branch | grep \\\* | cut -d \' \' -f2', SystemService::MODE_LASTLINE); } /** * Check if repository is initialized * * @return bool */ public function isGitRepository(): bool { return is_dir(PROJECT_ROOT.'/.git') && file_exists(PROJECT_ROOT.'/.git/HEAD'); } }