public function itAsksToDeleteTheRepositoryFromAllManifests()
 {
     expect($this->generator)->removeRepositoryFromManifestFile('*', $this->repository->getPath())->count(2);
     expect($this->generator)->removeRepositoryFromManifestFile($this->singapour_mirror, $this->repository->getPath())->at(0);
     expect($this->generator)->removeRepositoryFromManifestFile($this->noida_mirror, $this->repository->getPath())->at(1);
     $this->manager->triggerDelete($this->repository->getPath());
 }
示例#2
0
 private function getView()
 {
     if (empty($_REQUEST['a'])) {
         $_REQUEST['a'] = 'summary';
     } else {
         if ($_REQUEST['a'] === 'blobdiff' && isset($_REQUEST['jenkins']) && $_REQUEST['jenkins'] === 'true') {
             $this->inverseURLArgumentsForGitPhpDiff();
         }
     }
     set_time_limit(300);
     $_GET['a'] = $_REQUEST['a'];
     $_REQUEST['group_id'] = $this->repository->getProjectId();
     $_REQUEST['repo_id'] = $this->repository->getId();
     $_REQUEST['repo_name'] = $this->repository->getFullName();
     $_GET['p'] = $_REQUEST['repo_name'] . '.git';
     $_REQUEST['repo_path'] = $this->repository->getPath();
     $_REQUEST['project_dir'] = $this->repository->getProject()->getUnixName();
     $_REQUEST['git_root_path'] = $this->repository->getGitRootPath();
     $_REQUEST['action'] = 'view';
     $this->preSanitizeRequestForGitphp();
     if (empty($_REQUEST['noheader'])) {
         echo '<div id="gitphp" class="plugin_git_gitphp">';
     }
     include $this->getGitPhpIndexPath();
     if (empty($_REQUEST['noheader'])) {
         echo '</div>';
     }
 }
 public function doValidate($validator, $values)
 {
     try {
         $git = new GitRepository(sprintf('git://github.com/%s/%s.git', $values['user'], $values['repository']), sfConfig::get('app_git_storage_path'), sfConfig::get('app_git_command'));
         $git->fetch();
         $this->gitRepositoryPath = $git->getPath();
     } catch (GitRepositoryException $e) {
         throw new sfValidatorError($validator, 'Problems pulling/updating the repository.');
     }
     return $values;
 }
示例#4
0
 private function getMarkdownFilesDiv()
 {
     $commit_sha1 = $this->getCurrentCommitSha1();
     $node = $this->getCurrentNode();
     $repository_path = ForgeConfig::get('sys_data_dir') . '/gitolite/repositories/' . $this->repository->getPath();
     $git_markdown_file = new GitMarkdownFile(new Git_Exec($repository_path, $repository_path));
     $readme_file = $git_markdown_file->getReadmeFileContent($node, $commit_sha1);
     if ($readme_file) {
         $presenter = new ReadmeMarkdownPresenter($readme_file['file_name'], $readme_file['file_content']);
         $renderer = TemplateRendererFactory::build()->getRenderer(dirname(GIT_BASE_DIR) . '/templates');
         return $renderer->renderToString('readme_markdown', $presenter);
     }
 }
 private function deleteRepo(GitRepository $repository)
 {
     $path = $repository->getPath();
     try {
         $this->logger->debug("Deleting repository " . $path);
         $this->system_event_manager->queueGrokMirrorManifestRepoDelete($path);
         $repository->delete();
     } catch (Exception $e) {
         $this->error($e->getMessage());
         return false;
     }
     $this->done();
     return true;
 }
示例#6
0
 /**
  *@todo move the archive to another directory
  * @param <type> $repository
  * @return <type>
  */
 public function archive(GitRepository $repository)
 {
     chdir($this->getGitRootPath());
     $path = $repository->getPath();
     $archiveName = $repository->getBackupPath() . '.tar.bz2';
     $cmd = ' tar cjf ' . $archiveName . ' ' . $path . ' 2>&1';
     $rcode = 0;
     $output = $this->system($cmd, $rcode);
     if ($rcode != 0) {
         throw new GitBackendException($cmd . ' -> ' . $output);
     }
     if (!empty($this->gitBackupDir) && is_dir($this->gitBackupDir)) {
         $this->system('mv ' . $this->getGitRootPath() . '/' . $archiveName . ' ' . $this->gitBackupDir . '/' . $archiveName);
     }
     return true;
 }
