-
Notifications
You must be signed in to change notification settings - Fork 1k
Move bad go code under a vendor/ subdirectory. #1253
Conversation
This fixes an issue where running `dep status` on dep itself resulted in error from ListPackages due to parsing the bad go code that exists in the testdata.
we can't abuse vendor in this way - we need to fix the underlying problem in the logic that we're caring about these errors at all. same basic issue as in #1251, I think. |
@sdboyer yes, #1251 is the same issue and the inability to run From #1251
So, I think I know how to do this partially. Like, defer parsing dot and underscore-led dirs and keeping a record of all the dirs that might require parsing once we determine if we need them. Maybe from the PackageTree obtained after parsing all the non-dot/underscore-led dirs, check if any of the import paths have dot or underscore in them. If they do, parse that specific package only? |
so there's two basic approaches i can picture. one involves new a new parameter to the other approach could be a method on
the idea here would be creating a new
i think this should be doable by relying on the existing logic in func (t PackageTree) TrimHiddenAndUnreachable(main, tests, backprop bool, ignore map[string]bool) PackageTree {
// while it is probably correct to surface all these params, it is not
// necessarily the case that we will want to use them all the same way as we
// currently do with ToReachMap() in cmd/dep.
rm, pie := t.ToReachMap(main, tests, backprop, ignore)
t2 := t.Copy()
preserve := make(map[string]bool)
for pkg, ie := range rm {
if !pkgFilter(pkg) {
preserve[pkg] = true
for _, in := range ie.Internal {
preserve[in] = true
}
}
}
for ip := range t.Packages {
if !preserve[pkg] {
delete(t2.Packages, ip)
}
}
return t2
} that's more or less right, but it glaringly it does not incorporate the |
What about an |
@pengux we generally try to avoid introducing new flags, especially for situations like this. reliance on a flag would necessitate that it be passed for all operations for their correct behavior, which means that whole repos would only work if you use that flag. some would need it, some wouldn't, we can resolve this situation unambiguously and correctly without the need for additional input from the user. we just have to pay a bit of a complexity cost to do it. |
actually, i'm gonna just tackle this one, having started on the sketched-out implementation above. lot of subtle things here. |
(closing this, will make new PR) |
😆 I spent a few hours understanding, experimenting and implementing, but it's fine. 🤘 |
@darkowlzz sorry about that - happy to discuss it in more detail when my PR is up :) |
What does this do / why do we need it?
This fixes an issue where running
dep status
on dep itself resulted inerror from ListPackages due to parsing the bad go code that exists in
the testdata.
This started happening after adding tests from #1017 .
What should your reviewer look out for in this PR?
The solution to the issue. Any other better way to fix the same issue?
Do you need help or clarification on anything?
No.