MCPcopy Index your code
hub / github.com/git-bug/git-bug / getVersion

Function getVersion

commands/root.go:91–115  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

89}
90
91func getVersion() string {
92 if GitExactTag == "undefined" {
93 GitExactTag = ""
94 }
95
96 if GitExactTag != "" {
97 // we are exactly on a tag --> release version
98 return GitLastTag
99 }
100
101 if GitLastTag != "" {
102 // not exactly on a tag --> dev version
103 return fmt.Sprintf("%s-dev-%.10s", GitLastTag, GitCommit)
104 }
105
106 // we don't have commit information, try golang build info
107 if commit, dirty, err := getCommitAndDirty(); err == nil {
108 if dirty {
109 return fmt.Sprintf("dev-%.10s-dirty", commit)
110 }
111 return fmt.Sprintf("dev-%.10s", commit)
112 }
113
114 return "dev-unknown"
115}
116
117func getCommitAndDirty() (commit string, dirty bool, err error) {
118 info, ok := debug.ReadBuildInfo()

Callers 1

NewRootCommandFunction · 0.85

Calls 1

getCommitAndDirtyFunction · 0.85

Tested by

no test coverage detected