diff --git a/README.md b/README.md index d1e58fb1ff..4cbc511196 100644 --- a/README.md +++ b/README.md @@ -7,11 +7,17 @@ Place `greenhat.py` in your Git repository. Make sure your [remote repository UR python greenhat.py It might take a while to generate all the commits. If greenhat stops before it finishes, you can resume where you last left off by specifying a date before today when you want it to resume, like so: - + python greenhat.py `n` is the remaining days you want to generate commits for, and `date` is a date string in the form `yyyy-mm-dd` (e.g., 2013-04-05). + +You can also give the starting date relative w.r.t today's date + + python greenhat.py + For eg. python greenhat.py 30 5 + This will make commits for one month which ended 5 days ago. #### An Example The following calendar is the result of running `python greenhat.py 365`: diff --git a/greenhat.py b/greenhat.py index 48a11116e6..3d8c537645 100755 --- a/greenhat.py +++ b/greenhat.py @@ -8,6 +8,8 @@ import subprocess import os +COMMITS_PER_DAY=5 + # returns a date string for the date that is N days before STARTDATE def get_date_string(n, startdate): d = startdate - timedelta(days=n) @@ -16,18 +18,22 @@ def get_date_string(n, startdate): # main app def main(argv): - if len(argv) < 1 or len(argv) > 2: + if len(argv) < 1 or len(argv) > 3: print "Error: Bad input." sys.exit(1) n = int(argv[0]) if len(argv) == 1: startdate = date.today() if len(argv) == 2: - startdate = date(int(argv[1][0:4]), int(argv[1][5:7]), int(argv[1][8:10])) + if len(argv[1])<=4: + m = int(argv[1]) # note: m can be negative + startdate = date.today() - timedelta(days=m) + else: + startdate = date(int(argv[1][0:4]), int(argv[1][5:7]), int(argv[1][8:10])) i = 0 while i <= n: curdate = get_date_string(i, startdate) - num_commits = randint(1, 10) + num_commits = randint(1, COMMITS_PER_DAY) for commit in range(0, num_commits): subprocess.call("echo '" + curdate + str(randint(0, 1000000)) +"' > realwork.txt; git add realwork.txt; GIT_AUTHOR_DATE='" + curdate + "' GIT_COMMITTER_DATE='" + curdate + "' git commit -m 'update'; git push;", shell=True) sleep(.5)