diff --git a/module/gitlab/model.php b/module/gitlab/model.php index ef13b9d87b..cc2a7c4a98 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -685,15 +685,19 @@ class gitlabModel extends model * * @param int $gitlabID * @param string $simple + * @param int $minID + * @param int $maxID * @access public * @return array */ - public function apiGetProjects($gitlabID, $simple = 'true') + public function apiGetProjects($gitlabID, $simple = 'true', $minID = 0, $maxID = 0) { $apiRoot = $this->getApiRoot($gitlabID); if(!$apiRoot) return array(); $url = sprintf($apiRoot, "/projects"); + if($minID > 0) $url .= '&id_after=' . (intval($minID) - 1); + if($maxID > 0) $url .= '&id_before=' . (intval($maxID) + 1); $allResults = array(); for($page = 1; true; $page++) diff --git a/module/mr/model.php b/module/mr/model.php index 542e8556ed..ebdb9a4321 100644 --- a/module/mr/model.php +++ b/module/mr/model.php @@ -112,7 +112,17 @@ class mrModel extends model { if(!$this->app->user->admin and !isset($gitlabUsers[$gitlabID])) continue; - $allProjects[$gitlabID] = $this->gitlab->apiGetProjects($gitlabID, 'false'); + $minProject = $maxProject = 0; + $projectCount = $this->dao->select('min(sourceProject) as minSource,MAX(sourceProject) as maxSource,MIN(targetProject) as minTarget,MAX(targetProject) as maxTarget')->from(TABLE_MR) + ->where('deleted')->eq('0') + ->andWhere('gitlabID')->eq($gitlabID) + ->fetch(); + if($projectCount) + { + $minProject = min($projectCount->minSource, $projectCount->minTarget); + $maxProject = max($projectCount->maxSource, $projectCount->maxTarget); + } + $allProjects[$gitlabID] = $this->gitlab->apiGetProjects($gitlabID, 'false', $minProject, $maxProject); /* If not an administrator, need to obtain group member information. */ $groupIDList = array(0 => 0); diff --git a/module/repo/control.php b/module/repo/control.php index 1a958824cd..e52e7bc9cc 100644 --- a/module/repo/control.php +++ b/module/repo/control.php @@ -828,11 +828,15 @@ class repo extends control * @param string $fromRevision * @param string $toRevision * @param string $type + * @param bool $isBranchOrTag * @access public * @return void */ - public function download($repoID, $path, $fromRevision = 'HEAD', $toRevision = '', $type = 'file') + public function download($repoID, $path, $fromRevision = 'HEAD', $toRevision = '', $type = 'file', $isBranchOrTag = false) { + $fromRevision = str_replace('*', '-', $fromRevision); + $toRevision = str_replace('*', '-', $toRevision); + if($this->get->repoPath) $path = $this->get->repoPath; $entry = $this->repo->decodePath($path); $repo = $this->repo->getRepoByID($repoID); @@ -842,7 +846,7 @@ class repo extends control $this->commonAction($repoID); $this->scm->setEngine($repo); - $content = $type == 'file' ? $this->scm->cat($entry, $fromRevision) : $this->scm->diff($entry, $fromRevision, $toRevision, 'patch'); + $content = $type == 'file' ? $this->scm->cat($entry, $fromRevision) : $this->scm->diff($entry, $fromRevision, $toRevision, 'patch', $isBranchOrTag ? 'isBranchOrTag': ''); $fileName = basename(urldecode($entry)); if($type != 'file') $fileName .= "r$fromRevision--r$toRevision.patch";