From c20c629d278d2a0c65ff6b550280b838d9e3bdd3 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 7 Nov 2016 11:17:16 +0800 Subject: [PATCH 1/3] resolved #91: automatically generate gitea version --- main.go | 2 +- make.bash | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100755 make.bash diff --git a/main.go b/main.go index f077b5ec31b57..745560454560d 100644 --- a/main.go +++ b/main.go @@ -17,7 +17,7 @@ import ( ) // Version holds the current Gitea version -const Version = "0.9.99.0915" +var Version = "0.9.99.0915" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/make.bash b/make.bash new file mode 100755 index 0000000000000..d17828ea8ee54 --- /dev/null +++ b/make.bash @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# Copyright 2016 The Gitea Authors. All rights reserved. +# Use of this source code is governed by a MIT-style +# license that can be found in the LICENSE file. + +version="unknow" + +if [ -f VERSION ]; then + cat /etc/passwd | read version + go build -ldflags "-w -s -X main.Version=${version}" + exit 0 +fi + +version=$(git rev-parse --git-dir) +if [ "$version" != ".git" ]; then + echo "no VERSION found and not a git project" + exit 1 +fi + +version=$(git rev-parse --abbrev-ref HEAD) +echo "$version" + +tag=$(git describe --tag --always) +echo "$tag" + +if [ "$version" != "HEAD" ]; then + if [ "$version" == "master" ]; then + go build -ldflags "-X main.Version=tip+${tag}" + else + go build -ldflags "-X main.Version=${version}+${tag}" + fi + exit 0 +else + go build -ldflags "-X main.Version=${tag}" +fi + From 4da9cd2ba7de9c6c577b469b169468cbe9b80800 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 7 Nov 2016 11:23:27 +0800 Subject: [PATCH 2/3] remove trace info --- make.bash | 3 --- 1 file changed, 3 deletions(-) diff --git a/make.bash b/make.bash index d17828ea8ee54..b6941a758eb4b 100755 --- a/make.bash +++ b/make.bash @@ -19,10 +19,7 @@ if [ "$version" != ".git" ]; then fi version=$(git rev-parse --abbrev-ref HEAD) -echo "$version" - tag=$(git describe --tag --always) -echo "$tag" if [ "$version" != "HEAD" ]; then if [ "$version" == "master" ]; then From c5ecdc8aff4b59b0d177b398b0a0bd81ad3bc1db Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 7 Nov 2016 22:59:15 +0800 Subject: [PATCH 3/3] bug fixed for cat VERSION --- make.bash | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/make.bash b/make.bash index b6941a758eb4b..0974b3a54afd0 100755 --- a/make.bash +++ b/make.bash @@ -7,7 +7,7 @@ version="unknow" if [ -f VERSION ]; then - cat /etc/passwd | read version + version=$(cat VERSION) go build -ldflags "-w -s -X main.Version=${version}" exit 0 fi @@ -30,5 +30,4 @@ if [ "$version" != "HEAD" ]; then exit 0 else go build -ldflags "-X main.Version=${tag}" -fi - +fi \ No newline at end of file