@catladder/cli 3.15.1 → 3.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -53,7 +53,7 @@
53
53
  }
54
54
  ],
55
55
  "license": "MIT",
56
- "version": "3.15.1",
56
+ "version": "3.16.1",
57
57
  "scripts": {
58
58
  "lint": "eslint \"src/**/*.ts\"",
59
59
  "lint:fix": "eslint \"src/**/*.ts\" --fix",
@@ -2,6 +2,7 @@ import type { CommandInstance } from "vorpal";
2
2
  import { doGitlabRequest, getProjectInfo } from "../../../../../utils/gitlab";
3
3
  import { getProjectConfig } from "../../../../../config/getProjectConfig";
4
4
  import { getGitRemoteHostAndPath } from "../../../../../git/gitProjectInformation";
5
+ import { getMainBranch } from "../../../../../git";
5
6
  import type { AgentConfig } from "@catladder/pipeline";
6
7
 
7
8
  type TriggerToken = {
@@ -133,7 +134,8 @@ const setupAgentWebhook = async (
133
134
  ): Promise<Webhook> => {
134
135
  const webhookName = `cl_agent_${agentName}_webhook`;
135
136
  const { gitRemoteHost } = await getGitRemoteHostAndPath();
136
- const webhookUrl = `https://${gitRemoteHost}/api/v4/projects/${projectId}/ref/main/trigger/pipeline?token=${triggerToken}`;
137
+ const mainBranch = await getMainBranch();
138
+ const webhookUrl = `https://${gitRemoteHost}/api/v4/projects/${projectId}/ref/${mainBranch}/trigger/pipeline?token=${triggerToken}`;
137
139
 
138
140
  instance.log(`Setting up webhook for agent: ${agentName}`);
139
141
 
@@ -179,11 +181,13 @@ const setupAgentWebhook = async (
179
181
  merge_request_title: "{{merge_request.title}}",
180
182
  merge_request_source_branch: "{{merge_request.source_branch}}",
181
183
  merge_request_time_estimate: "{{merge_request.time_estimate}}",
184
+ // FIXME: may cause issues with gitlab webhooks when there are double quotes in the description
182
185
  //merge_request_description: "{{merge_request.description}}",
183
186
  merge_request_merge_status: "{{merge_request.merge_status}}",
184
187
  merge_request_last_commit_title: "{{merge_request.last_commit.title}}",
185
- merge_request_last_commit_message:
186
- "{{merge_request.last_commit.message}}",
188
+ // FIXME: may cause issues with gitlab webhooks when there are double quotes in the message
189
+ //merge_request_last_commit_message:
190
+ // "{{merge_request.last_commit.message}}",
187
191
  merge_request_last_commit_author_name:
188
192
  "{{merge_request.last_commit.author.name}}",
189
193
  merge_request_last_commit_author_email:
@@ -0,0 +1,5 @@
1
+ import { exec } from "child-process-promise";
2
+ export const getMainBranch = async () => {
3
+ const { stdout } = await exec("git rev-parse --abbrev-ref HEAD");
4
+ return stdout.trim();
5
+ };
package/src/git/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./gitConfig";
2
2
  export * from "./gitProjectInformation";
3
+ export * from "./getGetMainBranch";