Build without git

This commit is contained in:
Jakob Borg 2014-10-13 20:13:42 +02:00
parent 93ac1605bd
commit baf4cc225e
1 changed files with 11 additions and 2 deletions

View File

@ -35,6 +35,7 @@ import (
"runtime" "runtime"
"strconv" "strconv"
"strings" "strings"
"time"
) )
var ( var (
@ -301,7 +302,11 @@ func rmr(paths ...string) {
} }
func getVersion() string { func getVersion() string {
v := run("git", "describe", "--always", "--dirty") ecmd := exec.Command("git", "describe", "--always", "--dirty")
v, err := ecmd.CombinedOutput()
if err != nil {
return "unknown-dev"
}
v = versionRe.ReplaceAllFunc(v, func(s []byte) []byte { v = versionRe.ReplaceAllFunc(v, func(s []byte) []byte {
s[0] = '+' s[0] = '+'
return s return s
@ -310,7 +315,11 @@ func getVersion() string {
} }
func buildStamp() int64 { func buildStamp() int64 {
bs := run("git", "show", "-s", "--format=%ct") ecmd := exec.Command("git", "show", "-s", "--format=%ct")
bs, err := ecmd.CombinedOutput()
if err != nil {
return time.Now().Unix()
}
s, _ := strconv.ParseInt(string(bs), 10, 64) s, _ := strconv.ParseInt(string(bs), 10, 64)
return s return s
} }