Skip to content

Commit 94a46aa

Browse files
authored
fix: Support grabbing branch in Vercel (#80)
Grab the branch in Vercel env helper.
1 parent 7bc7183 commit 94a46aa

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

.changeset/early-phones-prove.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@codecov/bundler-plugin-core": patch
3+
"@codecov/rollup-plugin": patch
4+
"@codecov/vite-plugin": patch
5+
"@codecov/webpack-plugin": patch
6+
---
7+
8+
Grab branch name inside Vercel helper so that we for sure have a branch value

packages/bundler-plugin-core/src/utils/providers/Vercel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ function _getBuildURL(): string {
2121
}
2222

2323
function _getBranch(inputs: ProviderUtilInputs): string {
24-
const { args } = inputs;
24+
const { args, envs } = inputs;
2525

26-
return args?.branch ?? "";
26+
return args?.branch ?? envs?.VERCEL_GIT_COMMIT_REF ?? "";
2727
}
2828

2929
function _getJob(): string {

packages/bundler-plugin-core/src/utils/providers/__tests__/Vercel.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ describe("Vercel Params", () => {
4444
VERCEL_GIT_COMMIT_SHA: "testingsha",
4545
VERCEL_GIT_REPO_SLUG: "testRepo",
4646
VERCEL_GIT_REPO_OWNER: "testOrg",
47+
VERCEL_GIT_COMMIT_REF: "super-cool-branch",
4748
},
4849
};
4950

5051
const expected: ProviderServiceParams = {
51-
branch: "",
52+
branch: "super-cool-branch",
5253
build: "",
5354
buildURL: "",
5455
commit: "testingsha",
@@ -76,6 +77,7 @@ describe("Vercel Params", () => {
7677
VERCEL_GIT_COMMIT_SHA: "testingsha",
7778
VERCEL_GIT_REPO_SLUG: "testRepo",
7879
VERCEL_GIT_REPO_OWNER: "testOrg",
80+
VERCEL_GIT_COMMIT_REF: "super-cool-branch",
7981
},
8082
};
8183

0 commit comments

Comments
 (0)