removed the Git_Commit from system information output

it is not easyly to manage since both backend and frontend are running in compiled packages  in production and we have no git repository underneath
This commit is contained in:
2026-01-17 08:07:26 +01:00
parent 56e761fed1
commit d4341a4730
13 changed files with 11 additions and 142 deletions
+4 -2
View File
@@ -4,7 +4,9 @@ import (
"github.com/gin-gonic/gin"
)
// Versionsinfo returns version and git commit information
// Versionsinfo returns version information
func Versionsinfo(c *gin.Context) {
c.JSON(200, GetInfo())
c.JSON(200, gin.H{
"version": GetVersion(),
})
}
-51
View File
@@ -3,58 +3,7 @@ package config
// Version is the application version
const Version = "0.1.37"
var (
// GitCommit will be set by build flags or detected at runtime
GitCommit = "unknown"
)
// init detects git commit if not set during build
func init() {
/*
if GitCommit == "" {
// Try environment variable first
if envCommit := os.Getenv("GIT_COMMIT"); envCommit != "" {
GitCommit = envCommit
} else {
// Try to detect from git command
GitCommit = detectGitCommit()
}
}
*/
}
/*
// detectGitCommit tries to get the current git commit hash
func detectGitCommit() string {
cmd := exec.Command("git", "rev-parse", "--short", "HEAD")
output, err := cmd.Output()
if err != nil {
return "unknown"
}
return strings.TrimSpace(string(output))
}
*/
// GetVersion returns the current application version
func GetVersion() string {
return Version
}
/*
// GetGitCommit returns the git commit hash
func GetGitCommit() string {
return GitCommit
}
*/
// Info contains version information
type Info struct {
Version string `json:"version"`
GitCommit string `json:"gitCommit"`
}
// GetInfo returns version information as a struct
func GetInfo() Info {
return Info{
Version: Version,
GitCommit: GitCommit,
}
}
-28
View File
@@ -13,31 +13,3 @@ func TestGetVersion(t *testing.T) {
t.Errorf("Expected version %s, got %s", Version, version)
}
}
/*
func TestGetGitCommit(t *testing.T) {
commit := GetGitCommit()
if commit == "" {
t.Error("GitCommit should not be empty")
}
// Should be either "unknown" or a valid git hash
if commit != "unknown" && len(commit) < 7 {
t.Errorf("Invalid git commit format: %s", commit)
}
}
*/
func TestGetInfo(t *testing.T) {
info := GetInfo()
if info.Version == "" {
t.Error("Info.Version should not be empty")
}
if info.GitCommit == "" {
t.Error("Info.GitCommit should not be empty")
}
if info.Version != Version {
t.Errorf("Expected info.Version %s, got %s", Version, info.Version)
}
}
-1
View File
@@ -20,7 +20,6 @@ API_PORT=8180
BASE_URL="http://localhost:5173"
TEMPLATES_DIR=./templates
EXPORT_TEMP_DIR=./export_temp
GIT_COMMIT=d0c177b
LOG_LEVEL=debug
COMPOSE_PROJECT_NAME=bamort
CHROME_BIN="/usr/bin/chromium"
-2
View File
@@ -32,7 +32,6 @@ type VersionResponse struct {
// BackendInfo contains backend version information
type BackendInfo struct {
Version string `json:"version"`
Commit string `json:"commit"`
}
// DatabaseInfo contains database version information
@@ -86,7 +85,6 @@ func VersionHandler(db *gorm.DB) gin.HandlerFunc {
// Get backend version info
backendInfo := BackendInfo{
Version: config.GetVersion(),
Commit: config.GitCommit,
}
// Get database version info
-1
View File
@@ -193,7 +193,6 @@ func TestVersionHandler_Success(t *testing.T) {
backend, ok := result["backend"].(map[string]interface{})
assert.True(t, ok)
assert.Equal(t, config.GetVersion(), backend["version"])
assert.NotNil(t, backend["commit"])
// Check database section
database, ok := result["database"].(map[string]interface{})
+1 -2
View File
@@ -12,8 +12,7 @@ fi
cd "$(dirname "$0")"
# Get current git commit
export GIT_COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
echo "📝 Git Commit: $GIT_COMMIT"
echo "📦 Building and starting development containers..."
+1 -1
View File
@@ -88,7 +88,7 @@ Setting up is quite easy. I both cases I would suggest docker
* run ./docker/start-prd.sh
* test https://backend.domain.de/api/public/version
should responde like this: {"version":"0.1.30","gitCommit":"unknown"}
should responde like this: {"version":"0.1.30"}
## Development Environment
+2 -33
View File
@@ -35,30 +35,16 @@ And `/frontend/package.json`:
}
```
## Git Commit Information
The git commit is injected via environment variable:
- Set `VITE_GIT_COMMIT` in `.env` or at build time
- Falls back to "unknown" if not set
Example `.env`:
```bash
VITE_GIT_COMMIT=d0c177b
```
## Usage in Components
```javascript
import { getVersion, getGitCommit, getVersionInfo } from '@/version'
import { getVersion, getVersionInfo } from '@/version'
// Get version string
const version = getVersion() // "0.1.30"
// Get git commit
const commit = getGitCommit() // "d0c177b" or "unknown"
// Get full info object
const info = getVersionInfo() // { version: "0.1.30", gitCommit: "d0c177b" }
const info = getVersionInfo() // { version: "0.1.30" }
```
## Landing Page Display
@@ -68,20 +54,3 @@ The landing page shows both:
- **Backend Version**: Fetched from `/api/public/version`
This allows users to see if frontend and backend are in sync.
## Build-time Version Injection
To inject git commit at build time, update `vite.config.js`:
```javascript
import { defineConfig } from 'vite'
import { execSync } from 'child_process'
const gitCommit = execSync('git rev-parse --short HEAD').toString().trim()
export default defineConfig({
define: {
'import.meta.env.VITE_GIT_COMMIT': JSON.stringify(gitCommit)
}
})
```
+1 -9
View File
@@ -1,20 +1,12 @@
// Frontend version information
export const VERSION = '0.1.29'
// Git commit will be injected at build time or detected from env
export const GIT_COMMIT = import.meta.env.VITE_GIT_COMMIT || 'unknown'
export function getVersion() {
return VERSION
}
export function getGitCommit() {
return GIT_COMMIT
}
export function getVersionInfo() {
return {
version: VERSION,
gitCommit: GIT_COMMIT
version: VERSION
}
}
+1 -4
View File
@@ -45,16 +45,14 @@
<script>
import axios from 'axios'
import { getVersion, getGitCommit } from '../version'
import { getVersion } from '../version'
export default {
name: "LandingView",
data() {
return {
frontendVersion: getVersion(),
frontendCommit: getGitCommit(),
backendVersion: "Loading...",
backendCommit: "Loading...",
githubUrl: "https://github.com/Bardioc26/bamort",
retryCount: 0,
maxRetries: 24,
@@ -85,7 +83,6 @@ export default {
if (response.data) {
this.backendVersion = response.data.version || "Unknown"
this.backendCommit = response.data.gitCommit || "Unknown"
if (this.retryInterval) {
clearInterval(this.retryInterval)
this.retryInterval = null
+1 -7
View File
@@ -19,13 +19,11 @@
<div class="card">
<h4>{{ $t('systemInfo.frontend') }}</h4>
<p><strong>{{ $t('systemInfo.version') }}:</strong> {{ frontendVersion }}</p>
<p><strong>{{ $t('systemInfo.commit') }}:</strong> <code>{{ frontendCommit }}</code></p>
</div>
<div class="card">
<h4>{{ $t('systemInfo.backend') }}</h4>
<p><strong>{{ $t('systemInfo.version') }}:</strong> {{ backendVersion }}</p>
<p><strong>{{ $t('systemInfo.commit') }}:</strong> <code>{{ backendCommit }}</code></p>
<p><strong>{{ $t('systemInfo.status') }}:</strong>
<span :class="statusClass">{{ statusText }}</span>
</p>
@@ -109,16 +107,14 @@
<script>
import axios from 'axios'
import { getVersion, getGitCommit } from '../version'
import { getVersion } from '../version'
export default {
name: "SystemInfoView",
data() {
return {
frontendVersion: getVersion(),
frontendCommit: getGitCommit(),
backendVersion: "Loading...",
backendCommit: "Loading...",
githubUrl: "https://github.com/Bardioc26/bamort",
koFiUrl: "https://ko-fi.com/bardioc26",
}
@@ -152,12 +148,10 @@ export default {
if (response.data) {
this.backendVersion = response.data.version || "Unknown"
this.backendCommit = response.data.gitCommit || "Unknown"
}
} catch (error) {
console.warn("Could not fetch backend version:", error)
this.backendVersion = "Unavailable"
this.backendCommit = "N/A"
}
}
}
-1
View File
@@ -20,7 +20,6 @@ API_PORT=8180
BASE_URL="http://localhost:5173"
TEMPLATES_DIR=./templates
EXPORT_TEMP_DIR=./export_temp
GIT_COMMIT=d0c177b
LOG_LEVEL=debug
COMPOSE_PROJECT_NAME=bamort
CHROME_BIN="/usr/bin/chromium"