+ [task#124017] Add method to create tag by gitlab API.

This commit is contained in:
dingguodong
2024-07-29 15:31:16 +08:00
committed by 翟晓剑
parent 7bf0c5bcef
commit 29e78f3321
+19
View File
@@ -940,6 +940,25 @@ class gitlabModel extends model
return json_decode(commonModel::http($url, $branch, array(), array(), 'json'));
}
/**
* 通过API创建一个标签。
* Creates a new tag in the GitLab repository using the GitLab API.
* @link https://docs.gitlab.com/ee/api/tags.html#create-a-new-tag
*
* @param int $gitlabID The ID of the GitLab instance.
* @param int $projectID The ID of the project in GitLab.
* @param object $tag An object containing the tag details, including the tag name and reference.
* @return object|array|null|false The response from the GitLab API, or false if the tag name or reference is empty.
*/
public function apiCreateTag(int $gitlabID, int $projectID, object $tag): object|array|null|false
{
if(empty($tag->tag_name) or empty($tag->ref)) return false;
$apiRoot = $this->getApiRoot($gitlabID);
$url = sprintf($apiRoot, "/projects/{$projectID}/repository/tags");
return json_decode(commonModel::http($url, $tag, array(), array(), 'json'));
}
/**
* 通过api获取一个项目信息。
* Get single project by API.