From 0ebecca1e6edd31ec95c5d8be3d02814fb39179f Mon Sep 17 00:00:00 2001 From: Gusted Date: Sat, 11 Nov 2023 12:15:26 +0100 Subject: [PATCH] [CLEANUP] Reuse ForgejoVersion variable - Resolves https://codeberg.org/forgejo/forgejo/issues/1226 (cherry picked from commit e383b70109325833034dd0593727e5eec3acf92d) (cherry picked from commit 029cfa34de06e7706c3f85134468f2faadf30a21) (cherry picked from commit 81392b8c55b2f5893a3222c521f697d1d53adbb2) --- Makefile | 2 +- routers/api/forgejo/v1/forgejo.go | 5 ++--- tests/integration/api_forgejo_version_test.go | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 400cc9d097..ac48a050d9 100644 --- a/Makefile +++ b/Makefile @@ -97,7 +97,7 @@ VERSION = ${GITEA_VERSION} # SemVer FORGEJO_VERSION := 6.0.0+0-gitea-1.21.0 -LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)" -X "code.gitea.io/gitea/routers/api/forgejo/v1.ForgejoVersion=$(FORGEJO_VERSION)" -X "main.ForgejoVersion=$(FORGEJO_VERSION)" +LDFLAGS := $(LDFLAGS) -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)" -X "main.ForgejoVersion=$(FORGEJO_VERSION)" LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64 diff --git a/routers/api/forgejo/v1/forgejo.go b/routers/api/forgejo/v1/forgejo.go index 54ab19d7bd..0f1f4f1932 100644 --- a/routers/api/forgejo/v1/forgejo.go +++ b/routers/api/forgejo/v1/forgejo.go @@ -6,6 +6,7 @@ import ( "net/http" "code.gitea.io/gitea/modules/json" + "code.gitea.io/gitea/modules/setting" ) type Forgejo struct{} @@ -16,9 +17,7 @@ func NewForgejo() *Forgejo { return &Forgejo{} } -var ForgejoVersion = "development" - func (f *Forgejo) GetVersion(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) - _ = json.NewEncoder(w).Encode(Version{&ForgejoVersion}) + _ = json.NewEncoder(w).Encode(Version{&setting.ForgejoVersion}) } diff --git a/tests/integration/api_forgejo_version_test.go b/tests/integration/api_forgejo_version_test.go index b8b8de8ee1..b59afcbb10 100644 --- a/tests/integration/api_forgejo_version_test.go +++ b/tests/integration/api_forgejo_version_test.go @@ -7,7 +7,7 @@ import ( "net/http" "testing" - "code.gitea.io/gitea/routers/api/forgejo/v1" + v1 "code.gitea.io/gitea/routers/api/forgejo/v1" "code.gitea.io/gitea/tests" "github.com/stretchr/testify/assert" @@ -21,5 +21,5 @@ func TestAPIForgejoVersion(t *testing.T) { var version v1.Version DecodeJSON(t, resp, &version) - assert.Equal(t, "development", *version.Version) + assert.Equal(t, "1.0.0", *version.Version) }