diff --git a/src/pages/settings/Settings.tsx b/src/pages/settings/Settings.tsx index a8713521..58be985a 100644 --- a/src/pages/settings/Settings.tsx +++ b/src/pages/settings/Settings.tsx @@ -20,7 +20,7 @@ import { User } from "@styled-icons/feather"; import { Megaphone } from "@styled-icons/bootstrap"; -import { GIT_REVISION, REPO_URL } from "../../revision"; +import { GIT_BRANCH, GIT_REVISION, REPO_URL } from "../../revision"; import LineDivider from "../../components/ui/LineDivider"; import RequiresOnline from "../../context/revoltjs/RequiresOnline"; import ButtonItem from "../../components/navigation/items/ButtonItem"; @@ -147,8 +147,12 @@ export default function Settings() { { GIT_REVISION.substr(0, 7) } + {` `} + + ({ GIT_BRANCH }) + - Stable {APP_VERSION} + { GIT_BRANCH === 'production' ? 'Stable' : 'Nightly' } {APP_VERSION} API: {client.configuration?.revolt ?? "N/A"} revolt.js: {LIBRARY_VERSION} diff --git a/src/revision.ts b/src/revision.ts index ab519af0..e01dcdda 100644 --- a/src/revision.ts +++ b/src/revision.ts @@ -1,2 +1,3 @@ -export const GIT_REVISION = '__GIT_REVISION__'; export const REPO_URL = 'https://gitlab.insrt.uk/revolt/revite/-/commit'; +export const GIT_REVISION = '__GIT_REVISION__'; +export const GIT_BRANCH: string = '__GIT_BRANCH__'; diff --git a/vite.config.ts b/vite.config.ts index e797ce48..d3b5762a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -19,6 +19,20 @@ function getGitRevision() { } } +function getGitBranch() { + try { + const rev = readFileSync('.git/HEAD').toString().trim(); + if (rev.indexOf(':') === -1) { + return 'DETACHED'; + } else { + return rev.split('/').pop(); + } + } catch (err) { + console.error('Failed to get Git branch.'); + return '?'; + } +} + function getVersion() { return readFileSync('VERSION').toString(); } @@ -55,6 +69,7 @@ export default defineConfig({ }), replace({ __GIT_REVISION__: getGitRevision(), + __GIT_BRANCH__: getGitBranch(), __APP_VERSION__: getVersion(), preventAssignment: true })