config/module: detect preserves forces
This commit is contained in:
parent
2a655bc7d9
commit
5480eb4e41
|
@ -48,9 +48,16 @@ func Detect(src string, pwd string) (string, error) {
|
||||||
continue
|
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 != "" {
|
if getForce != "" {
|
||||||
result = fmt.Sprintf("%s::%s", getForce, result)
|
result = fmt.Sprintf("%s::%s", getForce, result)
|
||||||
|
} else if detectForce != "" {
|
||||||
|
result = fmt.Sprintf("%s::%s", detectForce, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|
|
@ -13,6 +13,7 @@ func TestDetect(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{"./foo", "/foo", "file:///foo/foo", false},
|
{"./foo", "/foo", "file:///foo/foo", false},
|
||||||
{"git::./foo", "/foo", "git::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 {
|
for i, tc := range cases {
|
||||||
|
|
Loading…
Reference in New Issue