fix: import non-existant package

This commit is contained in:
Nicholas Wiersma
2020-06-18 09:44:03 +02:00
committed by GitHub
parent 1fe91be882
commit 2bef03e253
2 changed files with 8 additions and 1 deletions

View File

@@ -191,7 +191,8 @@ func effectivePkg(root, path string) string {
for i := 0; i < len(splitPath); i++ {
part := splitPath[len(splitPath)-1-i]
if part == splitRoot[len(splitRoot)-1-rootIndex] && i != 0 {
index := len(splitRoot) - 1 - rootIndex
if index > 0 && part == splitRoot[index] && i != 0 {
prevRootIndex = rootIndex
rootIndex++
} else if prevRootIndex == rootIndex {

View File

@@ -26,6 +26,12 @@ func Test_effectivePkg(t *testing.T) {
path: "vendor/guthib.com/containous/vin",
expected: "github.com/foo/plugin/vendor/guthib.com/containous/fromage/vendor/guthib.com/containous/vin",
},
{
desc: "path is non-existent",
root: "foo",
path: "githib.com/foo/app",
expected: "foo/githib.com/foo/app",
},
}
for _, test := range testCases {