Skip to content

Commit

Permalink
fix: Support grabbing branch in Vercel (#80)
Browse files Browse the repository at this point in the history
Grab the branch in Vercel env helper.
  • Loading branch information
nicholas-codecov authored Feb 23, 2024
1 parent 7bc7183 commit 94a46aa
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .changeset/early-phones-prove.md
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions packages/bundler-plugin-core/src/utils/providers/Vercel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
},
};

Expand Down

0 comments on commit 94a46aa

Please sign in to comment.