@@ -316,6 +316,26 @@ func runMakeTargets() {
316316 }
317317}
318318
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+
319339// runAlphaGenerate executes the old Kubebuilder version's 'alpha generate' command
320340// to create clean scaffolding in the ancestor branch. This uses the downloaded
321341// binary with the original PROJECT file to recreate the project's initial state.
@@ -446,7 +466,11 @@ func (opts *Update) mergeOriginalToUpgrade() (bool, error) {
446466 }
447467
448468 // 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+ }
450474
451475 // Step 4: Stage and commit
452476 if err := exec .Command ("git" , "add" , "--all" ).Run (); err != nil {
0 commit comments