mprahl
(Matt Prahl)
November 15, 2019, 10:48pm
1
I’m working on a project where I need to determine the Go module version on a locally cloned Git repository. I’ve got an algorithm that mostly works thanks to the documentation and some trial and error. Where I’m stuck is determining which tag to use when there are multiple tags on the same commit.
Any help would be appreciated. Thank you!
1 Like
mprahl
(Matt Prahl)
November 18, 2019, 6:49pm
2
I found the relevant code:
// Look through the tags on the revision for either a usable canonical version
// or an appropriate base for a pseudo-version.
var pseudoBase string
for _, pathTag := range info.Tags {
v, tagIsCanonical := tagToVersion(pathTag)
if tagIsCanonical {
if statVers != "" && semver.Compare(v, statVers) == 0 {
// The user requested a non-canonical version, but the tag for the
// canonical equivalent refers to the same revision. Use it.
info2.Version = v
return checkGoMod()
} else {
// Save the highest canonical tag for the revision. If we don't find a
// better match, we'll use it as the canonical version.
//
// NOTE: Do not replace this with semver.Max. Despite the name,
// semver.Max *also* canonicalizes its arguments, which uses
// semver.Canonical instead of module.CanonicalVersion and thereby
// strips our "+incompatible" suffix.
if semver.Compare(info2.Version, v) < 0 {
This file has been truncated. show original
I’ll just work from that.
1 Like
system
(system)
Closed
February 16, 2020, 6:49pm
3
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.