Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

Honor per-project prune options correctly #1570

Merged
merged 7 commits into from
Jan 24, 2018

Conversation

sdboyer
Copy link
Member

@sdboyer sdboyer commented Jan 24, 2018

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

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.
@sdboyer sdboyer changed the title Introduce CascadingPruneOptions Honor per-project prune options correctly Jan 24, 2018
All old types are now gone, tests are fixed, and test coverage should be
adequate for emergency purposes.
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.
Copy link
Collaborator

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 {
Copy link
Collaborator

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?

Copy link
Member Author

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)...)
Copy link
Collaborator

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.
Copy link
Collaborator

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.
Copy link
Collaborator

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?

Copy link
Member Author

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:

  1. it is visually explicit, and the sole purpose of having these types is for the reader
  2. 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),
Copy link
Collaborator

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.
@sdboyer sdboyer merged commit de0548c into golang:master Jan 24, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Per-project prune options are ignored
4 participants