-
Notifications
You must be signed in to change notification settings - Fork 1k
Conversation
cmd/dep/gom_importer.go
Outdated
lp := gps.NewLockedProject(pi, version, nil) | ||
lock.P = append(lock.P, lp) | ||
} | ||
manifest.Constraints[pc.Ident.ProjectRoot] = gps.ProjectProperties{Source: pc.Ident.Source, Constraint: 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.
Did you intend to always leave the constraint in the manifest nil
? When the gomfile specifies :tag => '1.0.0'
, or :branch => 'master'
for example, both are valid constraints that can be figured out using deduceConstraint
.
I consider about production/develop environments for gom. But maybe, all of packages writen in Gomfile should be exported in Gopkg.toml. So I'll remove [WIP] and [DO NOT MERGE]. |
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.
Thanks for adding support for gom! Really excited to get this incorporated. 🎉
lock := &dep.Lock{} | ||
|
||
for _, pkg := range g.goms { | ||
// Obtain ProjectRoot. Required for avoiding sub-package imports. |
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 it valid config to specify a sub-package? For example:
Gomfile
gom 'github.com/davecgh/go-spew/spew', :tag => 'v1.1.0'
If not, then you can remove the logic that detects the project root and check if the project exists in the lock.
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 don't clearly understand what you mean. Yes, it's valid entry in Gomfile.
cmd/dep/gom_importer.go
Outdated
g.logger.Printf(warn.Error()) | ||
version = revision | ||
} | ||
feedback(version, pi.ProjectRoot, fb.DepTypeImported, g.logger) |
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.
You'll need to rebase to get the latest changes to the feedback function. It has been deprecated. Here's an example of the updated feedback usage.
It is new separate calls for logging feedback for a constraint and a locked project, so you'll need to add more feedback after setting the constraint in the manifest.
cmd/dep/gom_importer_test.go
Outdated
} | ||
} | ||
|
||
func TestGomConfig_ProjectExistsInLock(t *testing.T) { |
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 is a duplicate test of
dep/cmd/dep/godep_importer_test.go
Line 305 in cc11274
func TestGodepConfig_ProjectExistsInLock(t *testing.T) { |
cmd/dep/gom_importer_test.go
Outdated
} | ||
|
||
// Compares two slices of gomPackage and checks if they are equal. | ||
func equalGomImports(a, b []gomPackage) bool { |
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 looks like it's unused?
@@ -0,0 +1,2 @@ | |||
gom "github.com/sdboyer/deptest", :commit => "3f4c3bea144e112a69bbe5d8d01c1b09a544253f" |
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 notice that this only has testdata for :commit
and not :tag
or :branch
. Since we also need an integration test for dep init
importing a gomfile, see godep for an integration test example, you could include those in that new integration test.
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.
It is important that tests for :branch
and :tag
are added, in addition to an integration test.
bump |
revision := gps.Revision(rev) | ||
version, err := lookupVersionForLockedProject(pi, pc.Constraint, revision, g.sm) | ||
if err != nil { | ||
warn := errors.Wrapf(err, "Unable to lookup the version represented by %s in %s. Falling back to locking the revision only.", rev, pi.ProjectRoot) |
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.
The warning message, and falling back to the revision is now handled in lookupVersionForLockedProject
, so you can just print the err if it's present, and remove the version = revision
assignment.
See the godep importer for an example.
@@ -0,0 +1,4 @@ | |||
Detected Gomfile... | |||
Converting from Gomfile ... | |||
Trying v0.8.1 (3f4c3be) as initial lock for imported dep github.com/sdboyer/deptest |
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.
There should be 2 extra lines in the output, looks like it is missing the constraints and is only printing the locked projects.
pc.Ident = pi | ||
|
||
if rev != "" { | ||
pc.Constraint, err = g.sm.InferConstraint(rev, pc.Ident) |
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.
When revision == ""
, you should set the constraint to gps.Any()
.
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.
Ah, I didn't know gps.Any(). Okay, will do it in later.
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.
After thinking about this more, I think the right answer is to do that in InferConstraint
, so that when an empty string is passed, it returns gps.Any()
. I'll submit a PR for that in a bit.
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 submitted #901 so that all importers get this for free when calling InferConstraint
.
return nil, nil, err | ||
} | ||
|
||
revision := gps.Revision(rev) |
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 am not sure what you are doing on this line? This won't be valid when rev
is a branch or a tag.
I noticed that you first try to load a gomfile.lock
and fallback to a gomfile
. Does the gomfile.lock
contain just :commit
entries and the gomefile
contain entries for :branch
and :tag
? With other dependency managers, like glide, there are two files and we use both. One to import constraints and the other to know which revision to put in the lock.
At a high level what needs to happen here is this:
- If a constraint such as a branch or tag is available, it should be used as the constraint in the manifest. Otherwise, use
gps.Any()
. We don't want to put a revision/commit in the constraint. - Log the constraint using
f := fb.NewConstraintFeedback(pc, fb.DepTypeImported).LogFeedback(g.logger)
. - Call
lookupVersionForLockedProject
passing in the project, the constraint from the first step and the revision (:commit
) from the lock. - Make a locked project and log it.
@@ -0,0 +1,2 @@ | |||
gom "github.com/sdboyer/deptest", :commit => "3f4c3bea144e112a69bbe5d8d01c1b09a544253f" |
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.
It is important that tests for :branch
and :tag
are added, in addition to an integration test.
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! |
Adds Gomfile importer support to init.
TODO
* add detection for production/test environments