From 319d04e4f314273554dba25e2c30b5c7a05a6bc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milutin=20Jovanovic=CC=81?= Date: Thu, 15 Jun 2017 17:35:58 -0400 Subject: [PATCH] Added check for multiple overrides in manifes files. --- manifest.go | 3 +++ manifest_test.go | 1 + testdata/manifest/error3.toml | 9 +++++++++ 3 files changed, 13 insertions(+) create mode 100644 testdata/manifest/error3.toml diff --git a/manifest.go b/manifest.go index 4e223ae0..6a4ce4f4 100644 --- a/manifest.go +++ b/manifest.go @@ -193,6 +193,9 @@ func fromRawManifest(raw rawManifest) (*Manifest, error) { if err != nil { return nil, err } + if _, exists := m.Ovr[name]; exists { + return nil, errors.Errorf("multiple overrides specified for %s, can only specify one", name) + } m.Ovr[name] = prj } diff --git a/manifest_test.go b/manifest_test.go index 80b4c035..a747b4f8 100644 --- a/manifest_test.go +++ b/manifest_test.go @@ -107,6 +107,7 @@ func TestReadManifestErrors(t *testing.T) { }{ {"multiple constraints", "manifest/error1.toml"}, {"multiple dependencies", "manifest/error2.toml"}, + {"multiple overrides", "manifest/error3.toml"}, } for _, tst := range tests { diff --git a/testdata/manifest/error3.toml b/testdata/manifest/error3.toml new file mode 100644 index 00000000..4d96624b --- /dev/null +++ b/testdata/manifest/error3.toml @@ -0,0 +1,9 @@ +ignored = ["github.com/foo/bar"] + +[[override]] + name = "github.com/golang/dep" + branch = "master" + +[[override]] + name = "github.com/golang/dep" + branch = "master"