config/module: detect preserves forces

This commit is contained in:
Mitchell Hashimoto 2014-09-16 10:54:23 -07:00
parent 2a655bc7d9
commit 5480eb4e41
2 changed files with 9 additions and 1 deletions

View File

@ -48,9 +48,16 @@ func Detect(src string, pwd string) (string, error) {
continue
}
// Preserve the forced getter if it exists
var detectForce string
detectForce, result = getForcedGetter(result)
// Preserve the forced getter if it exists. We try to use the
// original set force first, followed by any force set by the
// detector.
if getForce != "" {
result = fmt.Sprintf("%s::%s", getForce, result)
} else if detectForce != "" {
result = fmt.Sprintf("%s::%s", detectForce, result)
}
return result, nil

View File

@ -13,6 +13,7 @@ func TestDetect(t *testing.T) {
}{
{"./foo", "/foo", "file:///foo/foo", false},
{"git::./foo", "/foo", "git::file:///foo/foo", false},
{"git::github.com/hashicorp/foo", "", "git::https://github.com/hashicorp/foo.git", false},
}
for i, tc := range cases {