1
0
镜像自地址 https://github.com/tuna/tunasync.git 已同步 2025-12-06 06:26:46 +00:00

chore(cmd): added git hash and build date to version

这个提交包含在:
bigeagle
2016-06-15 14:26:32 +08:00
父节点 d292f9b0e3
当前提交 03fdaeeb7f
共有 6 个文件被更改,包括 77 次插入4 次删除

查看文件

@@ -6,7 +6,9 @@ import (
"io/ioutil"
"net/http"
"os"
"strconv"
"strings"
"time"
"github.com/BurntSushi/toml"
"github.com/codegangsta/cli"
@@ -15,6 +17,11 @@ import (
tunasync "github.com/tuna/tunasync/internal"
)
var (
buildstamp = ""
githash = "No githash provided"
)
const (
listJobsPath = "/jobs"
listWorkersPath = "/workers"
@@ -259,6 +266,27 @@ func cmdWorker(cmd tunasync.CmdVerb) cli.ActionFunc {
}
func main() {
cli.VersionPrinter = func(c *cli.Context) {
var builddate string
if buildstamp == "" {
builddate = "No build date provided"
} else {
ts, err := strconv.Atoi(buildstamp)
if err != nil {
builddate = "No build date provided"
} else {
t := time.Unix(int64(ts), 0)
builddate = t.String()
}
}
fmt.Printf(
"Version: %s\n"+
"Git Hash: %s\n"+
"Build Date: %s\n",
c.App.Version, githash, builddate,
)
}
app := cli.NewApp()
app.EnableBashCompletion = true
app.Version = "0.1"