@catladder/cli 3.15.0 → 3.16.0

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.0",
56
+ "version": "3.16.0",
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
 
@@ -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";