Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect --ignore-dirs flag in import analysis #7

Merged
merged 2 commits into from
May 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func main() {
repo := gitRoot()

pkgSeen := make(map[string]bool)
var modifiedPackages []*build.Package
buildContext := build.Default
for _, f := range files {
if isIgnored(f) {
Expand All @@ -59,7 +58,6 @@ func main() {
}

pkgSeen[pkg.ImportPath] = true
modifiedPackages = append(modifiedPackages, pkg)
}

// TODO: list all packages in the repo, determine dependency tree and filter package list to those that transitively import affected packages
Expand All @@ -75,6 +73,10 @@ func main() {
return
}

if isIgnored(importPath) {
return
}

pkg, err := buildContext.Import(importPath, repo, build.AllowBinary)
if err, ok := err.(*build.NoGoError); err != nil && ok {
return
Expand All @@ -96,8 +98,8 @@ func main() {

// filter the package list to those affected
var affectedPackages []string
for _, p := range modifiedPackages {
affectedPackages = append(affectedPackages, p.ImportPath)
for path := range pkgSeen {
affectedPackages = append(affectedPackages, path)
}
addedMore := true
for addedMore {
Expand Down