From d74a787035d59c88edd4815dae0e826c74e231f6 Mon Sep 17 00:00:00 2001 From: Andrea Lamparelli Date: Mon, 14 Apr 2025 17:48:09 +0200 Subject: [PATCH] fix(#151): fix gitlab post comments url (#152) --- dist/cli/index.js | 6 ++++-- dist/gha/index.js | 6 ++++-- mise.toml | 2 ++ src/service/git/gitlab/gitlab-client.ts | 6 ++++-- 4 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 mise.toml diff --git a/dist/cli/index.js b/dist/cli/index.js index 6e48496..4a14d47 100755 --- a/dist/cli/index.js +++ b/dist/cli/index.js @@ -1151,7 +1151,9 @@ class GitLabClient { // example: /api/v4/projects/%2Fbackporting-example/merge_requests/1 async getPullRequest(namespace, repo, mrNumber, squash) { const projectId = this.getProjectId(namespace, repo); - const { data } = await this.client.get(`/projects/${projectId}/merge_requests/${mrNumber}`); + const url = `/projects/${projectId}/merge_requests/${mrNumber}`; + this.logger.debug(`Fetching pull request ${url}`); + const { data } = await this.client.get(`${url}`); if (squash === undefined) { squash = (0, git_util_1.inferSquash)(data.state === "opened", data.squash_commit_sha); } @@ -1241,7 +1243,7 @@ class GitLabClient { try { const { namespace, project, id } = this.extractMergeRequestData(mrUrl); const projectId = this.getProjectId(namespace, project); - const { data } = await this.client.post(`/projects/${projectId}/issues/${id}/notes`, { + const { data } = await this.client.post(`/projects/${projectId}/merge_requests/${id}/notes`, { body: comment, }); if (!data) { diff --git a/dist/gha/index.js b/dist/gha/index.js index 3d1119e..b477378 100755 --- a/dist/gha/index.js +++ b/dist/gha/index.js @@ -1116,7 +1116,9 @@ class GitLabClient { // example: /api/v4/projects/%2Fbackporting-example/merge_requests/1 async getPullRequest(namespace, repo, mrNumber, squash) { const projectId = this.getProjectId(namespace, repo); - const { data } = await this.client.get(`/projects/${projectId}/merge_requests/${mrNumber}`); + const url = `/projects/${projectId}/merge_requests/${mrNumber}`; + this.logger.debug(`Fetching pull request ${url}`); + const { data } = await this.client.get(`${url}`); if (squash === undefined) { squash = (0, git_util_1.inferSquash)(data.state === "opened", data.squash_commit_sha); } @@ -1206,7 +1208,7 @@ class GitLabClient { try { const { namespace, project, id } = this.extractMergeRequestData(mrUrl); const projectId = this.getProjectId(namespace, project); - const { data } = await this.client.post(`/projects/${projectId}/issues/${id}/notes`, { + const { data } = await this.client.post(`/projects/${projectId}/merge_requests/${id}/notes`, { body: comment, }); if (!data) { diff --git a/mise.toml b/mise.toml new file mode 100644 index 0000000..126f680 --- /dev/null +++ b/mise.toml @@ -0,0 +1,2 @@ +[tools] +node = "20" diff --git a/src/service/git/gitlab/gitlab-client.ts b/src/service/git/gitlab/gitlab-client.ts index da26010..6d17ccf 100644 --- a/src/service/git/gitlab/gitlab-client.ts +++ b/src/service/git/gitlab/gitlab-client.ts @@ -48,7 +48,9 @@ export default class GitLabClient implements GitClient { // example: /api/v4/projects/%2Fbackporting-example/merge_requests/1 async getPullRequest(namespace: string, repo: string, mrNumber: number, squash: boolean | undefined): Promise { const projectId = this.getProjectId(namespace, repo); - const { data } = await this.client.get(`/projects/${projectId}/merge_requests/${mrNumber}`); + const url = `/projects/${projectId}/merge_requests/${mrNumber}`; + this.logger.debug(`Fetching pull request ${url}`); + const { data } = await this.client.get(`${url}`); if (squash === undefined) { squash = inferSquash(data.state === "opened", data.squash_commit_sha); @@ -169,7 +171,7 @@ export default class GitLabClient implements GitClient { const { namespace, project, id } = this.extractMergeRequestData(mrUrl); const projectId = this.getProjectId(namespace, project); - const { data } = await this.client.post(`/projects/${projectId}/issues/${id}/notes`, { + const { data } = await this.client.post(`/projects/${projectId}/merge_requests/${id}/notes`, { body: comment, });