示例#1
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>';
     }
 }
 private function sendErrorNotification(GitRepository $repository)
 {
     $user = $this->getRequester();
     if (!$user->isAnonymous()) {
         $factory = new BaseLanguageFactory();
         $language = $factory->getBaseLanguage($user->getLocale());
         $url = get_server_url() . GIT_BASE_URL . '/?action=repo_management&group_id=' . $repository->getProjectId() . '&repo_id=' . $repository->getId() . '&pane=gerrit';
         $notification = new Notification(array($user->getEmail()), $language->getText('plugin_git', 'delegated_to_gerrit_error_mail_subject', array($repository->getFullName())), $language->getText('plugin_git', 'delegated_to_gerrit_error_mail_body', array($repository->getFullName(), $url)), $language->getText('plugin_git', 'delegated_to_gerrit_error_mail_body', array($repository->getFullName(), $url)), $url, 'git');
         $this->mail_builder->buildAndSendEmail($repository->getProject(), $notification, new MailEnhancer());
     }
 }
示例#3
0
 /**
  *
  * Behaviour extracted from official email hook prep_for_email() function
  *
  * @param GitRepository $repository
  * @param PFUser $user
  * @param type $oldrev
  * @param type $newrev
  * @param type $refname
  * @return Git_Hook_PushDetails
  */
 public function getPushDetails(GitRepository $repository, PFUser $user, $oldrev, $newrev, $refname)
 {
     $change_type = Git_Hook_PushDetails::ACTION_ERROR;
     $revision_list = array();
     $rev_type = '';
     try {
         if ($oldrev == self::FAKE_EMPTY_COMMIT) {
             $revision_list = $this->exec_repo->revListSinceStart($refname, $newrev);
             $change_type = Git_Hook_PushDetails::ACTION_CREATE;
         } elseif ($newrev == self::FAKE_EMPTY_COMMIT) {
             $change_type = Git_Hook_PushDetails::ACTION_DELETE;
         } else {
             $revision_list = $this->exec_repo->revList($oldrev, $newrev);
             $change_type = Git_Hook_PushDetails::ACTION_UPDATE;
         }
         if ($change_type == Git_Hook_PushDetails::ACTION_DELETE) {
             $rev_type = $this->exec_repo->getObjectType($oldrev);
         } else {
             $rev_type = $this->exec_repo->getObjectType($newrev);
         }
     } catch (Git_Command_Exception $exception) {
         $this->logger->error(__CLASS__ . " {$repository->getFullName()} {$refname} {$oldrev} {$newrev} " . $exception->getMessage());
     }
     return new Git_Hook_PushDetails($repository, $user, $refname, $change_type, $rev_type, $revision_list);
 }
 /**
  * @param GitRepository $repository
  * @return string the base url to access the git repository regarding plugin configuration
  */
 public function getRepositoryBaseUrl(GitRepository $repository)
 {
     if ($this->git_plugin->areFriendlyUrlsActivated()) {
         return GIT_BASE_URL . '/' . $repository->getProject()->getUnixName() . '/' . $repository->getFullName();
     } else {
         return GIT_BASE_URL . '/index.php/' . $repository->getProjectId() . '/view/' . $repository->getId() . '/';
     }
 }
示例#5
0
 private function getHeader()
 {
     $html = '';
     $repoId = $this->repository->getId();
     $creator = $this->repository->getCreator();
     $parent = $this->repository->getParent();
     $access = $this->repository->getAccess();
     $creatorName = '';
     if (!empty($creator)) {
         $creatorName = UserHelper::instance()->getLinkOnUserFromUserId($creator->getId());
     }
     // Access type
     $accessType = $this->getAccessType($access, $this->repository->getBackend() instanceof Git_Backend_Gitolite);
     $html .= '<h1>' . $accessType . $this->repository->getFullName() . '</h1>';
     if (!empty($parent)) {
         $html .= '<div id="plugin_git_repo_parent">';
         $html .= $GLOBALS['Language']->getText('plugin_git', 'view_repo_parent_' . $this->repository->getBackendType(), $parent->getHTMLLink($this->url_manager));
         $html .= '</div>';
     }
     return $html;
 }
 /**
  * Collect, into an array, logged git pushes matching a given git repository for the given duration.
  *
  * @param GitRepository $repository Git repository we want to fetch its pushes
  *
  * @return Array
  */
 private function getRepositoryPushesByWeek(GitRepository $repository)
 {
     $pushes = array();
     $gitLogDao = new Git_LogDao();
     foreach ($this->weekNum as $key => $w) {
         $res = $gitLogDao->getRepositoryPushesByWeek($repository->getId(), $w, $this->year[$key]);
         if ($res && !$res->isError() && $res->valid()) {
             $row = $res->getRow();
             $pushes[$key] = intval($row['pushes']);
             if ($pushes[$key] > 0) {
                 $this->displayChart = true;
                 $this->legend = $repository->getFullName();
             }
         }
         $pushes = array_pad($pushes, $this->weeksNumber, 0);
     }
     return $pushes;
 }
 public function repoFullName(GitRepository $repo, $unix_name)
 {
     require_once GIT_BASE_DIR . '/PathJoinUtil.php';
     return unixPathJoin(array($unix_name, $repo->getFullName()));
 }
