Skip to content

Commit

Permalink
better checks if changes are needed
Browse files Browse the repository at this point in the history
  • Loading branch information
dianzrong committed Jun 5, 2023
1 parent cf9afa6 commit 8e66364
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions openadapt/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,24 @@

from openadapt.app.main import run_app

def changes_needed(result: str) -> bool:
""" Checks if git stash needs to be run.
Assumes result is the result of git status.
"""
if "Changes to be committed:" in result:
return True
if "Changes not staged for commit:" in result:
return True
if "Your branch is ahead of" in result:
return True
return False

result = subprocess.run(["git", "status"], capture_output=True, text=True)

if "branch is up to date" not in result.stdout:

if "Changes to be committed:" or \
"Changes not staged for commit:" in result.stdout:
if changes_needed(result.stdout):
subprocess.run(["git", "stash"])
print("Changes stashed")

Expand Down

0 comments on commit 8e66364

Please sign in to comment.