Compare commits
3 Commits
aa8fff37ea
...
master
Author | SHA1 | Date | |
---|---|---|---|
e155fc4611 | |||
da008ba847 | |||
6880f826e8 |
@@ -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():
|
||||
|
@@ -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
2
src/requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
requests
|
||||
dnspython
|
Reference in New Issue
Block a user