wiki/scripts/git.py
sthope 5792ba3dd6
All checks were successful
continuous-integration/drone/push Build is passing
cleaning
2023-08-19 23:03:35 +02:00

26 lines
744 B
Python

import os
import subprocess
import argparse
# Define and parse command-line arguments
parser = argparse.ArgumentParser(description="Automate Git add, commit, and push operations.")
parser.add_argument("--COMMIT-MSG", help="Commit message for the changes.")
args = parser.parse_args()
# Get the commit message from command-line argument or prompt user
if args.COMMIT_MSG:
commit_msg = args.COMMIT_MSG
else:
commit_msg = input("Enter commit message: ")
# Add changes to the staging area
subprocess.run(["git", "add", "."], check=True)
# Commit changes
subprocess.run(["git", "commit", "-m", commit_msg], check=True)
# Push changes
subprocess.run(["git", "push"], check=True)
print("Changes have been added, committed, and pushed.")