Skip to content

Commit 0a8e63c

Browse files
lunnytechknowlogick
authored andcommitted
add make version on gitea version (#6485)
1 parent 60ba903 commit 0a8e63c

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ GOFMT ?= gofmt -s
2424
GOFLAGS := -i -v
2525
EXTRA_GOFLAGS ?=
2626

27+
MAKE_VERSION := $(shell make -v | head -n 1)
28+
2729
ifneq ($(DRONE_TAG),)
2830
VERSION ?= $(subst v,,$(DRONE_TAG))
2931
GITEA_VERSION ?= $(VERSION)
@@ -36,7 +38,7 @@ else
3638
GITEA_VERSION ?= $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
3739
endif
3840

39-
LDFLAGS := -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)"
41+
LDFLAGS := -X "main.MakeVersion=$(MAKE_VERSION)" -X "main.Version=$(GITEA_VERSION)" -X "main.Tags=$(TAGS)"
4042

4143
PACKAGES ?= $(filter-out code.gitea.io/gitea/integrations/migration-test,$(filter-out code.gitea.io/gitea/integrations,$(shell $(GO) list ./... | grep -v /vendor/)))
4244
SOURCES ?= $(shell find . -name "*.go" -type f)

main.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@ import (
2323
"github.com/urfave/cli"
2424
)
2525

26-
// Version holds the current Gitea version
27-
var Version = "1.5.0-dev"
28-
29-
// Tags holds the build tags used
30-
var Tags = ""
26+
var (
27+
// Version holds the current Gitea version
28+
Version = "1.9.0-dev"
29+
// Tags holds the build tags used
30+
Tags = ""
31+
// MakeVersion holds the current Make version if built with make
32+
MakeVersion = ""
33+
)
3134

3235
func init() {
3336
setting.AppVer = Version
@@ -60,10 +63,14 @@ arguments - which can alternatively be run by running the subcommand web.`
6063
}
6164
}
6265

63-
func formatBuiltWith(Tags string) string {
66+
func formatBuiltWith(makeTags string) string {
67+
var version = runtime.Version()
68+
if len(MakeVersion) > 0 {
69+
version = MakeVersion + ", " + runtime.Version()
70+
}
6471
if len(Tags) == 0 {
65-
return " built with " + runtime.Version()
72+
return " built with " + version
6673
}
6774

68-
return " built with " + runtime.Version() + " : " + strings.Replace(Tags, " ", ", ", -1)
75+
return " built with " + version + " : " + strings.Replace(Tags, " ", ", ", -1)
6976
}

0 commit comments

Comments
 (0)