diff --git a/.changeset/early-phones-prove.md b/.changeset/early-phones-prove.md new file mode 100644 index 00000000..9638035a --- /dev/null +++ b/.changeset/early-phones-prove.md @@ -0,0 +1,8 @@ +--- +"@codecov/bundler-plugin-core": patch +"@codecov/rollup-plugin": patch +"@codecov/vite-plugin": patch +"@codecov/webpack-plugin": patch +--- + +Grab branch name inside Vercel helper so that we for sure have a branch value diff --git a/packages/bundler-plugin-core/src/utils/providers/Vercel.ts b/packages/bundler-plugin-core/src/utils/providers/Vercel.ts index 7e3b3bfe..15a28fd8 100644 --- a/packages/bundler-plugin-core/src/utils/providers/Vercel.ts +++ b/packages/bundler-plugin-core/src/utils/providers/Vercel.ts @@ -21,9 +21,9 @@ function _getBuildURL(): string { } function _getBranch(inputs: ProviderUtilInputs): string { - const { args } = inputs; + const { args, envs } = inputs; - return args?.branch ?? ""; + return args?.branch ?? envs?.VERCEL_GIT_COMMIT_REF ?? ""; } function _getJob(): string { diff --git a/packages/bundler-plugin-core/src/utils/providers/__tests__/Vercel.test.ts b/packages/bundler-plugin-core/src/utils/providers/__tests__/Vercel.test.ts index f2b0ae25..5f944e6a 100644 --- a/packages/bundler-plugin-core/src/utils/providers/__tests__/Vercel.test.ts +++ b/packages/bundler-plugin-core/src/utils/providers/__tests__/Vercel.test.ts @@ -44,11 +44,12 @@ describe("Vercel Params", () => { VERCEL_GIT_COMMIT_SHA: "testingsha", VERCEL_GIT_REPO_SLUG: "testRepo", VERCEL_GIT_REPO_OWNER: "testOrg", + VERCEL_GIT_COMMIT_REF: "super-cool-branch", }, }; const expected: ProviderServiceParams = { - branch: "", + branch: "super-cool-branch", build: "", buildURL: "", commit: "testingsha", @@ -76,6 +77,7 @@ describe("Vercel Params", () => { VERCEL_GIT_COMMIT_SHA: "testingsha", VERCEL_GIT_REPO_SLUG: "testRepo", VERCEL_GIT_REPO_OWNER: "testOrg", + VERCEL_GIT_COMMIT_REF: "super-cool-branch", }, };