+ Add the method to get MRs by GitFox API.

This commit is contained in:
dingguodong
2024-04-30 14:48:04 +08:00
parent 2e264a59ed
commit ed2eae4ba8
+27
View File
@@ -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.