-
Notifications
You must be signed in to change notification settings - Fork 1k
Honor per-project prune options correctly #1570
Conversation
This new type defers computation of the actual prune value for a given project until the method is called, rather than trying to precompute it. By deferring computation, we retain full fidelity on the original cascading inputs. Still a WIP hack - need to clean up, and make everything actually use this.
cbd4214
to
53bd31c
Compare
All old types are now gone, tests are fixed, and test coverage should be adequate for emergency purposes.
53bd31c
to
877b793
Compare
manifest.go
Outdated
const ( | ||
pvnone uint8 = 0 // No per-project prune value was set in Gopkg.toml. | ||
pvtrue uint8 = 1 // Per-project prune value was explicitly set to true. | ||
pvfalse uint8 = 2 // Per-project prune value was explicitly set to true. |
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.
s/true/false/
return ops | ||
} | ||
|
||
func defaultCascadingPruneOptions() CascadingPruneOptions { |
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.
Maybe export this instead of having multiple copies of it?
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 intentionally didn't export it, as i don't think it's worth polluting the package interface with it.
manifest.go
Outdated
m, err := fromRawManifest(raw) | ||
//warns = append(warns, checkRedundantPruneOptions(m)...) |
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.
Intentional?
@@ -91,12 +84,22 @@ const ( | |||
pruneOptionNonGo = "non-go" | |||
) | |||
|
|||
// Constants to represents per-project prune uint8 values. |
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.
s/represents/represent, or maybe just: Per-project prune values.
@@ -91,12 +84,22 @@ const ( | |||
pruneOptionNonGo = "non-go" | |||
) | |||
|
|||
// Constants to represents per-project prune uint8 values. | |||
const ( | |||
pvnone uint8 = 0 // No per-project prune value was set in Gopkg.toml. |
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.
Did you consider using iota
?
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 preferred this form because:
- it is visually explicit, and the sole purpose of having these types is for the reader
- while it happens to be true that iota enumerates the first three values traditionally used in a trinary, iotas are not for expressing trinaries.
manifest.go
Outdated
func fromRawPruneOptions(raw rawPruneOptions) (gps.CascadingPruneOptions, error) { | ||
opts := gps.CascadingPruneOptions{ | ||
DefaultOptions: gps.PruneNestedVendorDirs, | ||
PerProjectOptions: make(map[gps.ProjectRoot]gps.PruneOptionSet), |
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.
Could make w/cap: len(raw.Projects)
Our TOML lib doesn't support decoding directly into interface{} types, so our only short-term choice is to decode...for a third time, and operate directly on that.
This will make the transition easier for people with automation already built around the old dep prune. We'll remove the logic again for the next release.
What does this do / why do we need it?
We don't actually honor per-project prune options correctly.
This new type defers computation of the actual prune value for a given project until the method is called, rather than trying to precompute it. By deferring computation, we retain full fidelity on the original cascading inputs.
This is an emergency fix, so i'm pushing it through fast.
fixes #1561