Rebase with autostash. Pass env to git command
This commit is contained in:
@@ -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():
|
||||
|
@@ -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}")
|
||||
|
Reference in New Issue
Block a user