示例#7
0
 /**
  * Configure gitphp output
  * 
  * @param GitRepository $repository
  */
 public function getView($repository)
 {
     include_once 'common/include/Codendi_HTMLPurifier.class.php';
     if (empty($_REQUEST['a'])) {
         $_REQUEST['a'] = 'summary';
     }
     set_time_limit(300);
     $_GET['a'] = $_REQUEST['a'];
     $_REQUEST['group_id'] = $this->groupId;
     $_REQUEST['repo_id'] = $repository->getId();
     $_REQUEST['repo_name'] = $repository->getFullName();
     $_GET['p'] = $_REQUEST['repo_name'] . '.git';
     $_REQUEST['repo_path'] = $repository->getPath();
     $_REQUEST['project_dir'] = $repository->getProject()->getUnixName();
     $_REQUEST['git_root_path'] = $repository->getGitRootPath();
     $_REQUEST['action'] = 'view';
     if (empty($_REQUEST['noheader'])) {
         //echo '<hr>';
         echo '<div id="gitphp">';
     }
     include $this->getGitPhpIndexPath();
     if (empty($_REQUEST['noheader'])) {
         echo '</div>';
     }
 }
示例#8
0
 public function save(GitRepository $repository)
 {
     $id = (int) $repository->getId();
     $name = $repository->getName();
     $mailPrefix = $repository->getMailPrefix();
     $parentId = 0;
     $scope = $repository->getScope();
     $namespace = $repository->getNamespace();
     try {
         $parent = $repository->getParent();
         if (!empty($parent)) {
             $parentId = $parent->getId();
         }
     } catch (GitDaoException $e) {
     }
     $projectId = $repository->getProjectId();
     $description = $repository->getDescription();
     $path = $repository->getPath();
     $isInitialized = $repository->getIsInitialized();
     $creationUserId = $repository->getCreatorId();
     $access = $repository->getAccess();
     //protect parameters
     $id = $this->da->escapeInt($id);
     $name = $this->da->quoteSmart($name);
     $description = $this->da->quoteSmart($description);
     $path = $this->da->quoteSmart($path);
     $projectId = $this->da->escapeInt($projectId);
     $isInitialized = $this->da->escapeInt($isInitialized);
     $creationUserId = $this->da->escapeInt($creationUserId);
     $access = $this->da->quoteSmart($access);
     $mailPrefix = $this->da->quoteSmart($mailPrefix);
     $scope = $this->da->quoteSmart($scope);
     $namespace = $this->da->quoteSmart($namespace);
     $backup_path = $this->da->quoteSmart($repository->getBackupPath());
     $insert = false;
     if ($this->exists($id)) {
         $query = 'UPDATE ' . $this->getTable() . ' SET ' . self::REPOSITORY_DESCRIPTION . '=' . $description . ',' . self::REPOSITORY_IS_INITIALIZED . '=' . $isInitialized . ',' . self::REPOSITORY_ACCESS . '=' . $access . ',' . self::REPOSITORY_MAIL_PREFIX . '=' . $mailPrefix . ',' . self::REPOSITORY_BACKUP_PATH . '=' . $backup_path . 'WHERE ' . self::REPOSITORY_ID . '=' . $id;
     } else {
         if ($repository->getBackend() instanceof Git_Backend_Gitolite) {
             $backendType = self::BACKEND_GITOLITE;
         } else {
             $backendType = self::BACKEND_GITSHELL;
         }
         $insert = true;
         $creationDate = date('Y-m-d H:i:s');
         $query = 'INSERT INTO ' . $this->getTable() . '(' . self::REPOSITORY_NAME . ',' . self::REPOSITORY_PATH . ',' . self::REPOSITORY_PARENT . ',' . self::REPOSITORY_DESCRIPTION . ',' . self::FK_PROJECT_ID . ',' . self::REPOSITORY_CREATION_DATE . ',' . self::REPOSITORY_CREATION_USER_ID . ',' . self::REPOSITORY_IS_INITIALIZED . ',' . self::REPOSITORY_ACCESS . ',' . self::REPOSITORY_BACKEND_TYPE . ',' . self::REPOSITORY_SCOPE . ',' . self::REPOSITORY_NAMESPACE . ') values (' . "" . $name . "," . "" . $path . "," . "" . $parentId . "," . "" . $description . "," . $projectId . "," . "'" . $creationDate . "'," . $creationUserId . "," . $isInitialized . ',' . $access . ',' . $this->da->quoteSmart($backendType) . ',' . $scope . ',' . $namespace . ')';
     }
     if ($this->update($query) === false) {
         throw new GitDaoException($GLOBALS['Language']->getText('plugin_git', 'dao_update_error') . ' : ' . $this->da->isError());
     }
     if ($insert) {
         return $this->da->lastInsertId();
     }
     return true;
 }
 /**
  *
  * Restore archived repository
  *
  * @param GitRepository $repository
  * @param String git_root_path
  * @param String $backup_directory
  *
  * @return boolean
  *
  */
 public function restoreRepository(GitRepository $repository, $git_root_path, $backup_directory)
 {
     $repository_path = $git_root_path . $repository->getPath();
     $backup_path = $this->getBackupPath($repository, $backup_directory);
     if (!file_exists($backup_path)) {
         $this->logger->error('[Gitolite][Restore] Unable to find repository archive: ' . $backup_path);
         return false;
     }
     $backup_path = realpath($backup_path);
     if (!$this->extractRepository($backup_path)) {
         $this->logger->error('[Gitolite][Restore] Unable to restore repository: ' . $repository->getName());
         return false;
     }
     $this->deleteBackup($repository, $backup_directory);
     if (!$this->getDao()->activate($repository->getId())) {
         $this->logger->error('[Gitolite][Restore] Unable to activate repository after restore: ' . $repository->getName());
     }
     if (!$repository->getBackend()->updateRepoConf($repository)) {
         $this->logger->warn('[Gitolite][Restore] Unable to update repository configuration after restore : ' . $repository->getName());
     }
     $this->logger->info('[Gitolite] Restore of repository "' . $repository->getName() . '" completed');
     return true;
 }
 private function getRepositoryKey(GitRepository $repository)
 {
     return '/' . $repository->getPath();
 }
 /**
  * @throws GitRepositoryAlreadyExistsException 
  */
 public function fork(GitRepository $old, GitRepository $new, array $forkPermissions)
 {
     $new_project = $new->getProject();
     if ($this->getDao()->isRepositoryExisting($new_project->getId(), $new->getPath())) {
         throw new GitRepositoryAlreadyExistsException('Respository already exists');
     } else {
         $id = $this->getDao()->save($new);
         $new->setId($id);
         if (empty($forkPermissions)) {
             $this->clonePermissions($old, $new);
         } else {
             $this->savePermissions($new, $forkPermissions);
         }
         return $id;
     }
 }
