Skip to content

Commit

Permalink
feat: extract latest git tag as version
Browse files Browse the repository at this point in the history
  • Loading branch information
tingzhen.lin committed Sep 26, 2022
1 parent 7794765 commit f9bb50a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
VERSION := $(shell git describe --abbrev=0)
COMMIT_REVISION := $(shell git log --pretty=%h -1)
REVISION_FLAG := "-X github.com/lintingzhen/commitizen-go/cmd.revision=${COMMIT_REVISION}"
REVISION_FLAG := "-X github.com/lintingzhen/commitizen-go/cmd.revision=${COMMIT_REVISION} -X github.com/lintingzhen/commitizen-go/cmd.version=${VERSION}"
TARGET := commitizen-go
GOFILES := $(wildcard *.go) $(wildcard cmd/*.go) $(wildcard git/*.go) $(wildcard commit/*.go)

Expand Down
3 changes: 2 additions & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import (
"github.com/spf13/cobra"
)

var version string
var revision string

var VersionCmd = &cobra.Command{
Use: "version",
Short: "Print version information and quit",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("Commitizen-go version 1.0.0, build revision %s\n", revision)
fmt.Printf("Commitizen-go version %s, build revision %s\n", version, revision)
},
}

0 comments on commit f9bb50a

Please sign in to comment.