Skip to content

Commit 834dd14

Browse files
authored
fix: Manually create Git slug for Vercel (#77)
Adjust Vercel env helper to manually create full Git slug.
1 parent f0fd4ce commit 834dd14

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

.changeset/four-houses-drive.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+
Update Vercel env helper function to create full git slug

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// VERCEL ENV DOCS
2+
// https://vercel.com/docs/projects/environment-variables/system-environment-variables
3+
14
import {
25
type ProviderEnvs,
36
type ProviderServiceParams,
@@ -48,7 +51,15 @@ function _getSHA(inputs: ProviderUtilInputs): string {
4851
function _getSlug(inputs: ProviderUtilInputs): string {
4952
const { args, envs } = inputs;
5053
if (args?.slug && args?.slug !== "") return args?.slug;
51-
return envs?.VERCEL_GIT_REPO_SLUG ?? "";
54+
const owner = envs?.VERCEL_GIT_REPO_OWNER ?? "";
55+
const repo = envs?.VERCEL_GIT_REPO_SLUG ?? "";
56+
57+
let slug = "";
58+
if (owner && repo) {
59+
slug = `${owner}/${repo}`;
60+
}
61+
62+
return slug;
5263
}
5364

5465
// eslint-disable-next-line @typescript-eslint/require-await

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ describe("Vercel Params", () => {
4242
envs: {
4343
VERCEL: "true",
4444
VERCEL_GIT_COMMIT_SHA: "testingsha",
45-
VERCEL_GIT_REPO_SLUG: "testOrg/testRepo",
45+
VERCEL_GIT_REPO_SLUG: "testRepo",
46+
VERCEL_GIT_REPO_OWNER: "testOrg",
4647
},
4748
};
4849

@@ -73,7 +74,8 @@ describe("Vercel Params", () => {
7374
envs: {
7475
VERCEL: "true",
7576
VERCEL_GIT_COMMIT_SHA: "testingsha",
76-
VERCEL_GIT_REPO_SLUG: "other-org/testRepo",
77+
VERCEL_GIT_REPO_SLUG: "testRepo",
78+
VERCEL_GIT_REPO_OWNER: "testOrg",
7779
},
7880
};
7981

0 commit comments

Comments
 (0)