mirror of
https://github.com/caddyserver/xcaddy.git
synced 2025-01-22 08:36:28 +01:00
Don't include version in replacement source
Follow-up to #69 I had a situation where caddy/v2 v2.4.6 was in my go.mod and a replace on it to use local caddy repo. When I ran `xcaddy run` to test a caddy module, it failed to run because the replace included the version v2.4.6, even though somehow the buildenv go.mod had v2.6.1 (the latest), and the replace directive specified @v2.4.6 only, so the replacement didn't happen. I don't think versions in the replacement source/origin are really that useful for xcaddy. If experience proves this wrong, we can figure out a better solution.
This commit is contained in:
parent
25c412f1ec
commit
e4c5f53dd2
3 changed files with 11 additions and 13 deletions
|
@ -292,8 +292,6 @@ func parseGoListJson(out []byte) (currentModule, moduleDir string, replacements
|
|||
continue
|
||||
}
|
||||
|
||||
src := mod.Path + "@" + mod.Version
|
||||
|
||||
// 1. Target is module, version is required in this case
|
||||
// 2A. Target is absolute path
|
||||
// 2B. Target is relative path, proper handling is required in this case
|
||||
|
@ -315,7 +313,7 @@ func parseGoListJson(out []byte) (currentModule, moduleDir string, replacements
|
|||
}
|
||||
}
|
||||
|
||||
replacements = append(replacements, xcaddy.NewReplace(src, dst))
|
||||
replacements = append(replacements, xcaddy.NewReplace(mod.Path, dst))
|
||||
}
|
||||
for _, idx := range unjoinedReplaces {
|
||||
unresolved := string(replacements[idx].New)
|
||||
|
|
|
@ -95,12 +95,12 @@ func TestParseGoListJson(t *testing.T) {
|
|||
t.Errorf("Unexpected module path")
|
||||
}
|
||||
expected := []xcaddy.Replace{
|
||||
xcaddy.NewReplace("replacetest1@v1.2.3", "golang.org/x/example@v0.0.0-20210811190340-787a929d5a0d"),
|
||||
xcaddy.NewReplace("replacetest2@v0.0.1", "golang.org/x/example@v0.0.0-20210407023211-09c3a5e06b5d"),
|
||||
xcaddy.NewReplace("replacetest3@v1.2.3", "/home/work/module/fork1"),
|
||||
xcaddy.NewReplace("replacetest1", "golang.org/x/example@v0.0.0-20210811190340-787a929d5a0d"),
|
||||
xcaddy.NewReplace("replacetest2", "golang.org/x/example@v0.0.0-20210407023211-09c3a5e06b5d"),
|
||||
xcaddy.NewReplace("replacetest3", "/home/work/module/fork1"),
|
||||
xcaddy.NewReplace("github.com/simnalamburt/module", "/home/work/module"),
|
||||
xcaddy.NewReplace("replacetest4@v0.0.1", "/srv/fork2"),
|
||||
xcaddy.NewReplace("replacetest5@v1.2.3", "/home/work/module/fork3"),
|
||||
xcaddy.NewReplace("replacetest4", "/srv/fork2"),
|
||||
xcaddy.NewReplace("replacetest5", "/home/work/module/fork3"),
|
||||
}
|
||||
if !reflect.DeepEqual(replacements, expected) {
|
||||
t.Errorf("Expected replacements '%v' but got '%v'", expected, replacements)
|
||||
|
|
|
@ -99,12 +99,12 @@ func TestParseGoListJson(t *testing.T) {
|
|||
t.Errorf("Unexpected module path")
|
||||
}
|
||||
expected := []xcaddy.Replace{
|
||||
xcaddy.NewReplace("replacetest1@v1.2.3", "golang.org/x/example@v0.0.0-20210811190340-787a929d5a0d"),
|
||||
xcaddy.NewReplace("replacetest2@v0.0.1", "golang.org/x/example@v0.0.0-20210407023211-09c3a5e06b5d"),
|
||||
xcaddy.NewReplace("replacetest3@v1.2.3", "C:\\Users\\work\\module\\fork1"),
|
||||
xcaddy.NewReplace("replacetest1", "golang.org/x/example@v0.0.0-20210811190340-787a929d5a0d"),
|
||||
xcaddy.NewReplace("replacetest2", "golang.org/x/example@v0.0.0-20210407023211-09c3a5e06b5d"),
|
||||
xcaddy.NewReplace("replacetest3", "C:\\Users\\work\\module\\fork1"),
|
||||
xcaddy.NewReplace("github.com/simnalamburt/module", "C:\\Users\\work\\module"),
|
||||
xcaddy.NewReplace("replacetest4@v0.0.1", "C:\\go\\fork2"),
|
||||
xcaddy.NewReplace("replacetest5@v1.2.3", "C:\\Users\\work\\module\\fork3"),
|
||||
xcaddy.NewReplace("replacetest4", "C:\\go\\fork2"),
|
||||
xcaddy.NewReplace("replacetest5", "C:\\Users\\work\\module\\fork3"),
|
||||
}
|
||||
if !reflect.DeepEqual(replacements, expected) {
|
||||
t.Errorf("Expected replacements '%v' but got '%v'", expected, replacements)
|
||||
|
|
Loading…
Reference in a new issue