示例#8
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>';
     }
 }
示例#9
0
 public function delete(GitRepository $repository)
 {
     $id = $repository->getId();
     $projectId = $repository->getProjectId();
     $id = $this->da->escapeInt($id);
     $projectId = $this->da->escapeInt($projectId);
     if (empty($id) || empty($projectId)) {
         throw new GitDaoException($GLOBALS['Language']->getText('plugin_git', 'dao_delete_params'));
     }
     $deletionDate = $repository->getDeletionDate();
     $projectName = $repository->getProject()->getUnixName();
     $backup_path = str_replace('/', '_', $repository->getFullName());
     $backup_path .= '_' . strtotime($deletionDate);
     $backup_path = $projectName . '_' . $backup_path;
     $backup_path = $this->da->quoteSmart($backup_path);
     $deletionDate = $this->da->quoteSmart($deletionDate);
     $query = ' UPDATE ' . $this->getTable() . ' SET ' . self::REPOSITORY_DELETION_DATE . '=' . $deletionDate . ', ' . self::REPOSITORY_BACKUP_PATH . '=' . $backup_path . ' WHERE ' . self::REPOSITORY_ID . '=' . $id . ' AND ' . self::FK_PROJECT_ID . '=' . $projectId;
     $r = $this->update($query);
     $ar = $this->da->affectedRows();
     if ($r === false || $ar == 0) {
         throw new GitDaoException($GLOBALS['Language']->getText('plugin_git', 'dao_delete_error') . ' ' . $this->da->isError());
     }
     if ($ar == 1) {
         return true;
     }
     return false;
 }
示例#10
0
 public function repoFullName(GitRepository $repo, $unix_name)
 {
     return unixPathJoin(array($unix_name, $repo->getFullName()));
 }
 private function getRepositoryFullName(GitRepository $repository)
 {
     return $repository->getFullName();
 }
 public function getGerritProjectName(GitRepository $repository)
 {
     $project = $repository->getProject()->getUnixName();
     $repo = $repository->getFullName();
     return "{$project}/{$repo}";
 }
示例#13
0
 private function redirectIfTryingToViewRepositoryAndUserFriendlyURLsActivated(Project $project, GitRepository $repository, $parameters)
 {
     if (!$this->getPlugin()->areFriendlyUrlsActivated()) {
         return;
     }
     $request_parameters = $parameters ? '?' . $parameters : '';
     $redirecting_url = GIT_BASE_URL . '/' . $project->getUnixName() . '/' . $repository->getFullName() . $request_parameters;
     header("Location: {$redirecting_url}", TRUE, 301);
 }
 public function getHTTPAccessURL(GitRepository $repository)
 {
     $http_url = $this->getConfigurationParameter('git_http_url');
     if ($http_url) {
         return $http_url . '/' . $repository->getProject()->getUnixName() . '/' . $repository->getFullName() . '.git';
     }
 }
 private function getLinkToRepositoryManagement(GitRepository $repository)
 {
     $project = $repository->getProject();
     return '<a href="/plugins/git/?action=repo_management&group_id=' . $project->getId() . '&repo_id=' . $repository->getId() . '">' . $project->getUnixName() . '/' . $repository->getFullName() . '</a>';
 }
 public function __construct(GitRepository $repository, array $used_mirrors)
 {
     $this->repository_id = $repository->getId();
     $this->name = $repository->getFullName();
     $this->used_mirrors = $used_mirrors;
 }
 /**
  * Return URL to access the respository for remote git commands
  *
  * @param  GitRepository $repository
  * @return String
  */
 public function getAccessUrl(GitRepository $repository)
 {
     $serverName = $_SERVER['SERVER_NAME'];
     return 'gitolite@' . $serverName . ':' . $repository->getProject()->getUnixName() . '/' . $repository->getFullName() . '.git';
 }