|
1 |
| -/* eslint-disable react-hooks/rules-of-hooks,no-undef */ |
2 |
| -import { execSync } from 'node:child_process'; |
3 |
| - |
4 | 1 | /**
|
5 | 2 | * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
|
6 | 3 | * for Docker builds.
|
7 | 4 | */
|
8 | 5 | await import('./src/env.js');
|
9 |
| - |
10 |
| -const repoInfo = useLocalGitRepo(); |
11 |
| - |
12 | 6 | /** @type {import("next").NextConfig} */
|
13 | 7 | const config = {
|
14 |
| - env: { |
15 |
| - NEXT_PUBLIC_COMMIT_HASH: repoInfo?.hash, |
16 |
| - NEXT_PUBLIC_COMMIT_URL: repoInfo?.url, |
17 |
| - }, |
| 8 | + env: {}, |
18 | 9 | };
|
19 | 10 |
|
20 | 11 | 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 |
| -} |
0 commit comments