-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resolved #91: automatically generate gitea version #101
Conversation
Current coverage is 2.24% (diff: 100%)@@ master #101 diff @@
========================================
Files 32 32
Lines 7521 7521
Methods 0 0
Messages 0 0
Branches 0 0
========================================
Hits 169 169
Misses 7335 7335
Partials 17 17
|
I personally prefer a makefile, most of the bash content is done there. |
version="unknow" | ||
|
||
if [ -f VERSION ]; then | ||
cat /etc/passwd | read version |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
passwd?
|
||
if [ "$version" != "HEAD" ]; then | ||
if [ "$version" == "master" ]; then | ||
go build -ldflags "-X main.Version=tip+${tag}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of tip as a "version"
What's wrong with Makefile? Why we need make.bash? |
You have to install extra make system. But for a bash, it has no more dependency. |
To be serious, I think nearly all people working with Go got make installed. I personally don't really want to maintain 2 files for a single use case. |
And if we change the version assignment I would also drop https://github.com/go-gitea/gitea/blob/master/modules/setting/setting.go#L51-L52 and the places where it gets used.
|
And this is my suggestion for the Makefile to get it working based on this proposal, I would always keep a valid version number, --- Makefile.current 2016-11-07 09:25:49.668272844 +0100
+++ Makefile 2016-11-07 09:33:32.880272024 +0100
@@ -4,31 +4,30 @@
EXECUTABLE := gitea
IMPORT := github.com/go-gitea/gitea
-SHA := $(shell git rev-parse --short HEAD)
-DATE := $(shell date -u '+%Y-%m-%d %I:%M:%S %Z')
-
BINDATA := $(shell find conf | sed 's/ /\\ /g')
STYLESHEETS := $(wildcard public/less/index.less public/less/_*.less)
JAVASCRIPTS :=
-LDFLAGS += -X "github.com/go-gitea/gitea/modules/setting.BuildTime=$(DATE)"
-LDFLAGS += -X "github.com/go-gitea/gitea/modules/setting.BuildGitHash=$(SHA)"
+REF ?= $(shell git rev-parse --abbrev-ref HEAD)
+SHA ?= $(shell git describe --tag --always)
TARGETS ?= linux/*,darwin/*,windows/*
PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
TAGS ?=
-ifneq ($(TRAVIS_TAG),)
- VERSION ?= $(TRAVIS_TAG)
+ifneq ($(REF),HEAD)
+ VERSION ?= 0.0.0+$(SHA)
else
- ifneq ($(TRAVIS_BRANCH),)
- VERSION ?= $(TRAVIS_BRANCH)
+ ifneq ($(REF),master)
+ VERSION ?= 0.0.0+$(SHA)
else
- VERSION ?= master
+ VERSION ?= $(REF)+$(SHA)
endif
endif
+LDFLAGS += -X "main.Version=$(VERSION)"
+
.PHONY: all
all: clean test build |
What's wrong with just using SHA ? Why do we need REF too ? Do you have example resulting VERSION strings ? |
|
And why do we want to distinguish, was my question. |
We WANT to have |
On Mon, Nov 07, 2016 at 04:15:17AM -0800, Thomas Boerger wrote:
I don't get this, why don't you always want an unambiguous |
We want a proper version scheme that applies for package managers. |
Maybe I misunderstood your suggestion, as long as the |
@@ -17,7 +17,7 @@ import ( | |||
) | |||
|
|||
// Version holds the current Gitea version | |||
const Version = "0.9.99.0915" | |||
var Version = "0.9.99.0915" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would set that to var Version = "0.0.0+master"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should still be const
, since it shouldn't be changed at runtime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I remember correctly you can not manipulate const
from outside? Need to confirm that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A const can not be set via go build flag.
On Mon, Nov 07, 2016 at 07:19:43AM -0800, Thomas Boerger wrote:
// Version holds the current Gitea version
-const Version = "0.9.99.0915"
+var Version = "0.9.99.0915"
I would set that to `var Version = "0.0.0+master"`
Based on
#91 (comment)
the hard-coded version should probably be "1.0.0+dev"
(target version for current master is 1.0.0)
|
Let's close that in favor of #190 |
And I create the make.bash for linux and mac, we need another make.bat for windows. Of course, this is a beginning of make bash. I think a bash file to make is simple and better than Makefile.