Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Go <1.18 compile support for version VCS IDs #2450

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
26 changes: 25 additions & 1 deletion version/version.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2013-2014 The btcsuite developers
// Copyright (c) 2015-2021 The Decred developers
// Copyright (c) 2015-2024 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

Expand All @@ -8,6 +8,7 @@ package version
import (
"bytes"
"fmt"
"runtime/debug"
"strings"
)

Expand Down Expand Up @@ -42,6 +43,29 @@ func init() {
}
}

func vcsCommitID() string {
bi, ok := debug.ReadBuildInfo()
if !ok {
return ""
}
var vcs, revision string
for _, bs := range bi.Settings {
switch bs.Key {
case "vcs":
vcs = bs.Value
case "vcs.revision":
revision = bs.Value
}
}
if vcs == "" {
return ""
}
if vcs == "git" && len(revision) > 9 {
revision = revision[:9]
}
return revision
}

// String returns the application version as a properly formed string per the
// semantic versioning 2.0.0 spec (https://semver.org/).
func String() string {
Expand Down
32 changes: 0 additions & 32 deletions version/version_buildinfo.go

This file was deleted.

11 changes: 0 additions & 11 deletions version/version_nobuildinfo.go

This file was deleted.

Loading