mirror of
https://github.com/caddyserver/xcaddy.git
synced 2025-01-22 16:46:55 +01:00
accept replacements with branches of github forks (#51)
* accept replacements with branches of github forks Closes #50 * remove `!filepath.IsAbs(repl)` when checking path of replacement If the replacement path starts with a `.`, then the path is definitely not absolute.
This commit is contained in:
parent
83655481bf
commit
83bc5a7c58
2 changed files with 18 additions and 3 deletions
|
@ -76,7 +76,7 @@ func runBuild(ctx context.Context, args []string) error {
|
|||
})
|
||||
if repl != "" {
|
||||
// adjust relative replacements in current working directory since our temporary module is in a different directory
|
||||
if !filepath.IsAbs(repl) {
|
||||
if strings.HasPrefix(repl, ".") {
|
||||
repl, err = filepath.Abs(repl)
|
||||
if err != nil {
|
||||
log.Fatalf("[FATAL] %v", err)
|
||||
|
@ -288,9 +288,13 @@ func trapSignals(ctx context.Context, cancel context.CancelFunc) {
|
|||
func splitWith(arg string) (module, version, replace string, err error) {
|
||||
const versionSplit, replaceSplit = "@", "="
|
||||
|
||||
parts := strings.SplitN(arg, versionSplit, 2)
|
||||
module = parts[0]
|
||||
modules := strings.SplitN(arg, replaceSplit, 2)
|
||||
if len(modules) > 1 {
|
||||
replace = modules[1]
|
||||
}
|
||||
|
||||
parts := strings.SplitN(modules[0], versionSplit, 2)
|
||||
module = parts[0]
|
||||
if len(parts) == 1 {
|
||||
parts := strings.SplitN(module, replaceSplit, 2)
|
||||
if len(parts) > 1 {
|
||||
|
|
|
@ -33,6 +33,17 @@ func TestSplitWith(t *testing.T) {
|
|||
expectModule: "module",
|
||||
expectReplace: "replace",
|
||||
},
|
||||
{
|
||||
input: "module=replace@version",
|
||||
expectModule: "module",
|
||||
expectReplace: "replace@version",
|
||||
},
|
||||
{
|
||||
input: "module@version=replace@version",
|
||||
expectModule: "module",
|
||||
expectVersion: "version",
|
||||
expectReplace: "replace@version",
|
||||
},
|
||||
{
|
||||
input: "=replace",
|
||||
expectErr: true,
|
||||
|
|
Loading…
Reference in a new issue