mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Adding git commit to the version output
The Makefile must be used in order to inject the git commit via -ldflags.
This commit is contained in:
parent
1d6929c8bc
commit
37a78902db
3 changed files with 9 additions and 1 deletions
4
Makefile
4
Makefile
|
@ -10,6 +10,8 @@ ifeq ($(VERBOSE), 1)
|
||||||
GO_OPTIONS += -v
|
GO_OPTIONS += -v
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
BUILD_OPTIONS = -ldflags "-X main.GIT_COMMIT `git rev-parse HEAD`"
|
||||||
|
|
||||||
SRC_DIR := $(GOPATH)/src
|
SRC_DIR := $(GOPATH)/src
|
||||||
|
|
||||||
DOCKER_DIR := $(SRC_DIR)/$(DOCKER_PACKAGE)
|
DOCKER_DIR := $(SRC_DIR)/$(DOCKER_PACKAGE)
|
||||||
|
@ -24,7 +26,7 @@ all: $(DOCKER_BIN)
|
||||||
|
|
||||||
$(DOCKER_BIN): $(DOCKER_DIR)
|
$(DOCKER_BIN): $(DOCKER_DIR)
|
||||||
@mkdir -p $(dir $@)
|
@mkdir -p $(dir $@)
|
||||||
@(cd $(DOCKER_MAIN); go get $(GO_OPTIONS); go build $(GO_OPTIONS) -o $@)
|
@(cd $(DOCKER_MAIN); go get $(GO_OPTIONS); go build $(GO_OPTIONS) $(BUILD_OPTIONS) -o $@)
|
||||||
@echo $(DOCKER_BIN_RELATIVE) is created.
|
@echo $(DOCKER_BIN_RELATIVE) is created.
|
||||||
|
|
||||||
$(DOCKER_DIR):
|
$(DOCKER_DIR):
|
||||||
|
|
|
@ -21,6 +21,8 @@ import (
|
||||||
|
|
||||||
const VERSION = "0.1.0"
|
const VERSION = "0.1.0"
|
||||||
|
|
||||||
|
var GIT_COMMIT string
|
||||||
|
|
||||||
func (srv *Server) Name() string {
|
func (srv *Server) Name() string {
|
||||||
return "docker"
|
return "docker"
|
||||||
}
|
}
|
||||||
|
@ -128,6 +130,7 @@ func (srv *Server) CmdWait(stdin io.ReadCloser, stdout io.Writer, args ...string
|
||||||
// 'docker version': show version information
|
// 'docker version': show version information
|
||||||
func (srv *Server) CmdVersion(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
func (srv *Server) CmdVersion(stdin io.ReadCloser, stdout io.Writer, args ...string) error {
|
||||||
fmt.Fprintf(stdout, "Version:%s\n", VERSION)
|
fmt.Fprintf(stdout, "Version:%s\n", VERSION)
|
||||||
|
fmt.Fprintf(stdout, "Git Commit:%s\n", GIT_COMMIT)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,8 @@ import (
|
||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var GIT_COMMIT string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if docker.SelfPath() == "/sbin/init" {
|
if docker.SelfPath() == "/sbin/init" {
|
||||||
// Running in init mode
|
// Running in init mode
|
||||||
|
@ -21,6 +23,7 @@ func main() {
|
||||||
flDebug := flag.Bool("D", false, "Debug mode")
|
flDebug := flag.Bool("D", false, "Debug mode")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
rcli.DEBUG_FLAG = *flDebug
|
rcli.DEBUG_FLAG = *flDebug
|
||||||
|
docker.GIT_COMMIT = GIT_COMMIT
|
||||||
if *flDaemon {
|
if *flDaemon {
|
||||||
if flag.NArg() != 0 {
|
if flag.NArg() != 0 {
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue