@@ -451,6 +451,26 @@ func runMakeTargets() {
451
451
}
452
452
}
453
453
454
+ // hasMakefileConflict returns true if the Makefile (or makefile) is in conflict.
455
+ func hasMakefileConflict () bool {
456
+ // Check unmerged entries for Makefile/makefile.
457
+ out , err := exec .Command ("git" , "ls-files" , "-u" , "--" , "Makefile" , "makefile" ).Output ()
458
+ if err == nil && len (strings .TrimSpace (string (out ))) > 0 {
459
+ return true
460
+ }
461
+
462
+ // Fallback: file content contains conflict markers.
463
+ check := func (p string ) bool {
464
+ b , err := os .ReadFile (p )
465
+ if err != nil {
466
+ return false
467
+ }
468
+ s := string (b )
469
+ return strings .Contains (s , "<<<<<<<" ) && strings .Contains (s , "=======" ) && strings .Contains (s , ">>>>>>>" )
470
+ }
471
+ return check ("Makefile" ) || check ("makefile" )
472
+ }
473
+
454
474
// runAlphaGenerate executes the old Kubebuilder version's 'alpha generate' command
455
475
// to create clean scaffolding in the ancestor branch. This uses the downloaded
456
476
// binary with the original PROJECT file to recreate the project's initial state.
@@ -581,7 +601,11 @@ func (opts *Update) mergeOriginalToUpgrade() (bool, error) {
581
601
}
582
602
583
603
// Best effort to run make targets to ensure the project is in a good state
584
- runMakeTargets ()
604
+ if hasMakefileConflict () {
605
+ log .Warn ("Skipping make targets because the Makefile has merge conflicts." )
606
+ } else {
607
+ runMakeTargets ()
608
+ }
585
609
586
610
// Step 4: Stage and commit
587
611
if err := exec .Command ("git" , "add" , "--all" ).Run (); err != nil {
0 commit comments