fix: git branch name (#771)

pull/775/head
三咲智子 Kevin Deng 2023-01-04 21:41:48 +08:00 zatwierdzone przez GitHub
rodzic 8a66174477
commit 9a167ee990
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 11 dodań i 3 usunięć

Wyświetl plik

@ -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 }
}

Wyświetl plik

@ -15,7 +15,7 @@ export const pwa: VitePWANuxtOptions = {
includeManifestIcons: false,
manifest: async () => {
const { env } = await getEnv()
const envName = `${env !== 'release' ? '' : ` (${env})`}`
const envName = `${env === 'release' ? '' : ` (${env})`}`
return {
scope: '/',
id: '/',

Wyświetl plik

@ -36,7 +36,7 @@ const handleShowCommit = () => {
<template #content>
<div font-mono>
<span>{{ buildInfo.env === 'release' ? `v${buildInfo.version}` : buildInfo.env }}</span>
<span v-if="showCommit"> ({{ buildInfo.commit.slice(0, 7) }})</span>
<span v-if="showCommit"> ({{ buildInfo.commit.slice(0, 7) }}@{{ buildInfo.branch }})</span>
</div>
</template>
</SettingsItem>