fix: Do not require Git for development (#3015)

This commit is contained in:
Wladimir Palant 2024-10-24 02:50:30 +02:00 committed by GitHub
parent 83fce5d8a1
commit 2c8307b3d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -29,9 +29,30 @@ export const isPreview = isPR || process.env.CONTEXT === 'deploy-preview' || pro
const git = Git() const git = Git()
export async function getGitInfo() { export async function getGitInfo() {
const branch = gitBranch || await git.revparse(['--abbrev-ref', 'HEAD']) let branch
const commit = await git.revparse(['HEAD']) try {
const shortCommit = await git.revparse(['--short=7', 'HEAD']) branch = gitBranch || await git.revparse(['--abbrev-ref', 'HEAD'])
}
catch {
branch = 'unknown'
}
let commit
try {
commit = await git.revparse(['HEAD'])
}
catch {
commit = 'unknown'
}
let shortCommit
try {
shortCommit = await git.revparse(['--short=7', 'HEAD'])
}
catch {
shortCommit = 'unknown'
}
return { branch, commit, shortCommit } return { branch, commit, shortCommit }
} }