Created
January 31, 2010 11:27
-
-
Save selwin/291025 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#A simple script to automatically commit changes in script's directory at a specified interval. I use this mainly for document versioning. | |
import subprocess, time, os, datetime, sys | |
#Change this variable to set a different commit interval | |
interval = 300 # secs | |
#Check whether git is installed, if not exit the script | |
exit_code = os.system('git > /dev/null') | |
if (exit_code % 256) != 0: | |
print('Git not installed or not in PATH variable. Refer to http://git-scm.com/ (for Linux and Mac) or http://code.google.com/p/msysgit/ (for Windows) for installation instructions') | |
sys.exit() | |
while True: | |
commit_time = datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M%p") | |
os.system("git add .") | |
command = "git commit -m 'Saved at %s'" % commit_time | |
os.system(command) | |
print("Changed committed at %s") % commit_time | |
time.sleep(interval) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment