Skip to content

Commit e04eaab

Browse files
committed
fix: inline functions
1 parent 485828b commit e04eaab

File tree

2 files changed

+14
-29
lines changed

2 files changed

+14
-29
lines changed

CLAUDE.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ Launchr is a CLI action runner that executes tasks defined in YAML files across
7676
- Mutex-protected operations for concurrency safety
7777
- `fs.FS` interface for filesystem abstraction
7878
- JSON Schema validation for inputs and configuration
79-
- **Plugin Replacement Logic**: In `plugins/builder/environment.go:133-149`, when downloading plugins during build, the system uses a two-phase approach:
80-
1. **Subpath Detection**: Skip plugins that are subpaths of replaced modules (`p.Path != repl && strings.HasPrefix(p.Path, repl)`) using labeled loop control
81-
2. **Exact Match Handling**: Process plugins that exactly match replaced modules (`p.Path == repl`) as replaced plugins requiring special handling
82-
83-
This prevents downloading dependencies for sub-plugins when their parent module is replaced while ensuring exact matches are handled correctly.
79+
- **Plugin Replacement Logic**: In `plugins/builder/environment.go`, the system handles Go module replacements:
80+
- When ensuring modules are required, the system checks if a module is explicitly replaced (exact match) or if a plugin is a subpath of any replaced module (`p.Path != repl && strings.HasPrefix(p.Path, repl)`) to skip downloading its dependencies. This logic is inlined for direct use.
81+
- `ensureModuleRequired(ctx, modulePath, modReplace)`: This method ensures that a module is correctly added to `go.mod`, using a placeholder version if the module is replaced.
82+
83+
This approach ensures that exact module replacements are handled correctly, while sub-plugins of replaced modules are properly skipped during dependency resolution, preventing unnecessary downloads and maintaining module integrity.
8484

8585
### Execution Flow
8686

plugins/builder/environment.go

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -80,31 +80,17 @@ func newBuildEnvironment(streams launchr.Streams) (*buildEnvironment, error) {
8080
}, nil
8181
}
8282

83-
// isModuleReplaced checks if a module path is present in the module replacements map.
84-
// It returns true if the module is replaced, and the replacement path if it is.
85-
func isModuleReplaced(modulePath string, modReplace map[string]string) (bool, string) {
86-
for replPath, replTarget := range modReplace {
87-
// Check for exact match first
88-
if modulePath == replPath {
89-
return true, replTarget
90-
}
91-
// Check if the module path is a subpath of a replaced module
92-
if strings.HasPrefix(modulePath, replPath) {
93-
// We consider it replaced if it's a subpath, but we don't need the target path here.
94-
// The logic for handling subpaths is to skip them for 'go get',
95-
// but the commit's intent seems to be to treat them as replaced for 'go mod edit'.
96-
// For simplification, we'll treat any prefix match as a "replacement" for the purpose of `go mod edit`.
97-
// A more precise approach might be needed if subpaths should be handled differently.
98-
return true, "" // Target path not strictly needed for `go mod edit -require` logic here
99-
}
100-
}
101-
return false, ""
102-
}
103-
10483
// ensureModuleRequired adds a module to go.mod if it's not already there or if it's replaced.
10584
// It uses a placeholder version for replaced modules.
10685
func (env *buildEnvironment) ensureModuleRequired(ctx context.Context, modulePath string, modReplace map[string]string) error {
107-
replaced, _ := isModuleReplaced(modulePath, modReplace)
86+
// Check if the module is replaced (exact match).
87+
replaced := false
88+
for replPath := range modReplace {
89+
if modulePath == replPath {
90+
replaced = true
91+
break
92+
}
93+
}
10894

10995
pkgStr := modulePath
11096
if replaced {
@@ -165,8 +151,7 @@ func (env *buildEnvironment) CreateModFile(ctx context.Context, opts *BuildOptio
165151

166152
// Ensure plugins are required.
167153
for _, p := range opts.Plugins {
168-
// Skip plugins that are subpaths of replaced modules, as per original logic.
169-
// The `isModuleReplaced` function handles the prefix check.
154+
// Skip plugins that are subpaths of replaced modules.
170155
isSubpath := false
171156
for repl := range opts.ModReplace {
172157
if p.Path != repl && strings.HasPrefix(p.Path, repl) {

0 commit comments

Comments
 (0)