diff --git a/module/gitlab/model.php b/module/gitlab/model.php index 9f3abe8f17..ee8c951d99 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -490,6 +490,31 @@ class gitlabModel extends model return $allResults; } + /** + * API获取项目的合并请求列表。 + * Get Merge Requests by API. + * + * @param int $gitlabID + * @param int $projectID + * @return array + */ + public function apiGetMergeRequests(int $gitlabID, int $projectID): array + { + $apiRoot = $this->getApiRoot((int)$gitlabID); + $url = sprintf($apiRoot, "/projects/$projectID/merge_requests"); + + $MRs = array(); + for($page = 1; true; $page++) + { + $onePageMRs = json_decode(commonModel::http($url . "&&page={$page}&per_page=100")); + if(!is_array($onePageMRs)) break; + if(!empty($onePageMRs)) $MRs = array_merge($MRs, $onePageMRs); + if(count($onePageMRs) < 100) break; + } + + return $MRs; + } + /** * 获取gitlab命名空间列表。 * Get namespaces of one gitlab.