Skip to content

Commit

Permalink
check uncommited changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rkansal47 committed Mar 5, 2024
1 parent 6de21cc commit a81f555
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/HHbbVV/run_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ def check_branch(git_branch: str, allow_diff_local_repo: bool = False):
)
), f"Branch {git_branch} does not exist"

print(f"Using branch {git_branch}")

# check if there are uncommitted changes
uncommited_files = int(subprocess.getoutput("git status -s | wc -l"))

if uncommited_files:
print_red("There are local changes that have not been committed!")
os.system("git status -s")
if allow_diff_local_repo:
print_red("Proceeding anyway...")
else:
print_red("Exiting! Use the --allow-diff-local-repo option to override this.")
sys.exit(1)

# check that the local repo's latest commit matches that on github
remote_hash = subprocess.getoutput(f"git show origin/{git_branch} | head -n 1").split(" ")[1]
local_hash = subprocess.getoutput("git rev-parse HEAD")

Expand Down

0 comments on commit a81f555

Please sign in to comment.