kin: auto-commit after pipeline
This commit is contained in:
parent
95ba853b49
commit
24996b3974
4 changed files with 77 additions and 11 deletions
|
|
@ -71,15 +71,34 @@ def merge_worktree(worktree_path: str, project_path: str) -> dict:
|
|||
branch_name = Path(worktree_path).name
|
||||
|
||||
try:
|
||||
# Stage all changes in the worktree before merge
|
||||
subprocess.run(
|
||||
[git, "-C", worktree_path, "add", "-A"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=30,
|
||||
)
|
||||
|
||||
# Commit staged changes; ignore failure (nothing to commit = returncode 1)
|
||||
commit_result = subprocess.run(
|
||||
[git, "-C", worktree_path, "commit", "-m", f"kin: {branch_name}"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=30,
|
||||
)
|
||||
commit_had_changes = commit_result.returncode == 0
|
||||
|
||||
merge_result = subprocess.run(
|
||||
[git, "-C", project_path, "merge", "--no-ff", branch_name],
|
||||
[git, "merge", "--no-ff", branch_name],
|
||||
cwd=project_path,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=60,
|
||||
)
|
||||
if merge_result.returncode == 0:
|
||||
diff_result = subprocess.run(
|
||||
[git, "-C", project_path, "diff", "HEAD~1", "HEAD", "--name-only"],
|
||||
[git, "diff", "HEAD~1", "HEAD", "--name-only"],
|
||||
cwd=project_path,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=10,
|
||||
|
|
@ -90,9 +109,15 @@ def merge_worktree(worktree_path: str, project_path: str) -> dict:
|
|||
_logger.info("Merged worktree %s: %d files", branch_name, len(merged_files))
|
||||
return {"success": True, "conflicts": [], "merged_files": merged_files}
|
||||
|
||||
# Merge failed — if commit was also empty (nothing to commit), treat as success
|
||||
if not commit_had_changes:
|
||||
_logger.info("Worktree %s: nothing to commit, skipping merge", branch_name)
|
||||
return {"success": True, "conflicts": [], "merged_files": []}
|
||||
|
||||
# Merge failed — collect conflicts and abort
|
||||
conflict_result = subprocess.run(
|
||||
[git, "-C", project_path, "diff", "--name-only", "--diff-filter=U"],
|
||||
[git, "diff", "--name-only", "--diff-filter=U"],
|
||||
cwd=project_path,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=10,
|
||||
|
|
@ -100,7 +125,8 @@ def merge_worktree(worktree_path: str, project_path: str) -> dict:
|
|||
conflicts = [f.strip() for f in conflict_result.stdout.splitlines() if f.strip()]
|
||||
|
||||
subprocess.run(
|
||||
[git, "-C", project_path, "merge", "--abort"],
|
||||
[git, "merge", "--abort"],
|
||||
cwd=project_path,
|
||||
capture_output=True,
|
||||
timeout=10,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue