Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added num_days features #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,17 @@ Place `greenhat.py` in your Git repository. Make sure your [remote repository UR
python greenhat.py <n>

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> <date>

`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 <n> <m>
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`:
Expand Down
12 changes: 9 additions & 3 deletions greenhat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down