Better handling of lock files from worktress upon merging

This commit is contained in:
AndyMik90
2025-12-18 16:00:30 +01:00
parent 42496446bc
commit e44202a066
2 changed files with 20 additions and 6 deletions
+11 -5
View File
@@ -192,9 +192,12 @@ def merge_existing_build(
# Smart merge handled it (success or identified conflicts) # Smart merge handled it (success or identified conflicts)
if smart_result.get("success"): if smart_result.get("success"):
# Check if smart merge resolved git conflicts directly # Check if smart merge resolved git conflicts directly
if smart_result.get("stats", {}).get("ai_assisted"): stats = smart_result.get("stats", {})
# AI resolved git conflicts - changes are already staged had_conflicts = stats.get("conflicts_resolved", 0) > 0
_print_merge_success(no_commit, smart_result.get("stats"))
if had_conflicts:
# Git conflicts were resolved (via AI or lock file exclusion) - changes are already staged
_print_merge_success(no_commit, stats)
# Cleanup the worktree since merge is done # Cleanup the worktree since merge is done
try: try:
@@ -209,7 +212,7 @@ def merge_existing_build(
spec_name, delete_after=True, no_commit=no_commit spec_name, delete_after=True, no_commit=no_commit
) )
if success_result: if success_result:
_print_merge_success(no_commit, smart_result.get("stats")) _print_merge_success(no_commit, stats)
return True return True
elif smart_result.get("git_conflicts"): elif smart_result.get("git_conflicts"):
# Had git conflicts that AI couldn't fully resolve # Had git conflicts that AI couldn't fully resolve
@@ -740,10 +743,13 @@ def _resolve_git_conflicts_with_ai(
# Lock files should be excluded from merge entirely # Lock files should be excluded from merge entirely
# They must be regenerated after merge by running the package manager # They must be regenerated after merge by running the package manager
# (e.g., npm install, pnpm install, uv sync, cargo update) # (e.g., npm install, pnpm install, uv sync, cargo update)
#
# Strategy: Take main branch version and let user regenerate
lock_files_excluded.append(file_path) lock_files_excluded.append(file_path)
simple_merges.append((file_path, main_content))
debug( debug(
MODULE, MODULE,
f" {file_path}: lock file (excluded - regenerate after merge)", f" {file_path}: lock file (excluded - will use main version)",
) )
else: else:
# Regular file - needs AI merge # Regular file - needs AI merge
+9 -1
View File
@@ -75,12 +75,20 @@ def print_merge_success(no_commit: bool, stats: dict | None = None) -> None:
from ui import Icons, box, icon from ui import Icons, box, icon
if no_commit: if no_commit:
content = [ lines = [
success(f"{icon(Icons.SUCCESS)} CHANGES ADDED TO YOUR PROJECT"), success(f"{icon(Icons.SUCCESS)} CHANGES ADDED TO YOUR PROJECT"),
"", "",
"The new code is in your working directory.", "The new code is in your working directory.",
"Review the changes, then commit when ready.", "Review the changes, then commit when ready.",
] ]
# Add note about lock files if any were excluded
if stats and stats.get("lock_files_excluded", 0) > 0:
lines.append("")
lines.append("Note: Lock files kept from main.")
lines.append("Regenerate: npm install / pip install / cargo update")
content = lines
else: else:
lines = [ lines = [
success(f"{icon(Icons.SUCCESS)} FEATURE ADDED TO YOUR PROJECT!"), success(f"{icon(Icons.SUCCESS)} FEATURE ADDED TO YOUR PROJECT!"),