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

Commit 46080f4

Browse files
authored
Tweak import warnings to prevent confusion (#1543)
* Removing warning when the constraint hint is empty. It's a common case and the lock may still be imported. * Fix warning to say lock instead of constraint when the lock hint cannot be resolved.
1 parent 3b8fbe4 commit 46080f4

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

internal/importers/base/importer.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func (i *Importer) ImportPackages(packages []ImportedPackage, defaultConstraintF
215215
isTag, version, err = i.isTag(pc.Ident, prj.LockHint)
216216
if err != nil {
217217
i.Logger.Printf(
218-
" Warning: Skipping project. Unable to apply constraint %q for %v: %s\n",
218+
" Warning: Skipping project. Unable to import lock %q for %v: %s\n",
219219
prj.LockHint, pc.Ident, err,
220220
)
221221
continue
@@ -263,10 +263,6 @@ func (i *Importer) ImportPackages(packages []ImportedPackage, defaultConstraintF
263263
Constraint: pc.Constraint,
264264
}
265265
fb.NewConstraintFeedback(pc, fb.DepTypeImported).LogFeedback(i.Logger)
266-
} else {
267-
if i.Verbose {
268-
i.Logger.Printf(" Skipping import of %v because its constraint is empty.\n", pc.Ident)
269-
}
270266
}
271267

272268
if version != nil {

internal/importers/base/importer_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ func TestBaseImporter_ImportProjects(t *testing.T) {
355355
"skip empty lock hints": {
356356
importertest.TestCase{
357357
WantRevision: "",
358-
WantWarning: "constraint is empty",
359358
},
360359
[]ImportedPackage{
361360
{
@@ -379,7 +378,6 @@ func TestBaseImporter_ImportProjects(t *testing.T) {
379378
"skip default source": {
380379
importertest.TestCase{
381380
WantSourceRepo: "",
382-
WantWarning: "constraint is empty",
383381
},
384382
[]ImportedPackage{
385383
{
@@ -415,7 +413,7 @@ func TestBaseImporter_ImportProjects(t *testing.T) {
415413
importertest.TestCase{
416414
WantSourceRepo: "",
417415
WantWarning: fmt.Sprintf(
418-
"Warning: Skipping project. Unable to apply constraint %q for %s",
416+
"Warning: Skipping project. Unable to import lock %q for %s",
419417
importertest.V1Tag, importertest.NonexistentPrj,
420418
),
421419
},

internal/importers/govendor/importer_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func TestGovendorConfig_Convert(t *testing.T) {
133133
},
134134
},
135135
importertest.TestCase{
136-
WantWarning: "constraint is empty",
136+
WantRevision: "",
137137
},
138138
},
139139
}

internal/importers/importertest/testcase.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ func (tc TestCase) validate(manifest *dep.Manifest, lock *dep.Lock, output *byte
150150
}
151151

152152
if tc.WantWarning != "" {
153-
if !strings.Contains(output.String(), tc.WantWarning) {
154-
return errors.Errorf("Expected the output to include the warning '%s'", tc.WantWarning)
153+
gotWarning := output.String()
154+
if !strings.Contains(gotWarning, tc.WantWarning) {
155+
return errors.Errorf("Expected the output to include the warning '%s' but got '%s'\n", tc.WantWarning, gotWarning)
155156
}
156157
}
157158

0 commit comments

Comments
 (0)