cleanly handle no update, don't try to push

This commit is contained in:
2024-09-14 17:53:56 -05:00
parent d749a0fe3b
commit 6ba8034a05

View File

@@ -74,10 +74,20 @@ if __name__ == "__main__":
# Git commands # Git commands
try: try:
subprocess.run(["git", "add", output_file], check=True) subprocess.run(["git", "add", output_file], check=True)
subprocess.run(["git", "commit", "-m", "Update ProtonVPN IP ranges"], check=True)
# 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) subprocess.run(["git", "push", "origin"], check=True)
print("Changes pushed to git repository.") print("Changes pushed to git repository.")
else:
# No changes to commit
print("No changes to ProtonVPN IP ranges.")
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
# Handle other git errors
print(f"Error running git commands: {e}") print(f"Error running git commands: {e}")
# ping health system # ping health system