All checks were successful
CI Monitor MIflow / build-image (push) Successful in 2m42s
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
import { MergeRequestNoteSchema } from "@gitbeaker/rest"
|
|
|
|
import netTool from "../netTool"
|
|
import { GITLAB_AUTH_HEADER, GITLAB_BASE_URL, gitlabReqWarp } from "./tools"
|
|
|
|
/**
|
|
* 创建一个新的合并请求备注
|
|
* @param {number} project_id - 项目ID
|
|
* @param {number} merge_request_iid - 合并请求IID
|
|
* @param {string} body - 备注内容
|
|
* @returns {Promise<MergeRequestNoteSchema>} - 返回包含新创建备注的Promise
|
|
*/
|
|
const create2Mr = async (
|
|
project_id: number,
|
|
merge_request_iid: number,
|
|
body: string
|
|
): Promise<MergeRequestNoteSchema> => {
|
|
const URL = `${GITLAB_BASE_URL}/projects/${project_id}/merge_requests/${merge_request_iid}/notes`
|
|
return gitlabReqWarp<MergeRequestNoteSchema>(
|
|
() => netTool.post(URL, { body }, {}, GITLAB_AUTH_HEADER),
|
|
null
|
|
)
|
|
}
|
|
|
|
/**
|
|
* 修改一个现有的合并请求备注
|
|
* @param {number} project_id - 项目ID
|
|
* @param {number} merge_request_iid - 合并请求IID
|
|
* @param {number} note_id - 备注ID
|
|
* @param {string} body - 新的备注内容
|
|
* @returns {Promise<MergeRequestNoteSchema>} - 返回包含修改后备注的Promise
|
|
*/
|
|
const modify2Mr = async (
|
|
project_id: number,
|
|
merge_request_iid: number,
|
|
note_id: number,
|
|
body: string
|
|
): Promise<MergeRequestNoteSchema> => {
|
|
const URL = `${GITLAB_BASE_URL}/projects/${project_id}/merge_requests/${merge_request_iid}/notes/${note_id}`
|
|
return gitlabReqWarp<MergeRequestNoteSchema>(
|
|
() => netTool.put(URL, { body }, {}, GITLAB_AUTH_HEADER),
|
|
null
|
|
)
|
|
}
|
|
|
|
const note = {
|
|
create2Mr,
|
|
modify2Mr,
|
|
}
|
|
|
|
export default note
|