| 12345678910111213141516171819202122232425262728293031323334 |
- package main
- import "runtime/debug"
- // version is the release number shown on the About page. Bump it in the PR
- // that makes a user-visible change.
- const version = "0.2.1"
- // buildCommit returns the short git revision that `go build` stamped into the
- // binary, with "-dirty" if the tree had uncommitted changes, or "" if the
- // binary was built outside a git checkout.
- func buildCommit() string {
- info, ok := debug.ReadBuildInfo()
- if !ok {
- return ""
- }
- var rev string
- var dirty bool
- for _, s := range info.Settings {
- switch s.Key {
- case "vcs.revision":
- rev = s.Value
- case "vcs.modified":
- dirty = s.Value == "true"
- }
- }
- if len(rev) > 7 {
- rev = rev[:7]
- }
- if rev != "" && dirty {
- rev += "-dirty"
- }
- return rev
- }
|