From ed2eae4ba8b439abec3161dc5e2635ded275d64e Mon Sep 17 00:00:00 2001 From: dingguodong Date: Tue, 30 Apr 2024 14:48:04 +0800 Subject: [PATCH] + Add the method to get MRs by GitFox API. --- module/gitfox/model.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/module/gitfox/model.php b/module/gitfox/model.php index e318832ccd..17ef50522d 100644 --- a/module/gitfox/model.php +++ b/module/gitfox/model.php @@ -191,6 +191,33 @@ class gitfoxModel extends model return json_decode(commonModel::http($url, null, array(), $apiRoot->header)); } + /** + * 通过api获取合并请求。 + * Get Pull Requests/Merge Requests by API. + * + * @param mixed $gitfoxID + * @param mixed $repoID + * @return object + */ + public function apiGetMergeRequests(int $gitfoxID, int $repoID): object|null + { + $apiRoot = $this->getApiRoot($gitfoxID, false); + $apiPath = "/repos/{$repoID}/pullreq"; + $url = sprintf($apiRoot->url, $apiPath); + + $MRs = json_decode(commonModel::http($url, null, array(), $apiRoot->header)); + foreach($MRs as $MR) + { + $MR->iid = $MR->number; + $MR->source_project_id = $MR->source_repo_id; + $MR->target_project_id = $MR->target_repo_id; + $MR->work_in_progress = $MR->is_draft; + $MR->draft = $MR->is_draft; + } + + return $MRs; + } + /** * 通过api创建hook。 * Create hook by api.