Merge pull request #29 from yihuang/fix-rev-regex

Fix pseudo version string regex
This commit is contained in:
adisbladis 2022-05-20 18:17:06 +08:00 committed by GitHub
commit 96f7710270
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3,13 +3,6 @@ package fetch
import (
"encoding/json"
"fmt"
log "github.com/sirupsen/logrus"
"github.com/tweag/gomod2nix/formats/buildgopackage"
"github.com/tweag/gomod2nix/formats/gomod2nix"
"github.com/tweag/gomod2nix/types"
"golang.org/x/mod/modfile"
"golang.org/x/mod/module"
"golang.org/x/tools/go/vcs"
"io/ioutil"
"os"
"os/exec"
@ -17,6 +10,14 @@ import (
"regexp"
"sort"
"strings"
log "github.com/sirupsen/logrus"
"github.com/tweag/gomod2nix/formats/buildgopackage"
"github.com/tweag/gomod2nix/formats/gomod2nix"
"github.com/tweag/gomod2nix/types"
"golang.org/x/mod/modfile"
"golang.org/x/mod/module"
"golang.org/x/tools/go/vcs"
)
type packageJob struct {
@ -157,7 +158,7 @@ func fetchPackage(caches []map[string]*types.Package, importPath string, goPacka
return nil, err
}
commitShaRev := regexp.MustCompile(`v\d+\.\d+\.\d+-[\d+\.a-zA-Z]*?[0-9]{14}-(.*?)$`)
commitShaRev := regexp.MustCompile(`v\d+\.\d+\.\d+-[\d+\.a-zA-Z\-]*?[0-9]{14}-(.*?)$`)
rev := strings.TrimSuffix(sumVersion, "+incompatible")
if commitShaRev.MatchString(rev) {
rev = commitShaRev.FindAllStringSubmatch(rev, -1)[0][1]