cleanly handle no update, don't try to push
This commit is contained in:
@@ -72,12 +72,22 @@ 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)
|
||||
|
||||
# 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.")
|
||||
except subprocess.CalledProcessError as e:
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user