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

Add support importing from govend #1040

Merged

Conversation

RaviTezu
Copy link
Contributor

What does this do / why do we need it?

This PR includes the support importing from govend.

What should your reviewer look out for in this PR?

dep int now looks for vendor.yml file and converts it to Gopkg.toml and Gopkg.lock.

Do you need help or clarification on anything?

I see the go test is failing for when I run it in cmd/dep.

--- FAIL: TestIntegration (0.00s)
    --- FAIL: TestIntegration/init/govend/case1 (0.00s)
        --- FAIL: TestIntegration/init/govend/case1/external (8.39s)

However, when I run, go test on the govend/case1 is it passing:

λ terminator dep → go test github.com/golang/dep/cmd/dep -run testdata/harness_tests/init/govend/case1         
ok  	github.com/golang/dep/cmd/dep	2.014s

Which issue(s) does this PR fix?

Fixes #998

@RaviTezu
Copy link
Contributor Author

@carolynvs Can you please take a look, when you have a minute? Thank you.

@RaviTezu
Copy link
Contributor Author

Sorry, I forgot to mention this:
https://ci.appveyor.com/project/golang/dep/build/1821
I am not sure, why the test is failing, even if the got and expected are same.

analyzer-version = 1
inputs-digest = "1ed417a0bec57ffe988fae1cba8f3d49994fb893394d61844e0b3c96d69573fe"
solver-name = "gps-cdcl"
solver-version = 1
Copy link

Choose a reason for hiding this comment

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

Newline at the end of the file should fix the failing tests ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops! I am Sorry. Thanks @bpicode .
It solved the failing tests :)

func (g *govendImporter) convert(pr gps.ProjectRoot) (*dep.Manifest, *dep.Lock, error) {
g.logger.Println("Converting from vendor.yaml...")

manifest := &dep.Manifest{
Copy link
Collaborator

Choose a reason for hiding this comment

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

#1019 just got merged. Let's use the new Manifest constructor here.

"github.com/sdboyer/deptest",
"github.com/sdboyer/deptestdos"
]
}
Copy link
Collaborator

@darkowlzz darkowlzz Aug 22, 2017

Choose a reason for hiding this comment

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

No newline at EOF. Let's avoid this and add a newline.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a newline char at the EOF. But looks like github is not detecting it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This works :)

// Disable verbose so that we don't print values that change each test run
g := newGovendImporter(logger, false, sm)
if !g.HasDepMetadata(projectRoot) {
t.Fatal("Expected the importer to detect godep configuration file")
Copy link
Collaborator

Choose a reason for hiding this comment

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

godep govend

@RaviTezu RaviTezu force-pushed the add-support-for-importing-from-govend branch from b6b6ae7 to 4603971 Compare August 22, 2017 09:25
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.

Just a few very small changes, and I think this is good!

FYI, we have recently merged a PR (#992) which switches the importer tests over to use a set of common validations. However I really don't want to hold up this PR, and we can tackle that in a separate PR once this is in.

EDIT: Oops, ignore this comment. 😊 It's the vndr importer, not this one, that needs to switch to using the new validations. I'll take care of that right now.

g.logger.Println("Detected govend configuration files...")
y := filepath.Join(projectDir, govendYAMLName)
if g.verbose {
g.logger.Printf(" Loading %s", y)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: This should be two spaces, not a tab.

for _, pkg := range g.yaml.Imports {
// Path must not be empty
if pkg.Path == "" || pkg.Revision == "" {
return nil, nil, errors.New("Invalid govend configuration, Path or Rev is required")
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I think it will help people if we use the exact same words used in the config file, so "path and rev are required".

pp := getProjectPropertiesFromVersion(version)
if pp.Constraint != nil {
pc, err := g.buildProjectConstraint(pkg, pp.Constraint.String())
if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I realize this isn't in the other importers yet, but we'd like to have import keep going even when we can't guess a constraint from the revision. See #907.

So when buildProjectConstraint returns an error, let's log a warning like "Unable to infer a constraint for REVISION", and then skip adding the constraint to the manifest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@carolynvs Done. Please take a look.

@carolynvs carolynvs removed the request for review from sdboyer August 23, 2017 17:14
@RaviTezu RaviTezu force-pushed the add-support-for-importing-from-govend branch from 4603971 to b28420b Compare August 24, 2017 05:31
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.

Sweet! Thank you for adding support for govend! 💖

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.

Support importing from govend
5 participants