diff --git a/src/helpers.py b/src/helpers.py index 7630274..1de5a38 100644 --- a/src/helpers.py +++ b/src/helpers.py @@ -20,6 +20,13 @@ def write_zone_export(zone_name, content) -> Path: return out_path def commit_and_push(changed_files, trigger_path): + # Pull from remote, rebasing + try: + run_git_cmd(["pull", "--rebase", "origin", "master"]) + except subprocess.CalledProcessError as e: + logging.exception(f"git pull --rebase failed: {e}") + return + # Stage files try: # Add only the exports folder (keeps repo tidy) @@ -31,7 +38,7 @@ def commit_and_push(changed_files, trigger_path): # Check if there is anything to commit try: # git diff --cached --quiet will exit 0 if no changes staged - subprocess.run(["git", "-C", GIT_REPO_DIR, "diff", "--cached", "--quiet"], check=True) + run_git_cmd(["diff", "--cached", "--quiet"], check=True) logging.info("No changes to commit (nothing staged).") return except subprocess.CalledProcessError: