-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't do module replacement with github forks #50
Comments
Hmm, wouldn't you just change the |
No because that would imply the master branch, but if it's not on the master branch that won't work. |
Set the version of that require directive to another branch then? |
What do you mean? What would the command look like? |
so instead of a version on the master branch, choose a different branch name. |
Right but you would do that with |
I mean do this instead:
|
That won't work because the |
Oh... I see... how does the |
It does it just fine if you specify |
FWIW, I started working on it last night but didn't finish it. This is where I'm at now. Diff: diff --git a/cmd/xcaddy/main.go b/cmd/xcaddy/main.go
index 001f462..39d8b72 100644
--- a/cmd/xcaddy/main.go
+++ b/cmd/xcaddy/main.go
@@ -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, ".") && !filepath.IsAbs(repl) {
repl, err = filepath.Abs(repl)
if err != nil {
log.Fatalf("[FATAL] %v", err)
@@ -288,7 +288,9 @@ 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)
+ modules := strings.SplitN(arg, replaceSplit, 2)
+
+ parts := strings.SplitN(modules[0], versionSplit, 2)
module = parts[0]
if len(parts) == 1 { Test run:
|
It also needs to support |
Hence
😄 |
* 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.
So I want to have a replacement like:
So I try this:
But it does this:
This obviously isn't quite right, cause it never did the
go mod edit -replace
.Next I tried without
@caddyfile
(my branch), and I get this:So
xcaddy
thinks that path is relative but it's not, it's a git repo.I think to detect if it's relative, we should look if there's a
.
in front, so if you want to refer to something in the current dir then you do./blah
in the replacement. That should allow github module paths to work.The workaround obviously for now is to
git clone
the relevant repo then use a relative path on that, but it would be nice so that people can easily test branches/PRs for plugins without cloning.The text was updated successfully, but these errors were encountered: