forked from NYANDEV/forgejo
[CLEANUP] Reuse ForgejoVersion variable
- Resolves https://codeberg.org/forgejo/forgejo/issues/1226 (cherry picked from commite383b70109
) (cherry picked from commit029cfa34de
) (cherry picked from commit 81392b8c55b2f5893a3222c521f697d1d53adbb2) (cherry picked from commit 0ebecca1e6edd31ec95c5d8be3d02814fb39179f) (cherry picked from commit aff135418d96b1f7418e55882ee0bbdbf2b04c5e) (cherry picked from commit b5982f5008a0a60d0cf874edbe281c3f73b69e97) (cherry picked from commit 00f86df8f4f4072eb083426e807a9164be0dbc38) (cherry picked from commit 178908c047b9a13a7b61e90490d525ddbeae45e8) (cherry picked from commit 9cc57d1b3f48a9f530fb761bd70d224d069ea1eb)
This commit is contained in:
parent
8195ba06d5
commit
dc80ba9a97
3 changed files with 5 additions and 6 deletions
2
Makefile
2
Makefile
|
@ -97,7 +97,7 @@ VERSION = ${GITEA_VERSION}
|
||||||
# SemVer
|
# SemVer
|
||||||
FORGEJO_VERSION := 5.0.0+0-gitea-1.20.0
|
FORGEJO_VERSION := 5.0.0+0-gitea-1.20.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
|
LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"code.gitea.io/gitea/modules/json"
|
"code.gitea.io/gitea/modules/json"
|
||||||
|
"code.gitea.io/gitea/modules/setting"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Forgejo struct{}
|
type Forgejo struct{}
|
||||||
|
@ -16,9 +17,7 @@ func NewForgejo() *Forgejo {
|
||||||
return &Forgejo{}
|
return &Forgejo{}
|
||||||
}
|
}
|
||||||
|
|
||||||
var ForgejoVersion = "development"
|
|
||||||
|
|
||||||
func (f *Forgejo) GetVersion(w http.ResponseWriter, r *http.Request) {
|
func (f *Forgejo) GetVersion(w http.ResponseWriter, r *http.Request) {
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
_ = json.NewEncoder(w).Encode(Version{&ForgejoVersion})
|
_ = json.NewEncoder(w).Encode(Version{&setting.ForgejoVersion})
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"code.gitea.io/gitea/routers/api/forgejo/v1"
|
v1 "code.gitea.io/gitea/routers/api/forgejo/v1"
|
||||||
"code.gitea.io/gitea/tests"
|
"code.gitea.io/gitea/tests"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
@ -21,5 +21,5 @@ func TestAPIForgejoVersion(t *testing.T) {
|
||||||
|
|
||||||
var version v1.Version
|
var version v1.Version
|
||||||
DecodeJSON(t, resp, &version)
|
DecodeJSON(t, resp, &version)
|
||||||
assert.Equal(t, "development", *version.Version)
|
assert.Equal(t, "1.0.0", *version.Version)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue