Skip to content

Commit

Permalink
fix: Manually create Git slug for Vercel (#77)
Browse files Browse the repository at this point in the history
Adjust Vercel env helper to manually create full Git slug.
  • Loading branch information
nicholas-codecov authored Feb 22, 2024
1 parent f0fd4ce commit 834dd14
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .changeset/four-houses-drive.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
---

Update Vercel env helper function to create full git slug
13 changes: 12 additions & 1 deletion packages/bundler-plugin-core/src/utils/providers/Vercel.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// VERCEL ENV DOCS
// https://vercel.com/docs/projects/environment-variables/system-environment-variables

import {
type ProviderEnvs,
type ProviderServiceParams,
Expand Down Expand Up @@ -48,7 +51,15 @@ function _getSHA(inputs: ProviderUtilInputs): string {
function _getSlug(inputs: ProviderUtilInputs): string {
const { args, envs } = inputs;
if (args?.slug && args?.slug !== "") return args?.slug;
return envs?.VERCEL_GIT_REPO_SLUG ?? "";
const owner = envs?.VERCEL_GIT_REPO_OWNER ?? "";
const repo = envs?.VERCEL_GIT_REPO_SLUG ?? "";

let slug = "";
if (owner && repo) {
slug = `${owner}/${repo}`;
}

return slug;
}

// eslint-disable-next-line @typescript-eslint/require-await
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ describe("Vercel Params", () => {
envs: {
VERCEL: "true",
VERCEL_GIT_COMMIT_SHA: "testingsha",
VERCEL_GIT_REPO_SLUG: "testOrg/testRepo",
VERCEL_GIT_REPO_SLUG: "testRepo",
VERCEL_GIT_REPO_OWNER: "testOrg",
},
};

Expand Down Expand Up @@ -73,7 +74,8 @@ describe("Vercel Params", () => {
envs: {
VERCEL: "true",
VERCEL_GIT_COMMIT_SHA: "testingsha",
VERCEL_GIT_REPO_SLUG: "other-org/testRepo",
VERCEL_GIT_REPO_SLUG: "testRepo",
VERCEL_GIT_REPO_OWNER: "testOrg",
},
};

Expand Down

0 comments on commit 834dd14

Please sign in to comment.