示例#12
0
 /**
  * Configure mail output to link commit to gitweb 
  *
  * @param GitRepository $repository
  */
 public function setUpMailingHook($repository)
 {
     $path = $this->getGitRootPath() . $repository->getPath();
     $this->getDriver()->setConfig($path, 'hooks.showrev', $repository->getPostReceiveShowRev());
 }
 /**
  * @throws GitRepositoryAlreadyExistsException 
  */
 public function fork(GitRepository $old, GitRepository $new)
 {
     $name = $old->getName();
     //TODO use $old->getRootPath() (good luck for Unit Tests!)
     $old_namespace = $old->getProject()->getUnixName() . '/' . $old->getNamespace();
     $new_namespace = $new->getProject()->getUnixName() . '/' . $new->getNamespace();
     $new_project = $new->getProject();
     if ($this->getDao()->isRepositoryExisting($new_project->getId(), $new->getPath())) {
         throw new GitRepositoryAlreadyExistsException('Respository already exists');
     } else {
         $forkSucceeded = $this->getDriver()->fork($name, $old_namespace, $new_namespace);
         if ($forkSucceeded) {
             $id = $this->getDao()->save($new);
             $new->setId($id);
             $this->clonePermissions($old, $new);
             $this->updateRepoConf($new);
         }
     }
 }