Compare commits

...

3 Commits

Author SHA1 Message Date
e155fc4611 Add requirements.txt 2025-10-05 19:57:40 +02:00
da008ba847 Rebase with autostash. Pass env to git command 2025-10-04 23:32:50 +02:00
6880f826e8 Pull and rebase before committing 2025-10-04 19:05:13 +02:00
3 changed files with 13 additions and 4 deletions

View File

@@ -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():

View File

@@ -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", "--autostash", "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:
@@ -45,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}")

2
src/requirements.txt Normal file
View File

@@ -0,0 +1,2 @@
requests
dnspython