Skip to content

Commit

Permalink
Add support for short module names (#108)
Browse files Browse the repository at this point in the history
* Add support for short module names

* Fix incrementl tests

* Update the tools removal test

* Add Go 1.17 to the e2e tests
  • Loading branch information
nacx authored Feb 28, 2022
1 parent 597abdb commit bb75707
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.15.x
go-version: 1.17.x

- uses: actions/cache@v1
with:
Expand All @@ -34,7 +34,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: ['1.14.x', '1.15.x', '1.16.x']
go: ['1.14.x', '1.15.x', '1.16.x', '1.17.x']
platform: [ubuntu-latest, macos-latest]

name: Unit tests on Go ${{ matrix.go }} ${{ matrix.platform }}
Expand Down
2 changes: 1 addition & 1 deletion get.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ func resolveInGoModCache(logger *log.Logger, verbose bool, update runner.GetUpda

// Since we don't know which part of full path is package, which part is module.
// Start from longest and go until we find one.
for ; len(strings.Split(lookupModulePath, "/")) > 2; func() {
for ; len(strings.Split(lookupModulePath, "/")) >= 2; func() {
lookupModulePath = filepath.Dir(lookupModulePath)
modulePath = filepath.Dir(modulePath)
}() {
Expand Down
27 changes: 27 additions & 0 deletions get_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,11 +624,38 @@ func TestGet(t *testing.T) {
"wr_buildable-v0.0.0-20210109165512-ccbd4039b94a", "wr_buildable-v0.0.0-20210110214650-ab990d1be30b",
},
},
{
name: "get istio.io/tools/cmd/cue-gen@355a0b7a6ba743d14e3a43a3069287086207f35c (short module base path)",
do: func(t *testing.T) {
fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "istio.io/tools/cmd/cue-gen@355a0b7a6ba743d14e3a43a3069287086207f35c"))
},
expectRows: []row{
{name: "buildable", binName: "buildable-v0.0.0-20210109093942-2e6391144e85", pkgVersion: "github.com/bwplotka/bingo/testdata/module/buildable@v0.0.0-20210109093942-2e6391144e85"},
{name: "buildable_old", binName: "buildable_old-v0.0.0-20210109093942-2e6391144e85", pkgVersion: "github.com/bwplotka/bingo/testdata/module/buildable@v0.0.0-20210109093942-2e6391144e85"},
{name: "cue-gen", binName: "cue-gen-v0.0.0-20210909062344-355a0b7a6ba7", pkgVersion: "istio.io/tools/cmd/cue-gen@v0.0.0-20210909062344-355a0b7a6ba7"},
{name: "f3", binName: "f3-v1.1.0", pkgVersion: "github.com/fatih/faillint@v1.1.0"},
{name: "faillint", binName: "faillint-v1.0.0", pkgVersion: "github.com/fatih/faillint@v1.0.0"},
{name: "faillint", binName: "faillint-v1.1.0", pkgVersion: "github.com/fatih/faillint@v1.1.0"},
{name: "go-bindata", binName: "go-bindata-v3.1.1+incompatible", pkgVersion: "github.com/go-bindata/go-bindata/go-bindata@v3.1.1+incompatible"},
{name: "wr_buildable", binName: "wr_buildable-v0.0.0-20210109165512-ccbd4039b94a", pkgVersion: "github.com/bwplotka/bingo/testdata/module_with_replace/buildable@v0.0.0-20210109165512-ccbd4039b94a"},
},
expectBinaries: []string{
"buildable",
"buildable-v0.0.0-20210109093942-2e6391144e85", "buildable-v0.0.0-20210109094001-375d0606849d", "buildable2-v0.0.0-20210109093942-2e6391144e85", "buildable3-v0.0.0-20210109093942-2e6391144e85",
"buildable_old-v0.0.0-20210109093942-2e6391144e85", "buildable_old-v0.0.0-20210109094001-375d0606849d",
"cue-gen-v0.0.0-20210909062344-355a0b7a6ba7",
"f2-v1.0.0", "f2-v1.1.0", "f2-v1.2.0", "f2-v1.3.0", "f2-v1.4.0", "f2-v1.5.0", "f3-v1.1.0", "f3-v1.3.0", "f3-v1.4.0",
"faillint-v1.0.0", "faillint-v1.1.0", "faillint-v1.3.0", "faillint-v1.4.0", "faillint-v1.5.0",
"go-bindata-v3.1.1+incompatible",
"wr_buildable-v0.0.0-20210109165512-ccbd4039b94a", "wr_buildable-v0.0.0-20210110214650-ab990d1be30b",
},
},
{
name: "Remove rest of tools",
do: func(t *testing.T) {
fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "FaIllint@none")) // case should not matter.
fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "buildable_old@none"))
fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "cue-gen@none"))
fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "f3@none"))
fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "buildable@none"))
fmt.Println(g.ExecOutput(t, p.root, bingoPath, "get", "wr_buildable@none"))
Expand Down

0 comments on commit bb75707

Please sign in to comment.