fix(#151): fix gitlab post comments url

This commit is contained in:
Andrea Lamparelli 2025-04-14 17:27:13 +02:00
parent 3a9d367b48
commit 69b693bed0
4 changed files with 14 additions and 6 deletions

6
dist/cli/index.js vendored
View file

@ -1151,7 +1151,9 @@ class GitLabClient {
// example: <host>/api/v4/projects/<namespace>%2Fbackporting-example/merge_requests/1 // example: <host>/api/v4/projects/<namespace>%2Fbackporting-example/merge_requests/1
async getPullRequest(namespace, repo, mrNumber, squash) { async getPullRequest(namespace, repo, mrNumber, squash) {
const projectId = this.getProjectId(namespace, repo); 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) { if (squash === undefined) {
squash = (0, git_util_1.inferSquash)(data.state === "opened", data.squash_commit_sha); squash = (0, git_util_1.inferSquash)(data.state === "opened", data.squash_commit_sha);
} }
@ -1241,7 +1243,7 @@ class GitLabClient {
try { try {
const { namespace, project, id } = this.extractMergeRequestData(mrUrl); const { namespace, project, id } = this.extractMergeRequestData(mrUrl);
const projectId = this.getProjectId(namespace, project); 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, body: comment,
}); });
if (!data) { if (!data) {

6
dist/gha/index.js vendored
View file

@ -1116,7 +1116,9 @@ class GitLabClient {
// example: <host>/api/v4/projects/<namespace>%2Fbackporting-example/merge_requests/1 // example: <host>/api/v4/projects/<namespace>%2Fbackporting-example/merge_requests/1
async getPullRequest(namespace, repo, mrNumber, squash) { async getPullRequest(namespace, repo, mrNumber, squash) {
const projectId = this.getProjectId(namespace, repo); 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) { if (squash === undefined) {
squash = (0, git_util_1.inferSquash)(data.state === "opened", data.squash_commit_sha); squash = (0, git_util_1.inferSquash)(data.state === "opened", data.squash_commit_sha);
} }
@ -1206,7 +1208,7 @@ class GitLabClient {
try { try {
const { namespace, project, id } = this.extractMergeRequestData(mrUrl); const { namespace, project, id } = this.extractMergeRequestData(mrUrl);
const projectId = this.getProjectId(namespace, project); 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, body: comment,
}); });
if (!data) { if (!data) {

2
mise.toml Normal file
View file

@ -0,0 +1,2 @@
[tools]
node = "20"

View file

@ -48,7 +48,9 @@ export default class GitLabClient implements GitClient {
// example: <host>/api/v4/projects/<namespace>%2Fbackporting-example/merge_requests/1 // example: <host>/api/v4/projects/<namespace>%2Fbackporting-example/merge_requests/1
async getPullRequest(namespace: string, repo: string, mrNumber: number, squash: boolean | undefined): Promise<GitPullRequest> { async getPullRequest(namespace: string, repo: string, mrNumber: number, squash: boolean | undefined): Promise<GitPullRequest> {
const projectId = this.getProjectId(namespace, repo); 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) { if (squash === undefined) {
squash = inferSquash(data.state === "opened", data.squash_commit_sha); 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 { namespace, project, id } = this.extractMergeRequestData(mrUrl);
const projectId = this.getProjectId(namespace, project); 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, body: comment,
}); });