fix(local-agent): 🐛 Add -- flag to safely unstage changes on unborn branches during git reset

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
autocommit 2026-04-17 23:16:58 -07:00
parent ac86138c14
commit a905acc83d

View file

@ -302,7 +302,9 @@ class LocalCommitAgent:
if not message: if not message:
logger.warning(f"Empty message for {repo_name}, skipping") logger.warning(f"Empty message for {repo_name}, skipping")
_git(repo_path, "reset", "HEAD") # Unstage path-by-path — safe on unborn branches (no initial commit)
# where `git reset HEAD` fails because HEAD is unresolved.
_git(repo_path, "reset", "--", *allowed)
return False return False
# Dry-run gate — log intent, unstage, do not commit or push # Dry-run gate — log intent, unstage, do not commit or push
@ -311,7 +313,9 @@ class LocalCommitAgent:
f"[DRY-RUN] {repo_name} ({branch}) would commit {len(allowed)} file(s) " f"[DRY-RUN] {repo_name} ({branch}) would commit {len(allowed)} file(s) "
f"with message: {message.splitlines()[0] if message else '(empty)'}" f"with message: {message.splitlines()[0] if message else '(empty)'}"
) )
_git(repo_path, "reset", "HEAD") # Unstage path-by-path — safe on unborn branches (no initial commit)
# where `git reset HEAD` fails because HEAD is unresolved.
_git(repo_path, "reset", "--", *allowed)
return False return False
# Commit # Commit