mirror of
https://github.com/elk-zone/elk.git
synced 2024-12-03 17:21:46 +03:00
fix: Do not require Git for development (#3015)
This commit is contained in:
parent
83fce5d8a1
commit
2c8307b3d8
1 changed files with 24 additions and 3 deletions
|
@ -29,9 +29,30 @@ export const isPreview = isPR || process.env.CONTEXT === 'deploy-preview' || pro
|
|||
|
||||
const git = Git()
|
||||
export async function getGitInfo() {
|
||||
const branch = gitBranch || await git.revparse(['--abbrev-ref', 'HEAD'])
|
||||
const commit = await git.revparse(['HEAD'])
|
||||
const shortCommit = await git.revparse(['--short=7', 'HEAD'])
|
||||
let branch
|
||||
try {
|
||||
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 }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue