Skip to content
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

execute module replacement in a single command #178

Merged
merged 2 commits into from
Apr 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,17 @@ func (b Builder) newEnvironment(ctx context.Context) (*environment, error) {
replaced := make(map[string]string)
for _, r := range b.Replacements {
log.Printf("[INFO] Replace %s => %s", r.Old.String(), r.New.String())
cmd := env.newGoModCommand(ctx, "edit",
"-replace", fmt.Sprintf("%s=%s", r.Old.Param(), r.New.Param()))
replaced[r.Old.String()] = r.New.String()
}
if len(replaced) > 0 {
cmd := env.newGoModCommand(ctx, "edit")
for o, n := range replaced {
cmd.Args = append(cmd.Args, "-replace", fmt.Sprintf("%s=%s", o, n))
}
err := env.runCommand(ctx, cmd)
if err != nil {
return nil, err
}
replaced[r.Old.String()] = r.New.String()
}

// check for early abort
Expand Down
Loading