feat: add command line argument to irgnore new git commits
- add new argument `--ignore-git-status` to continue even if there are no new commits
- update `update_git_repo` function to accept new argument and skip git status check if argument is passed
- update README.md with new Parameters section
🤖
This commit is contained in:
parent
16bc0974e1
commit
db6fd25741
3 changed files with 27 additions and 14 deletions
|
@ -22,33 +22,35 @@ def run_subprocess(command: str, workdir: str) -> bool:
|
|||
return True
|
||||
|
||||
|
||||
def update_git_repo(repo: str) -> bool:
|
||||
def update_git_repo(repo_path: str, ignore_git_status: bool) -> bool:
|
||||
"""update repo and check for new commits
|
||||
|
||||
Args:
|
||||
repo (str): path to git repo
|
||||
repo_path (str): path to git repo
|
||||
ignore_git_status (bool): continue even if no changes
|
||||
|
||||
Returns:
|
||||
bool: False if any step fails
|
||||
"""
|
||||
# create repo instance if it exists
|
||||
try:
|
||||
repo = git.Repo(repo)
|
||||
repo = git.Repo(repo_path)
|
||||
except git.exc.NoSuchPathError:
|
||||
log.error("directory not found")
|
||||
return False
|
||||
|
||||
# try to fetch latest changes
|
||||
try:
|
||||
repo.git.fetch()
|
||||
except git.exc.GitCommandError as e:
|
||||
log.error(str(e))
|
||||
return False
|
||||
if not ignore_git_status:
|
||||
# try to fetch latest changes
|
||||
try:
|
||||
repo.git.fetch()
|
||||
except git.exc.GitCommandError as e:
|
||||
log.error(str(e))
|
||||
return False
|
||||
|
||||
# check for new commits
|
||||
if repo.rev_parse("HEAD") == repo.rev_parse(f"origin/{repo.active_branch}"):
|
||||
log.info("no changes - skipping")
|
||||
return False
|
||||
# check for new commits
|
||||
if repo.rev_parse("HEAD") == repo.rev_parse(f"origin/{repo.active_branch}"):
|
||||
log.info("no changes - skipping")
|
||||
return False
|
||||
|
||||
# pull remote changes to local branch
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue