diff --git a/auto-commit-pipeline-py/src/lilith_auto_commit_pipeline/stages/push.py b/auto-commit-pipeline-py/src/lilith_auto_commit_pipeline/stages/push.py index 21d6850..fccd7fa 100644 --- a/auto-commit-pipeline-py/src/lilith_auto_commit_pipeline/stages/push.py +++ b/auto-commit-pipeline-py/src/lilith_auto_commit_pipeline/stages/push.py @@ -215,6 +215,22 @@ class PushCommitStage(PipelineStage): if "rejected" in error_msg or "non-fast-forward" in error_msg: raise PushRejectedError(f"Push rejected: {e.stderr}") + # Check if remote doesn't exist or branch doesn't match + if ("does not appear to be a git repository" in error_msg or + "could not read from remote repository" in error_msg or + "src refspec" in error_msg and "does not match any" in error_msg): + logger.warning(f"Remote not configured properly, attempting auto-setup") + if await self._setup_remote_if_missing(repo_path, remote, branch): + # Retry push after setup + result = subprocess.run( + ["git", "push", "-u", remote, branch], + cwd=repo_path, + capture_output=True, + text=True, + check=True, + ) + return # Success after setup + raise Exception(f"Push failed: {e.stderr}") async def _pull_rebase(