镜像自地址
https://github.com/tuna/tunasync.git
已同步 2025-12-06 06:26:46 +00:00
chore(cmd): added git hash and build date to version
这个提交包含在:
@@ -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"
|
||||
|
||||
在新工单中引用
屏蔽一个用户