mirror of
https://github.com/tuna/tunasync.git
synced 2025-04-21 04:42:46 +00:00
chore(cmd): added git hash and build date to version
This commit is contained in:
parent
d292f9b0e3
commit
03fdaeeb7f
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,4 +1 @@
|
|||||||
*.swp
|
/build
|
||||||
*~
|
|
||||||
/*.cov
|
|
||||||
node_modules
|
|
||||||
|
@ -8,6 +8,8 @@ function die() {
|
|||||||
|
|
||||||
export GOPATH=`pwd`:$GOPATH
|
export GOPATH=`pwd`:$GOPATH
|
||||||
|
|
||||||
|
make
|
||||||
|
|
||||||
# Initialize profile.cov
|
# Initialize profile.cov
|
||||||
echo "mode: count" > profile.cov
|
echo "mode: count" > profile.cov
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ go:
|
|||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
- sudo apt-get install cgroup-bin
|
- sudo apt-get install cgroup-bin
|
||||||
|
- go get github.com/smartystreets/goconvey
|
||||||
- go get golang.org/x/tools/cmd/cover
|
- go get golang.org/x/tools/cmd/cover
|
||||||
- go get -v github.com/mattn/goveralls
|
- go get -v github.com/mattn/goveralls
|
||||||
|
|
||||||
|
16
Makefile
Normal file
16
Makefile
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
LDFLAGS="-X main.buildstamp=`date -u '+%s'` -X main.githash=`git rev-parse HEAD`"
|
||||||
|
|
||||||
|
all: get tunasync tunasynctl
|
||||||
|
|
||||||
|
get:
|
||||||
|
go get ./cmd/tunasync
|
||||||
|
go get ./cmd/tunasynctl
|
||||||
|
|
||||||
|
build:
|
||||||
|
mkdir -p build
|
||||||
|
|
||||||
|
tunasync: build
|
||||||
|
go build -o build/tunasync -ldflags ${LDFLAGS} github.com/tuna/tunasync/cmd/tunasync
|
||||||
|
|
||||||
|
tunasynctl: build
|
||||||
|
go build -o build/tunasynctl -ldflags ${LDFLAGS} github.com/tuna/tunasync/cmd/tunasynctl
|
@ -1,8 +1,10 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"strconv"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -16,6 +18,11 @@ import (
|
|||||||
"github.com/tuna/tunasync/worker"
|
"github.com/tuna/tunasync/worker"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
buildstamp = ""
|
||||||
|
githash = "No githash provided"
|
||||||
|
)
|
||||||
|
|
||||||
var logger = logging.MustGetLogger("tunasync")
|
var logger = logging.MustGetLogger("tunasync")
|
||||||
|
|
||||||
func startManager(c *cli.Context) {
|
func startManager(c *cli.Context) {
|
||||||
@ -99,6 +106,28 @@ func startWorker(c *cli.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
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 := cli.NewApp()
|
||||||
app.EnableBashCompletion = true
|
app.EnableBashCompletion = true
|
||||||
app.Version = "0.1"
|
app.Version = "0.1"
|
||||||
|
@ -6,7 +6,9 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
@ -15,6 +17,11 @@ import (
|
|||||||
tunasync "github.com/tuna/tunasync/internal"
|
tunasync "github.com/tuna/tunasync/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
buildstamp = ""
|
||||||
|
githash = "No githash provided"
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
listJobsPath = "/jobs"
|
listJobsPath = "/jobs"
|
||||||
listWorkersPath = "/workers"
|
listWorkersPath = "/workers"
|
||||||
@ -259,6 +266,27 @@ func cmdWorker(cmd tunasync.CmdVerb) cli.ActionFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
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 := cli.NewApp()
|
||||||
app.EnableBashCompletion = true
|
app.EnableBashCompletion = true
|
||||||
app.Version = "0.1"
|
app.Version = "0.1"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user