-
Notifications
You must be signed in to change notification settings - Fork 1k
Conversation
df7bd86
to
cb6d779
Compare
@sdboyer I'm wondering how I should pass the I'm contemplating the choice between passing it in |
eh, i don't have a strong feeling either way 🤷♂️ |
cmd/dep/gopath_scanner.go
Outdated
Ovr: make(gps.ProjectConstraints), | ||
Constraints: g.pd.constraints, | ||
Ovr: make(gps.ProjectConstraints), | ||
PruneOptions: gps.PruneNestedVendorDirs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we want to have a default value for manifests (pruning nested vendor dirs), I'd prefer that we put that logic into a constructur dep.NewManifest
, instead of relying upon every caller to remember to set it and get the default right.
Also, I didn't see that you updated the importers (they all make new manifests) and it's not clear to me what will even happen in that case if they leave the prune option off?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was basing this on the assumption that pruning is opt-in. So we only remove nested vendor directories by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I'm late to the prune party and need a refresher course. When you say "pruning is opt-in" and also "we remove nested directories by default", I am not sure what will happen if someone doesn't explicitly set PruneOptions
.
Basically I am concerned that if it's supposed to be a default, then it would be helpful to have it set by default in a constructor, rather than having to remember to set it everywhere as it's currently done in this PR. Some places aren't setting any PruneOptions
(like the importers) and I can't really tell if they should, or if it doesn't matter because it's the default anyway.
If it's opt-in, do you mean that nothing happens (including removing nested vendor dirs) unless the user specifies a flag on the CLI or in the manifest? If so then why is it being set in code, that seems like a default, not opt-in...
None of this is criticism. I'm just confused. 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've already added a Manifest constructor based on your comments, seems like a great idea.
I've updated the importers to use the new constructor. 😁
I'll rebase and restructure the commits to allow sane review since this PR contains a lot of changes. 😓
internal/gps/prune.go
Outdated
} | ||
} | ||
|
||
// if (options & PruneNonGoFiles) != 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this commented out because the PR is still a WIP?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. 😓
I actually completed the PR but did a git checkout -- .
by mistake and now I have to do it again. 😫
I'm hoping that I'll be able to complete the remaining changes, again, tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh noes! Are any of your changes still hiding in the reflog perhaps?
manifest.go
Outdated
Ovr: make(gps.ProjectConstraints, len(raw.Overrides)), | ||
Ignored: raw.Ignored, | ||
Required: raw.Required, | ||
PruneOptions: gps.PruneNestedVendorDirs, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like it's not just a default but a required "base flag" that is always set and manifest cannot unset this flag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I could change this so that coming through dep/cmd/dep
always toggle that flag in PruneOptions
when passing it to SafeWriter.Write
or gps.WriteDepTree
.
I understood from @sdboyer that we want gps
to have control over this flag, but dep
should always keep it on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooooooh, knowing that gps may want to use it differently than dep makes this make a whole lot more sense!
I don't know what's the best way to make the change, you are much closer to this than I am. But at a high level, having a way for dep to make sure that optional is always passed in properly seems useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't let me tell you how to implement, I'm just asking questions and thinking out loud. 😃
d762e3c
to
6c30103
Compare
7db1353
to
6e672a2
Compare
f4bef4e
to
33b99af
Compare
@sdboyer Just to clarify and confirm the effect of each pruning option:
Finally, I always walk over |
83b92ab
to
c417150
Compare
internal/gps/result.go
Outdated
func WriteDepTree(basedir string, l Lock, sm SourceManager, sv bool) error { | ||
// It requires a SourceManager to do the work, and takes a PruneOptions | ||
// indicating the pruning options required for the exported dependencies. | ||
func WriteDepTree(baseDir string, l Lock, sm SourceManager, prune PruneOptions, logger *log.Logger) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, this looks like unmerged commits from #968 snuck in? Or did you intend to combine these PRs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is needed in both PRs since we need to log what was pruned.
manifest := &dep.Manifest{ | ||
Constraints: make(gps.ProjectConstraints), | ||
} | ||
manifest := dep.NewManifest() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yay! Thank you for the constructor. 😃
cac5f61
to
49ea538
Compare
Sorry for the slow updates. I was in quite the bind at work last week. 😩 Rebased and updated the commits. I'll be working on the tests now. |
Note: 4094432 is the result of running |
49ea538
to
4094432
Compare
internal/gps/result.go
Outdated
|
||
if len(errCh) > 0 { | ||
logger.Println("Failed to write dep tree. The following errors occurred:") | ||
for err := range errCh { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since channel is not closed, this will be blocked? Channel should be closed after wg.Wait()
and return below should return an error since closed channel yields nil.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. 👍
Some questions I've:
|
b46be92
to
b3cd781
Compare
Signed-off-by: Ibrahim AshShohail <[email protected]>
This change updates the manifest to accept a new table: prune. This table defines pruning options accepted by dep. By default, dep will always prune nested vendor directories. Three additional options can be toggled in the manifest: * non-go: Prune non-Go files (will keep LICENSE & COPYING files) * go-tests: Prune Go test files * unused-packages: Prune unused Go packages from dependencies. The implementation of these flags is not part of this commit. A constructor for dep.Manifest was also added. Signed-off-by: Ibrahim AshShohail <[email protected]>
Signed-off-by: Ibrahim AshShohail <[email protected]>
03db61c
to
82decf7
Compare
Signed-off-by: Ibrahim AshShohail <[email protected]>
82decf7
to
ec26c91
Compare
Signed-off-by: Ibrahim AshShohail <[email protected]>
ec26c91
to
b306f42
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tbh, this is too big for me to be able to review easily 😢
is there any chance we can break this down into more incremental PRs? like, could we make just the changes to allow pruning within gps first, then in a subsequent PR get rid of prune and change ensure's behavior?
return false | ||
} | ||
|
||
// pruneGoTestFiles deletes all Go test files (*_test.go) within baseDirr. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: Basedirr
) | ||
|
||
var ( | ||
// licenseFilePrefixes is a list of name prefixes for licesnse files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: licesnse
return err | ||
} | ||
|
||
// TODO(sdboyer) parallelize | ||
var wg sync.WaitGroup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also doing the parallelizing here? in general, would prefer to keep down the number of major changes in a single PR.
Closing this in favor of smaller PRs. 😁 |
What does this do / why do we need it?
This PR updates
gps.WriteDepTree
andWrite
ondep.*SafeWriter
to accept agps.PruneOptions
and a*log.Logger
to determine the pruning options when writingvendor/
and to enable verbose pruning.The manifest is updated to accept a new table,
prune
. This table defines pruning options accepted by dep. A constructor fordep.Manifest
is added to set the default PruneOptions.By default, dep will always prune nested vendor directories.
Users can define 3 additional rules:
non-go
: Prune non-Go files (will keep LICENSE & COPYING files)go-tests
: Prune Go test filesunused-packages
: Prune unused Go packages.What should your reviewer look out for in this PR?
Design comments and correctness as usual.
Which issue(s) does this PR fix?
fixes #944