-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit_changes.py
More file actions
69 lines (55 loc) · 1.79 KB
/
commit_changes.py
File metadata and controls
69 lines (55 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
"""
Script to commit changes to the repository.
"""
import os
import sys
import subprocess
def run_command(command):
"""Run a shell command and print the output."""
print(f"Running: {command}")
process = subprocess.Popen(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True,
universal_newlines=True
)
stdout, stderr = process.communicate()
if stdout:
print(f"Output: {stdout}")
if stderr:
print(f"Error: {stderr}")
return process.returncode
def main():
"""Main function to commit changes."""
# Change to the project directory
os.chdir(os.path.dirname(os.path.abspath(__file__)))
# Initialize git repository if it doesn't exist
if not os.path.exists('.git'):
print("Initializing git repository...")
run_command('git init')
# Configure git user if not already configured
run_command('git config user.name "Emmanuel D. Humbling"')
run_command('git config user.email "edhumbling@gmail.com"')
# Check git status
print("Checking git status...")
run_command('git status')
# Add all files
print("Adding files to git...")
run_command('git add .')
# Commit changes
print("Committing changes...")
run_command('git commit -m "Add reading metrics with Supabase integration and glass effect progress bar"')
# Check if remote exists
print("Checking if remote exists...")
remote_exists = run_command('git remote -v') == 0
if remote_exists:
# Push changes
print("Pushing changes...")
run_command('git push')
else:
print("No remote repository configured. Skipping push.")
print("Done!")
if __name__ == "__main__":
main()