mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-21 17:05:22 +03:00
refactor: get short commit
This commit is contained in:
parent
f98c667613
commit
bcf0965795
6 changed files with 11 additions and 8 deletions
|
@ -14,7 +14,7 @@ const build = useBuildInfo()
|
|||
<p>
|
||||
<i18n-t keypath="help.build_preview.desc1">
|
||||
<NuxtLink :href="`https://github.com/elk-zone/elk/commit/${build.commit}`" target="_blank" text-rose hover:underline>
|
||||
<code>{{ build.commit.slice(0, 7) }}</code>
|
||||
<code>{{ build.shortCommit }}</code>
|
||||
</NuxtLink>
|
||||
</i18n-t>
|
||||
</p>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup lang="ts">
|
||||
const buildInfo = useAppConfig().buildInfo
|
||||
const buildInfo = useBuildInfo()
|
||||
const timeAgoOptions = useTimeAgoOptions()
|
||||
|
||||
const userSettings = useUserSettings()
|
||||
|
@ -65,7 +65,7 @@ function toggleDark() {
|
|||
target="_blank"
|
||||
font-mono
|
||||
>
|
||||
{{ buildInfo.commit.slice(0, 7) }}
|
||||
{{ buildInfo.shortCommit }}
|
||||
</NuxtLink>
|
||||
</template>
|
||||
</div>
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -10,11 +10,12 @@ export default defineNuxtModule({
|
|||
name: 'elk:build-env',
|
||||
},
|
||||
async setup(_options, nuxt) {
|
||||
const { env, commit, branch } = await getEnv()
|
||||
const { env, commit, shortCommit, branch } = await getEnv()
|
||||
const buildInfo: BuildInfo = {
|
||||
version,
|
||||
time: +Date.now(),
|
||||
commit,
|
||||
shortCommit,
|
||||
branch,
|
||||
env,
|
||||
}
|
||||
|
|
|
@ -41,7 +41,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) }}@{{ buildInfo.branch }})</span>
|
||||
<span v-if="showCommit"> ({{ buildInfo.shortCommit }}@{{ buildInfo.branch }})</span>
|
||||
</div>
|
||||
</template>
|
||||
</SettingsItem>
|
||||
|
|
|
@ -72,6 +72,7 @@ export interface ErrorDialogData {
|
|||
export interface BuildInfo {
|
||||
version: string
|
||||
commit: string
|
||||
shortCommit: string
|
||||
time: number
|
||||
branch: string
|
||||
env: 'preview' | 'canary' | 'dev' | 'release'
|
||||
|
|
Loading…
Reference in a new issue