@shopify/oxygen-cli 1.11.7-unstable.202309081456.0 → 1.12.1-unstable.202309120939.0
Sign up to get free protection for your applications and to get access to all the features.
package/dist/deploy/metadata.js
CHANGED
@@ -8,10 +8,10 @@ async function getMetadata(config, logger) {
|
|
8
8
|
let metadata = {};
|
9
9
|
try {
|
10
10
|
const gitCommit = await getLatestGitCommit(config.rootPath);
|
11
|
-
const branch = gitCommit.refs
|
11
|
+
const branch = (/HEAD -> ([^,]*)/.exec(gitCommit.refs) || [])[1];
|
12
12
|
metadata = {
|
13
13
|
actor: gitCommit.author_name,
|
14
|
-
branch
|
14
|
+
branch,
|
15
15
|
commitDate: gitCommit.date,
|
16
16
|
commitSha: gitCommit.hash,
|
17
17
|
commitMessage: gitCommit.message.substring(0, maxLabelLength)
|
@@ -7,6 +7,7 @@ import { getMetadata, getEnvironmentInput, createLabels } from './metadata.js';
|
|
7
7
|
|
8
8
|
vi.mock("@shopify/cli-kit/node/context/local");
|
9
9
|
vi.mock("@shopify/cli-kit/node/git");
|
10
|
+
vi.mock("@shopify/cli-kit/node/output");
|
10
11
|
describe("getMetadata", () => {
|
11
12
|
test("should return custom metadata from environment", async () => {
|
12
13
|
vi.mocked(ciPlatform).mockReturnValueOnce({
|
@@ -69,6 +70,39 @@ describe("getMetadata", () => {
|
|
69
70
|
expect(metadataResult.name).toBe("none");
|
70
71
|
expect(metadataResult.url).toBe(void 0);
|
71
72
|
});
|
73
|
+
test("should derive branch correctly from commit refs", async () => {
|
74
|
+
vi.mocked(ciPlatform).mockReturnValue({
|
75
|
+
isCI: false
|
76
|
+
});
|
77
|
+
const testCases = {
|
78
|
+
"HEAD -> main, origin/main, origin/HEAD": "main",
|
79
|
+
"HEAD -> dev, origin/dev, origin/HEAD": "dev",
|
80
|
+
"HEAD -> feature/awesome-feature, origin/feature/awesome-feature, origin/HEAD": "feature/awesome-feature",
|
81
|
+
"HEAD -> bugfix/123-fix-bug, origin/bugfix/123-fix-bug, origin/HEAD": "bugfix/123-fix-bug",
|
82
|
+
"HEAD -> release/v1.0.0, origin/release/v1.0.0, origin/HEAD": "release/v1.0.0",
|
83
|
+
"HEAD -> hotfix/urgent-fix, origin/hotfix/urgent-fix, origin/HEAD": "hotfix/urgent-fix",
|
84
|
+
"HEAD -> test, origin/test, origin/HEAD": "test",
|
85
|
+
"HEAD -> my-branch, origin/my-branch, origin/HEAD": "my-branch",
|
86
|
+
"HEAD -> long-branch-name, origin/long-branch-name, origin/HEAD": "long-branch-name",
|
87
|
+
"HEAD -> branch_with_underscores, origin/branch_with_underscores, origin/HEAD": "branch_with_underscores",
|
88
|
+
"HEAD -> branch-with-dashes, origin/branch-with-dashes, origin/HEAD": "branch-with-dashes",
|
89
|
+
"HEAD -> branch.with.dots, origin/branch.with.dots, origin/HEAD": "branch.with.dots"
|
90
|
+
};
|
91
|
+
for (const [refs, expectedBranch] of Object.entries(testCases)) {
|
92
|
+
vi.mocked(getLatestGitCommit).mockResolvedValueOnce({
|
93
|
+
author_name: "gh_author",
|
94
|
+
author_email: "test@github.com",
|
95
|
+
hash: "gh_hash",
|
96
|
+
message: "gh_message",
|
97
|
+
refs,
|
98
|
+
date: "gh_date",
|
99
|
+
body: "gh_body"
|
100
|
+
});
|
101
|
+
const testConfig = createTestConfig("/tmp/deploymentRoot/");
|
102
|
+
const metadataResult = await getMetadata(testConfig, stderrLogger);
|
103
|
+
expect(metadataResult.branch).toBe(expectedBranch);
|
104
|
+
}
|
105
|
+
});
|
72
106
|
});
|
73
107
|
describe("getEnvironmentInput", () => {
|
74
108
|
test("should return environment tag from config", () => {
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
"@shopify:registry": "https://registry.npmjs.org"
|
6
6
|
},
|
7
7
|
"license": "MIT",
|
8
|
-
"version": "1.
|
8
|
+
"version": "1.12.1-unstable.202309120939.0",
|
9
9
|
"type": "module",
|
10
10
|
"scripts": {
|
11
11
|
"build": "tsup --clean --config ./tsup.config.ts && oclif manifest",
|
@@ -16,7 +16,8 @@
|
|
16
16
|
"lint:format": "prettier --write \"**/*.*\" && npm run lint --fix",
|
17
17
|
"generate:manifest": "oclif manifest",
|
18
18
|
"prepack": "npm install && npm run build",
|
19
|
-
"
|
19
|
+
"prepublishOnly": "rm -rf dist/**/*.test.*",
|
20
|
+
"release": "npm run build && npx changeset publish && git push --follow-tags",
|
20
21
|
"test": "vitest run",
|
21
22
|
"test:watch": "vitest"
|
22
23
|
},
|
@@ -44,7 +45,7 @@
|
|
44
45
|
"@shopify/prettier-config": "^1.1.2",
|
45
46
|
"@types/async": "^3.2.18",
|
46
47
|
"@types/node": "^20.5.9",
|
47
|
-
"eslint": "^8.
|
48
|
+
"eslint": "^8.49.0",
|
48
49
|
"eslint-plugin-prettier": "^5.0.0",
|
49
50
|
"node-fetch": "^3.3.2",
|
50
51
|
"oclif": "^3",
|