Skip to content

Commit dfcd470

Browse files
committed
support github.com/coreos/go-systemd/v22
Support vendoring `github.com/coreos/go-systemd/v22` as follows: `foo.go`: ```go package foo import ( "github.com/coreos/go-systemd/v22/dbus" ) func Foo() (*dbus.Conn, error) { return dbus.New() } ``` `vendor.conf`: ``` github.com/coreos/go-systemd/v22 v22.0.0 github.com/godbus/dbus/v5 v5.0.3 ``` Now `vndr` checks out the contents of `github.com/coreos/[email protected]` repo into the `./vendor/github.com/coreos/go-systemd/v22` directory. Note that `vndr` does not verify the actual version number written in `go.mod`. So `vndr github.com/coreos/go-systemd/v23 v22.0.0` would vendor v22, not v23. Fix containerd/cgroups#139 Signed-off-by: Akihiro Suda <[email protected]>
1 parent d87a917 commit dfcd470

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

godl/vcs.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"sync"
1818

1919
"github.com/LK4D4/vndr/godl/singleflight"
20+
"github.com/LK4D4/vndr/versioned"
2021
)
2122

2223
// envForDir returns a copy of the environment
@@ -512,6 +513,9 @@ func repoRootFromVCSPaths(importPath, scheme string, security securityMode, vcsP
512513
repo: match["repo"],
513514
root: match["root"],
514515
}
516+
if versioned.IsVersioned(importPath) {
517+
rr.root = importPath
518+
}
515519
return rr, nil
516520
}
517521
return nil, errUnknownSite
@@ -581,6 +585,9 @@ func repoRootForImportDynamic(importPath string, security securityMode) (*repoRo
581585
if rr.vcs == nil {
582586
return nil, fmt.Errorf("%s: unknown vcs %q", urlStr, mmi.VCS)
583587
}
588+
if versioned.IsVersioned(importPath) {
589+
rr.root = importPath
590+
}
584591
return rr, nil
585592
}
586593

main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
"github.com/LK4D4/vndr/build"
1616
"github.com/LK4D4/vndr/godl"
17+
"github.com/LK4D4/vndr/versioned"
1718
)
1819

1920
const (
@@ -155,7 +156,7 @@ func validateDeps(deps []depEntry) error {
155156
rootDeps := roots[r]
156157
if len(rootDeps) == 1 {
157158
d := rootDeps[0]
158-
if d.importPath != r {
159+
if d.importPath != r && !versioned.IsVersioned(d.importPath) {
159160
Warnf("package %s is not root import, should be %s", d.importPath, r)
160161
invalid = true
161162
newDeps = append(newDeps, depEntry{importPath: r, rev: d.rev, repoPath: d.repoPath})

versioned/versioned.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package versioned
2+
3+
import (
4+
"regexp"
5+
)
6+
7+
var re = regexp.MustCompile(`/v[0-9]+$`)
8+
9+
// IsVersioned true for string like "github.com/coreos/go-systemd/v22"
10+
func IsVersioned(s string) bool {
11+
return re.MatchString(s)
12+
}

0 commit comments

Comments
 (0)