File size: 917 Bytes
a588a0a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import time
import subprocess

# Function to update .gitignore file
def update_gitignore():
    with open(".gitignore", "w") as gitignore_file:
        gitignore_file.write("gitsaves.py\n")

# Function to perform git commit and push
def git_commit_and_push():
    current_time = time.strftime("%Y-%m-%d %H:%M:%S")
    commit_message = f"{current_time} Autosave for checkpoint additions"

    print("Pushing with commit `"+commit_message+"`")
    subprocess.run(["git", "add", "."])
    subprocess.run(["git", "commit", "-m", commit_message])
    subprocess.run(["git", "push"])

# Main loop
if __name__ == "__main__":
    try:
        while True:
            update_gitignore()
            git_commit_and_push()
            print(f"Autosaved at {time.strftime('%H:%M:%S')}")
            time.sleep(600)  # Sleep for 10 minutes (600 seconds)
    except KeyboardInterrupt:
        print("Autosave stopped.")