fix: git branch name (#771)
This commit is contained in:
parent
8a66174477
commit
9a167ee990
3 changed files with 11 additions and 3 deletions
|
@ -11,6 +11,14 @@ export { version } from '../package.json'
|
|||
*/
|
||||
export const isPR = process.env.PULL_REQUEST === 'true'
|
||||
|
||||
/**
|
||||
* Environment variable `BRANCH` provided by Netlify.
|
||||
* @see {@link https://docs.netlify.com/configure-builds/environment-variables/#git-metadata}
|
||||
*
|
||||
* Git branch
|
||||
*/
|
||||
export const gitBranch = process.env.BRANCH
|
||||
|
||||
/**
|
||||
* Environment variable `CONTEXT` provided by Netlify.
|
||||
* @see {@link https://docs.netlify.com/configure-builds/environment-variables/#build-metadata}
|
||||
|
@ -21,7 +29,7 @@ export const isPreview = isPR || process.env.CONTEXT === 'deploy-preview' || pro
|
|||
|
||||
const git = Git()
|
||||
export const getGitInfo = async () => {
|
||||
const branch = await git.revparse(['--abbrev-ref', 'HEAD'])
|
||||
const branch = gitBranch || await git.revparse(['--abbrev-ref', 'HEAD'])
|
||||
const commit = await git.revparse(['HEAD'])
|
||||
return { branch, commit }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue