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

Fixes #907 Warn when an importer cannot preserve a constraint #1086

Closed
wants to merge 3 commits into from

Conversation

djosephsen
Copy link
Contributor

What does this do / why do we need it?

This fixes issue #907

What should your reviewer look out for in this PR?

nothin

Do you need help or clarification on anything?

nope

Which issue(s) does this PR fix?

#907

@@ -202,7 +202,8 @@ func (g *glideImporter) buildProjectConstraint(pkg glidePackage) (pc gps.Project
}
pc.Constraint, err = g.sm.InferConstraint(pkg.Reference, pc.Ident)
if err != nil {
return
g.logger.Printf("Unable to interpret revision specifier '%s' for package %s: %s", pkg.Name, pc.Ident, err.Error())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these have trailing newlines \n?

I also wonder if it would be helpful to explicitly mention that Any is being used instead, or if that is the implied default or sufficiently documented elsewhere.

Copy link
Collaborator

@carolynvs carolynvs Aug 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, the default for the importers is to use the any constraint whenever they can't determine something more specific. This ensures that imported dependencies (direct only) are always included in the generated manifest.

This behavior is not documented because we don't currently doc how the importers work. I am knee deep in redoing the importer plumbing, and when I submit that PR, will add doc for the general heuristic used by all importers.

Copy link
Collaborator

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need a unit test for each importer to verify that the function continues, returning a lock/manifest and prints the warning.

Here is an example of a similar unit test:

https://github.com/golang/dep/blob/master/cmd/dep/glide_importer_test.go#L185

The "bad constraint" version of that test will need a new config file (that has a unparsable constraint) and golden output file that contains your warning.

@@ -202,7 +202,8 @@ func (g *glideImporter) buildProjectConstraint(pkg glidePackage) (pc gps.Project
}
pc.Constraint, err = g.sm.InferConstraint(pkg.Reference, pc.Ident)
if err != nil {
return
g.logger.Printf("Unable to interpret revision specifier '%s' for package %s: %s, (using the 'any' constraint instead)\n", pkg.Name, pc.Ident, err.Error())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The wrong variable is being passed in as the first fmt argument. We want to print the value passed to InferConstraint which was pkg.Reference.
  • Change "revision specifier" to "constraint" in the warning.

@@ -158,7 +158,8 @@ func (g *godepImporter) buildProjectConstraint(pkg godepPackage) (pc gps.Project
pc.Ident = gps.ProjectIdentifier{ProjectRoot: gps.ProjectRoot(pkg.ImportPath)}
pc.Constraint, err = g.sm.InferConstraint(pkg.Comment, pc.Ident)
if err != nil {
return
g.logger.Printf("Unable to interpret revision specifier '%s' for package %s: %s, (using the 'any' constraint instead)\n", pkg.ImportPath, pc.Ident, err.Error())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above, only this time it's pkg.Comment for the first argument.

@mvdan
Copy link
Member

mvdan commented Sep 4, 2020

Dep was officially deprecated earlier this year, and the proposal to archive this repository was accepted. As such, I'm closing outstanding issues before archiving the repository. For any further comments, please use the proposal thread on the Go issue tracker. Thanks!

@mvdan mvdan closed this Sep 4, 2020
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.

6 participants