Skip to content

Commit 2dd2403

Browse files
Ivan GorshkovIvan Gorshkov
authored andcommitted
Catching conflict error from the generator
1 parent 9d0e1f2 commit 2dd2403

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

internal/run/target.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/speakeasy-api/speakeasy/internal/git"
2323
"github.com/speakeasy-api/speakeasy/internal/links"
2424
"github.com/speakeasy-api/speakeasy/internal/log"
25+
"github.com/speakeasy-api/speakeasy/internal/registercustomcode"
2526
"github.com/speakeasy-api/speakeasy/internal/sdkchangelog"
2627
"github.com/speakeasy-api/speakeasy/internal/sdkgen"
2728
"github.com/speakeasy-api/speakeasy/internal/utils"
@@ -229,6 +230,27 @@ func (w *Workflow) runTarget(ctx context.Context, target string) (*SourceResult,
229230
},
230231
)
231232
if err != nil {
233+
// Check if this is a custom code conflict
234+
if strings.Contains(err.Error(), "CUSTOM_CODE_CONFLICT_DETECTED:") {
235+
// Print banner
236+
fmt.Println("\n" + strings.Repeat("=", 70))
237+
fmt.Println("CUSTOM CODE CONFLICTS DETECTED")
238+
fmt.Println(strings.Repeat("=", 70))
239+
fmt.Println("\nThe SDK was generated successfully, but your custom code patches")
240+
fmt.Println("conflict with the new generation and cannot be applied automatically.")
241+
fmt.Println("\nEntering automatic conflict resolution mode...")
242+
fmt.Println(strings.Repeat("=", 70) + "\n")
243+
244+
// Automatically trigger conflict resolution for all targets
245+
if resolveErr := registercustomcode.ResolveCustomCodeConflicts(ctx); resolveErr != nil {
246+
return sourceRes, nil, fmt.Errorf("automatic conflict resolution setup failed: %w", resolveErr)
247+
}
248+
249+
// Exit with code 2 to indicate manual action needed
250+
os.Exit(2)
251+
}
252+
253+
// Real generation errors
232254
return sourceRes, nil, err
233255
}
234256
w.generationAccess = generationAccess

0 commit comments

Comments
 (0)