Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@ var rootCmd = &cobra.Command{

Switch between different git identities (work, personal, school, etc.) with a single command.
Profiles are stored in ~/.config/git-context/config.yaml`,
Version: "1.0.0",
Version: "dev",
}

// SetVersion overrides the version reported by `git-context --version`.
// Called from main with the value goreleaser injects via ldflag.
func SetVersion(v string) {
if v != "" {
rootCmd.Version = v
}
}

var initCmd = &cobra.Command{
Expand Down
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,14 @@ import (
"github.com/aanogueira/git-context/cmd"
)

// version is set at build time via goreleaser's
// `-X main.version={{.Version}}` ldflag. Defaults to "dev" for local
// `go build` / `go install` invocations.
var version = "dev"

func main() {
cmd.SetVersion(version)

if err := cmd.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
Expand Down
Loading