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

cmd/dep: Move importers under internal/importers #1145

Merged
merged 4 commits into from
Sep 14, 2017

Conversation

carolynvs
Copy link
Collaborator

What does this do / why do we need it?

As the set of importers grow, it's really cluttering up the cmd/dep pkg. Here's the new structure:

internal/importers
- importertest (shared testcase logic for the importer tests)
- base (base importer implementation)
- glide/godep/vndr/govendor

What should your reviewer look out for in this PR?

I made a test package for the importer tests, so that they don't all have to be grouped into a single package. It really helped simplify the names. I don't think it will end up in the compiled dep binary because only tests reference it. Correct me if I'm wrong though!

Do you need help or clarification on anything?

Nope

Which issue(s) does this PR fix?

N/A

I think all the file based tests for the importers can be consolidated into a single test (like I did with the convert testcases) but I'll try that out in a separate PR after this is merged.

@sdboyer
Copy link
Member

sdboyer commented Sep 10, 2017

this seems like a good idea to me. don't forget to update CODEOWNERS, too 😄

Copy link
Member

@sdboyer sdboyer left a comment

Choose a reason for hiding this comment

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

looks really good overall, just some small things

@@ -167,6 +167,33 @@ type ProjectProperties struct {
Constraint Constraint
}

// GetProjectPropertiesFromVersion takes a Version and returns a proper
// ProjectProperties with Constraint value based on the provided version.
func GetProjectPropertiesFromVersion(v Version) ProjectProperties {
Copy link
Member

Choose a reason for hiding this comment

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

If we're gonna do this, it needs to mirror the NewSemverConstraint(), NewSemverConstraintIC() duality.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe this is only helpful to dep anyway. I'll think about doing as you suggested vs. moving into some other pkg under internal.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I ended up moving it back where it was and using a slimmed down version of it in the importers.

type Importer struct {
Logger *log.Logger
Verbose bool
Sm gps.SourceManager
Copy link
Member

Choose a reason for hiding this comment

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

Let's make this SourceManager instead. Need to behave ourselves when exporting 😄

got := verboseOutput.String()
want := h.GetTestFileString(goldenFile)
if want != got {
Want := h.GetTestFileString(goldenFile)
Copy link
Member

Choose a reason for hiding this comment

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

unnecessary capitalization - makes me wonder if there might be a few more of these that i've missed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Doh! My find/replace was a bit too greedy! I'll find the rest.

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
Copy link
Member

Choose a reason for hiding this comment

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

is it a bit redundant to name the file godep_importer.go if we're already in a package/dir named godep?

Copy link
Collaborator

@jmank88 jmank88 left a comment

Choose a reason for hiding this comment

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

LGTM besides some naming.

Seems like some find/replaces went too far in a few spots (local vars, comments) s/Want/want and s/Verbose/verbose

@@ -172,7 +172,7 @@ func (i *baseImporter) loadPackages(packages []importedPackage) ([]importedProje
// * Revision constraints are ignored.
// * Versions that don't satisfy the constraint, drop the constraint.
// * Untagged revisions ignore non-branch constraint hints.
func (i *baseImporter) importPackages(packages []importedPackage, defaultConstraintFromLock bool) (err error) {
func (i *Importer) ImportPackages(packages []ImportedPackage, DefaultConstraintFromLock bool) (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.

s/DefaultConstraintFromLock/defaultConstraintFromLock

type Importer struct {
Logger *log.Logger
Verbose bool
Sm gps.SourceManager
Copy link
Collaborator

Choose a reason for hiding this comment

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

s/Sm/SM?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm going to go with Sam's suggestion of SourceManager.

@carolynvs carolynvs force-pushed the importers-package branch 3 times, most recently from 7c84fe3 to 00cd514 Compare September 10, 2017 02:29
@sdboyer
Copy link
Member

sdboyer commented Sep 10, 2017

that appveyor failure seems like it should be ephemeral, but i can't force it to retest until the merge conflicts are resolved

@carolynvs
Copy link
Collaborator Author

carolynvs commented Sep 11, 2017

Rebased. Appveyor is now appeased. 😀

@carolynvs carolynvs merged commit d62440d into golang:master Sep 14, 2017
@carolynvs carolynvs deleted the importers-package branch September 14, 2017 19:31
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants