From 27c79e5ba9c8bc205245158745889493d8919644 Mon Sep 17 00:00:00 2001
From: Florent Gluck <florent.gluck@hesge.ch>
Date: Tue, 25 Mar 2025 14:29:08 +0100
Subject: [PATCH] Fixed inconsistencies in nexus-exam, notably buildversion

---
 nexus-exam/Makefile                |  9 +++------
 nexus-exam/buildversion/version.go | 15 +++++++++++++++
 nexus-exam/go.mod                  |  2 +-
 nexus-exam/nexus-exam.go           |  2 +-
 4 files changed, 20 insertions(+), 8 deletions(-)
 create mode 100644 nexus-exam/buildversion/version.go

diff --git a/nexus-exam/Makefile b/nexus-exam/Makefile
index 4f672eed..7b5d64f0 100644
--- a/nexus-exam/Makefile
+++ b/nexus-exam/Makefile
@@ -1,9 +1,6 @@
-# ------------------------------------
-# Common variables
-# ------------------------------------
 CURRENT_DATE=$(shell eval "date -u +'%Y-%m-%d at %H:%M:%S'")
 GIT_COMMIT=$(shell eval "git rev-parse HEAD")
-BUILD_FLAGS=-ldflags="-X 'gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/common/buildversion.buildDate=$(CURRENT_DATE)' -X 'gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/common/buildversion.gitCommit=$(GIT_COMMIT)'"
+BUILD_FLAGS=-ldflags="-X 'gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/nexus-exam/buildversion.buildDate=$(CURRENT_DATE)' -X 'gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/nexus-exam/buildversion.gitCommit=$(GIT_COMMIT)'"
 BUILD_DIR=build
 BUILD_DIR_ABS=$(PWD)/$(BUILD_DIR)
 NEXUSH_BINARY=nexush
@@ -11,7 +8,7 @@ NEXUSCLI_BINARY=nexus-cli
 NEXUS_EXAM_BINARY=nexus-exam
 GENPWD_BINARY=genpwd
 
-BUILD_CLIENT_FLAGS=-buildvcs=false
+BUILD_FLAGS+=-buildvcs=false
 # To force a full recompile:
 # BUILD_FLAGS=build -a
 
@@ -62,7 +59,7 @@ $(BUILD_DIR): check_server_var check_nexus_exam_vars
 	@echo -n '$(value EXAM_PWD)' > $(NEXUS_EXAM_PWD_CREDS_FILE)
 	@echo "OK"
 	@echo "[Building nexus-exam into $(BUILD_DIR) directory]"
-	go build $(BUILD_FLAGS) $(BUILD_CLIENT_FLAGS) -o $(BUILD_DIR)/$(NEXUS_EXAM_BINARY)
+	go build $(BUILD_FLAGS) -o $(BUILD_DIR)/$(NEXUS_EXAM_BINARY)
 	@strip -s $(BUILD_DIR)/$(NEXUS_EXAM_BINARY)
 	@echo "OK"
 #	@upx -q $(NEXUS_EXAM_BINARY)
diff --git a/nexus-exam/buildversion/version.go b/nexus-exam/buildversion/version.go
new file mode 100644
index 00000000..f23cfbe7
--- /dev/null
+++ b/nexus-exam/buildversion/version.go
@@ -0,0 +1,15 @@
+package buildversion
+
+var (
+	// These variables are replaced by ldflags at build time
+	gitCommit = "n/a"
+	buildDate = "n/a"
+)
+
+func GitCommit() string {
+	return gitCommit
+}
+
+func BuildDate() string {
+	return buildDate
+}
diff --git a/nexus-exam/go.mod b/nexus-exam/go.mod
index ed126946..0e91f722 100644
--- a/nexus-exam/go.mod
+++ b/nexus-exam/go.mod
@@ -5,12 +5,12 @@ go 1.22.2
 require (
 	fyne.io/fyne/v2 v2.5.5
 	gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client v0.0.0-20250320135605-9ac7ec3df57a
-	gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/common v0.0.0-20250320135605-9ac7ec3df57a
 	gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient v0.0.0-20250320133059-1f3e69fbd8f8
 )
 
 require (
 	fyne.io/systray v1.11.0 // indirect
+	gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/common v0.0.0-20250320135605-9ac7ec3df57a // indirect
 	github.com/BurntSushi/toml v1.4.0 // indirect
 	github.com/davecgh/go-spew v1.1.1 // indirect
 	github.com/fredbi/uri v1.1.0 // indirect
diff --git a/nexus-exam/nexus-exam.go b/nexus-exam/nexus-exam.go
index ff5ea85d..2904ebd2 100644
--- a/nexus-exam/nexus-exam.go
+++ b/nexus-exam/nexus-exam.go
@@ -15,9 +15,9 @@ import (
 	"fyne.io/fyne/v2/theme"
 	"fyne.io/fyne/v2/widget"
 	u "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/client/utils"
-	"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/common/buildversion"
 	nc "gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/nexusclient"
 	"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/libclient/version"
+	"gitedu.hesge.ch/flg_projects/nexus_vdi/nexus/nexus-exam/buildversion"
 )
 
 const (
-- 
GitLab