refactor: get short commit
This commit is contained in:
parent
f98c667613
commit
bcf0965795
6 changed files with 11 additions and 8 deletions
|
@ -31,11 +31,12 @@ const git = Git()
|
|||
export const getGitInfo = async () => {
|
||||
const branch = gitBranch || await git.revparse(['--abbrev-ref', 'HEAD'])
|
||||
const commit = await git.revparse(['HEAD'])
|
||||
return { branch, commit }
|
||||
const shortCommit = await git.revparse(['--short=7', 'HEAD'])
|
||||
return { branch, commit, shortCommit }
|
||||
}
|
||||
|
||||
export const getEnv = async () => {
|
||||
const { commit, branch } = await getGitInfo()
|
||||
const { commit, shortCommit, branch } = await getGitInfo()
|
||||
const env = isDevelopment
|
||||
? 'dev'
|
||||
: isPreview
|
||||
|
@ -43,5 +44,5 @@ export const getEnv = async () => {
|
|||
: branch === 'main'
|
||||
? 'canary'
|
||||
: 'release'
|
||||
return { commit, branch, env } as const
|
||||
return { commit, shortCommit, branch, env } as const
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue