Skip to content

Commit 364e749

Browse files
committed
prev: remove commit
1 parent 2928757 commit 364e749

File tree

3 files changed

+1
-51
lines changed

3 files changed

+1
-51
lines changed

next.config.js

+1-41
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,11 @@
1-
/* eslint-disable react-hooks/rules-of-hooks,no-undef */
2-
import { execSync } from 'node:child_process';
3-
41
/**
52
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
63
* for Docker builds.
74
*/
85
await import('./src/env.js');
9-
10-
const repoInfo = useLocalGitRepo();
11-
126
/** @type {import("next").NextConfig} */
137
const config = {
14-
env: {
15-
NEXT_PUBLIC_COMMIT_HASH: repoInfo?.hash,
16-
NEXT_PUBLIC_COMMIT_URL: repoInfo?.url,
17-
},
8+
env: {},
189
};
1910

2011
export default config;
21-
22-
function useLocalGitRepo() {
23-
if (process.env.VERCEL) {
24-
const { VERCEL_GIT_PROVIDER, VERCEL_GIT_REPO_SLUG, VERCEL_GIT_REPO_OWNER } = process.env;
25-
26-
switch (VERCEL_GIT_PROVIDER) {
27-
case 'github': {
28-
return {
29-
hash: process.env.VERCEL_GIT_COMMIT_SHA,
30-
url: `https://github.com/${VERCEL_GIT_REPO_OWNER}/${VERCEL_GIT_REPO_SLUG}/commit/${process.env.VERCEL_GIT_COMMIT_SHA}`,
31-
};
32-
}
33-
}
34-
}
35-
36-
try {
37-
const currentBranch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
38-
const remoteName = execSync(`git config branch.${currentBranch}.remote`).toString().trim();
39-
let remoteUrl = execSync(`git remote get-url ${remoteName}`).toString().trim();
40-
41-
const commitHash = execSync('git rev-parse HEAD').toString().trim();
42-
if (remoteUrl.startsWith('git@'))
43-
remoteUrl = remoteUrl.replace(':', '/').replace('git@', 'https://').replace('.git', '');
44-
else if (remoteUrl.endsWith('.git')) remoteUrl = remoteUrl.slice(0, -4);
45-
46-
return { hash: commitHash, url: `${remoteUrl}/commit/${commitHash}` };
47-
} catch (_error) {
48-
console.error('Failed to fetch repo info:', _error);
49-
return null;
50-
}
51-
}

src/app/page.tsx

-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { env } from '@/env';
2-
31
export default function Home() {
42
return (
53
<div className="flex h-dvh w-full flex-col items-center justify-center text-center">
@@ -10,9 +8,6 @@ export default function Home() {
108
<br />
119
looking forward to seeing you again soon!
1210
</span>
13-
{env?.NEXT_PUBLIC_COMMIT_HASH && (
14-
<span className="text-xs">{`version commit: ${env.NEXT_PUBLIC_COMMIT_HASH}`}</span>
15-
)}
1611
</div>
1712
);
1813
}

src/env.js

-5
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ export const env = createEnv({
1919
*/
2020
client: {
2121
NEXT_PUBLIC_NODE_ENV: z.enum(['development', 'test', 'production']),
22-
NEXT_PUBLIC_COMMIT_HASH: z.string().optional(),
23-
NEXT_PUBLIC_COMMIT_URL: z.string().optional(),
2422
},
2523

2624
/**
@@ -30,9 +28,6 @@ export const env = createEnv({
3028
runtimeEnv: {
3129
NODE_ENV: process.env.NODE_ENV,
3230
NEXT_PUBLIC_NODE_ENV: process.env.NODE_ENV,
33-
34-
NEXT_PUBLIC_COMMIT_HASH: (process.env.NEXT_PUBLIC_COMMIT_HASH ?? '').slice(0, 8),
35-
NEXT_PUBLIC_COMMIT_URL: process.env.NEXT_PUBLIC_COMMIT_URL,
3631
},
3732
/**
3833
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially

0 commit comments

Comments
 (0)