@@ -316,6 +316,26 @@ func runMakeTargets() {
316
316
}
317
317
}
318
318
319
+ // hasMakefileConflict returns true if the Makefile (or makefile) is in conflict.
320
+ func hasMakefileConflict () bool {
321
+ // Check unmerged entries for Makefile/makefile.
322
+ out , err := exec .Command ("git" , "ls-files" , "-u" , "--" , "Makefile" , "makefile" ).Output ()
323
+ if err == nil && len (strings .TrimSpace (string (out ))) > 0 {
324
+ return true
325
+ }
326
+
327
+ // Fallback: file content contains conflict markers.
328
+ check := func (p string ) bool {
329
+ b , err := os .ReadFile (p )
330
+ if err != nil {
331
+ return false
332
+ }
333
+ s := string (b )
334
+ return strings .Contains (s , "<<<<<<<" ) && strings .Contains (s , "=======" ) && strings .Contains (s , ">>>>>>>" )
335
+ }
336
+ return check ("Makefile" ) || check ("makefile" )
337
+ }
338
+
319
339
// runAlphaGenerate executes the old Kubebuilder version's 'alpha generate' command
320
340
// to create clean scaffolding in the ancestor branch. This uses the downloaded
321
341
// binary with the original PROJECT file to recreate the project's initial state.
@@ -446,7 +466,11 @@ func (opts *Update) mergeOriginalToUpgrade() (bool, error) {
446
466
}
447
467
448
468
// Best effort to run make targets to ensure the project is in a good state
449
- runMakeTargets ()
469
+ if hasMakefileConflict () {
470
+ log .Warn ("Skipping make targets because the Makefile has merge conflicts." )
471
+ } else {
472
+ runMakeTargets ()
473
+ }
450
474
451
475
// Step 4: Stage and commit
452
476
if err := exec .Command ("git" , "add" , "--all" ).Run (); err != nil {
0 commit comments