import { normalizeMergeRequestLocator, pickAuthInput, request } from '../core.ts' import { asRecord, slimMergeRequest } from '../shape.ts' /** * Fetch one GitLab merge request by project + iid, or by merge request URL. * * @example * import getGitlabMergeRequest from 'kody:@kody/gitlab/merge-requests/get' * const mr = await getGitlabMergeRequest({ * project: 'example-group/example-project', * mergeRequestIid: 4, * }) */ export default async function getGitlabMergeRequest(params: Record = {}) { const auth = pickAuthInput(params) const { projectId, projectPath, mergeRequestIid } = normalizeMergeRequestLocator(params) const response = await request>({ ...auth, path: `/projects/${projectId}/merge_requests/${mergeRequestIid}`, throwOnError: true, }) return { ...slimMergeRequest(asRecord(response.data)), projectPath, auth: response.auth, } }