From 6ba8034a0525bb8506fcc5d16b5d2c837b887d4a Mon Sep 17 00:00:00 2001 From: b3nw Date: Sat, 14 Sep 2024 17:53:56 -0500 Subject: [PATCH] cleanly handle no update, don't try to push --- proton-checker.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/proton-checker.py b/proton-checker.py index 3189de6..19c9a8e 100644 --- a/proton-checker.py +++ b/proton-checker.py @@ -72,13 +72,23 @@ if __name__ == "__main__": print(f" {country_code}: {count}") # Git commands - try: +try: subprocess.run(["git", "add", output_file], check=True) - subprocess.run(["git", "commit", "-m", "Update ProtonVPN IP ranges"], check=True) - subprocess.run(["git", "push", "origin"], check=True) - print("Changes pushed to git repository.") - except subprocess.CalledProcessError as e: - print(f"Error running git commands: {e}") + + # Attempt to commit, but allow for no changes + commit_result = subprocess.run(["git", "commit", "-m", "Update ProtonVPN IP ranges"], check=False) + + if commit_result.returncode == 0: + # Commit was successful (changes were made) + subprocess.run(["git", "push", "origin"], check=True) + print("Changes pushed to git repository.") + else: + # No changes to commit + print("No changes to ProtonVPN IP ranges.") + +except subprocess.CalledProcessError as e: + # Handle other git errors + print(f"Error running git commands: {e}") # ping health system try: