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

Function getCommitAndDirty

commands/root.go:117–144  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

115}
116
117func getCommitAndDirty() (commit string, dirty bool, err error) {
118 info, ok := debug.ReadBuildInfo()
119 if !ok {
120 return "", false, fmt.Errorf("unable to read build info")
121 }
122
123 var commitFound bool
124
125 // get the commit and modified status
126 // (that is the flag for repository dirty or not)
127 for _, kv := range info.Settings {
128 switch kv.Key {
129 case "vcs.revision":
130 commit = kv.Value
131 commitFound = true
132 case "vcs.modified":
133 if kv.Value == "true" {
134 dirty = true
135 }
136 }
137 }
138
139 if !commitFound {
140 return "", false, fmt.Errorf("no commit found")
141 }
142
143 return commit, dirty, nil
144}

Callers 1

getVersionFunction · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected