protected function exportGitBranches(Git_RemoteServer_GerritServer $gerrit_server, $gerrit_project, GitRepository $repository) { $gerrit_project_url = $gerrit_server->getCloneSSHUrl($gerrit_project); $executor = new Git_Exec($repository->getFullPath(), $repository->getFullPath()); $executor->exportBranchesAndTags($gerrit_project_url); }
/** * Backup gitolite repository * * @param String $path The repository path * @param String $backup_directory The repository backup directory path * @param String $repositoryName * */ public function backup(GitRepository $repository, $backup_directory) { if (!is_readable($repository->getFullPath())) { throw new GitDriverErrorException('Gitolite backup: Empty path or permission denied ' . $repository->getFullPath()); } if (!is_writable($backup_directory)) { throw new GitDriverErrorException('Gitolite backup: Empty backup path or permission denied ' . $backup_directory); } $backup_path = $this->getBackupPath($repository, $backup_directory); $target_directory = dirname($backup_path); if (!is_dir($target_directory)) { if (!mkdir($target_directory, 0700, true)) { throw new GitDriverErrorException('Unable to create git backup directory: ' . $target_directory); } } try { $exec = new System_Command(); $command = 'tar cvzf ' . escapeshellarg($backup_path) . ' ' . escapeshellarg($repository->getFullPath()); $exec->exec($command); $command = 'chmod 644 ' . escapeshellarg($backup_path); $exec->exec($command); $this->logger->info('[Gitolite][Backup] Repository backup done in [' . $backup_path . ']'); } catch (System_Command_CommandException $exception) { $this->logger->error('[Gitolite][Backup] Error when backuping repository in [' . $backup_path . '] error message : ' . $exception->getMessage()); throw new GitDriverErrorException($exception->getMessage()); } }