From da008ba8476ab1e77aea102a2c3780119f36760d Mon Sep 17 00:00:00 2001 From: Ettore Dreucci Date: Sat, 4 Oct 2025 23:32:50 +0200 Subject: [PATCH] Rebase with autostash. Pass env to git command --- src/git.py | 4 ++-- src/helpers.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/git.py b/src/git.py index bbe6faf..3935264 100644 --- a/src/git.py +++ b/src/git.py @@ -6,10 +6,10 @@ from pathlib import Path from config import * -def run_git_cmd(args, check=True, capture_output=False): +def run_git_cmd(args, check=True, capture_output=False, env = None): cmd = ["git", "-C", GIT_REPO_DIR] + args logging.debug(f"Running git: {' '.join(cmd)}") - return subprocess.run(cmd, check=check, capture_output=capture_output, text=True) + return subprocess.run(cmd, check=check, capture_output=capture_output, text=True, env=env) def ensure_git_repo(): diff --git a/src/helpers.py b/src/helpers.py index 1de5a38..1f3a178 100644 --- a/src/helpers.py +++ b/src/helpers.py @@ -22,7 +22,7 @@ def write_zone_export(zone_name, content) -> Path: def commit_and_push(changed_files, trigger_path): # Pull from remote, rebasing try: - run_git_cmd(["pull", "--rebase", "origin", "master"]) + run_git_cmd(["pull", "--rebase", "--autostash", "origin", "master"]) except subprocess.CalledProcessError as e: logging.exception(f"git pull --rebase failed: {e}") return @@ -52,7 +52,7 @@ def commit_and_push(changed_files, trigger_path): env["GIT_AUTHOR_NAME"] = GIT_AUTHOR_NAME env["GIT_AUTHOR_EMAIL"] = GIT_AUTHOR_EMAIL try: - run_git_cmd(["commit", "-m", commit_msg], check=True) + run_git_cmd(["commit", "-m", commit_msg], check=True, env=env) logging.info("Committed changes to git.") except subprocess.CalledProcessError as e: logging.exception(f"git commit failed: {e}")