Commit ba92717fe64e

Vincent Demeester <vincent@sbr.pm>
2026-02-02 15:46:36
fix(flake-updater): handle AUTO_MERGE=1 from Nix boolean conversion
Nix converts boolean 'true' to '1' in toString, not 'true'. Check for both '1' and 'true' to handle auto-merge properly.
1 parent 6765f9d
Changed files (1)
tools
nix-flake-update
tools/nix-flake-update/nix-flake-update.sh
@@ -194,58 +194,56 @@ Built systems: $BUILD_SYSTEMS
 
     git commit -m "$COMMIT_MSG"
 
-    if [ "$DRY_RUN" = "false" ]; then
-      if [ "$AUTO_MERGE" = "true" ]; then
-        # Auto-merge: rebase onto main and push directly
-        log "Auto-merge enabled: rebasing onto $GIT_REMOTE/$MAIN_BRANCH"
-        
-        # Fetch latest main
-        git fetch "$GIT_REMOTE" "$MAIN_BRANCH"
-        
-        # Rebase our commit onto main
-        if git rebase "$GIT_REMOTE/$MAIN_BRANCH"; then
-          log "Rebase successful, pushing to $GIT_REMOTE/$MAIN_BRANCH"
-          
-          # Push directly to main
-          git push "$GIT_REMOTE" "HEAD:$MAIN_BRANCH"
-          
-          # Notify success
-          notify "default" "✅ Flake Auto-Updated & Merged" \
-            "Updates for $input_desc merged to $MAIN_BRANCH. All builds passed: $BUILD_SYSTEMS" \
-            "white_check_mark,flake,merged"
-          
-          log "SUCCESS: Flake updated and merged to $MAIN_BRANCH"
-        else
-          log "ERROR: Rebase failed, main branch may have moved"
-          git rebase --abort || true
-          
-          add_todo_to_inbox "Flake update rebase conflict" \
-            "Auto-merge failed due to rebase conflict.
-Inputs: $input_desc
-Branch: $BRANCH_NAME (in worktree, needs manual rebase)"
-          
-          notify "high" "⚠️ Flake Update Rebase Failed" \
-            "Could not rebase $input_desc onto $MAIN_BRANCH. TODO added to inbox." \
-            "warning,flake,conflict"
-          exit 1
-        fi
-      else
-        # Branch mode: push to feature branch
-        log "Pushing to $GIT_REMOTE/$BRANCH_NAME"
-        git push "$GIT_REMOTE" "$BRANCH_NAME"
-
-        # Notify success
-        notify "default" "✅ Flake Updated Successfully" \
-          "Branch $BRANCH_NAME created and pushed. All builds passed: $BUILD_SYSTEMS" \
-          "white_check_mark,flake"
-
-        log "SUCCESS: Flake updated and pushed to $BRANCH_NAME"
-      fi
-    else
+    if [ "$DRY_RUN" != "false" ] && [ "$DRY_RUN" != "" ] && [ "$DRY_RUN" != "0" ]; then
       log "DRY RUN: Would push to $GIT_REMOTE/$BRANCH_NAME"
       notify "low" "🧪 Flake Update (Dry Run)" \
         "Branch $BRANCH_NAME created locally. All builds passed: $BUILD_SYSTEMS" \
         "test_tube,flake"
+    elif [ "$AUTO_MERGE" = "true" ] || [ "$AUTO_MERGE" = "1" ]; then
+      # Auto-merge: rebase onto main and push directly
+      log "Auto-merge enabled: rebasing onto $GIT_REMOTE/$MAIN_BRANCH"
+      
+      # Fetch latest main
+      git fetch "$GIT_REMOTE" "$MAIN_BRANCH"
+      
+      # Rebase our commit onto main
+      if git rebase "$GIT_REMOTE/$MAIN_BRANCH"; then
+        log "Rebase successful, pushing to $GIT_REMOTE/$MAIN_BRANCH"
+        
+        # Push directly to main
+        git push "$GIT_REMOTE" "HEAD:$MAIN_BRANCH"
+        
+        # Notify success
+        notify "default" "✅ Flake Auto-Updated & Merged" \
+          "Updates for $input_desc merged to $MAIN_BRANCH. All builds passed: $BUILD_SYSTEMS" \
+          "white_check_mark,flake,merged"
+        
+        log "SUCCESS: Flake updated and merged to $MAIN_BRANCH"
+      else
+        log "ERROR: Rebase failed, main branch may have moved"
+        git rebase --abort || true
+        
+        add_todo_to_inbox "Flake update rebase conflict" \
+          "Auto-merge failed due to rebase conflict.
+Inputs: $input_desc
+Branch: $BRANCH_NAME (in worktree, needs manual rebase)"
+        
+        notify "high" "⚠️ Flake Update Rebase Failed" \
+          "Could not rebase $input_desc onto $MAIN_BRANCH. TODO added to inbox." \
+          "warning,flake,conflict"
+        exit 1
+      fi
+    else
+      # Branch mode: push to feature branch
+      log "Pushing to $GIT_REMOTE/$BRANCH_NAME"
+      git push "$GIT_REMOTE" "$BRANCH_NAME"
+
+      # Notify success
+      notify "default" "✅ Flake Updated Successfully" \
+        "Branch $BRANCH_NAME created and pushed. All builds passed: $BUILD_SYSTEMS" \
+        "white_check_mark,flake"
+
+      log "SUCCESS: Flake updated and pushed to $BRANCH_NAME"
     fi
 
   else