Skip to content

Commit

Permalink
basic cli added
Browse files Browse the repository at this point in the history
  • Loading branch information
gelstudios committed Apr 29, 2013
1 parent f7f2b55 commit d029144
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions gitfiti.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
[4,1,3,3,3,4],
[4,3,3,3,3,4],
[4,4,4,4,4,4],
[0,0,4,4,0,0]
[0,0,4,4,0,0],
[4,4,4,4,4,4]]

octocat=[
Expand All @@ -69,6 +69,16 @@
[2,0,2,0,2,0,2,0,0,0,2,0,0,0,0,2,0,2,0,2,0,2,0,0],
[1,0,1,0,1,0,1,0,0,0,1,1,1,0,0,1,0,1,0,1,0,1,1,1]]

images={
'kitty':kitty,
'oneup':oneup,
'twoup':twoup,
'hello':hello,
'hackerschool':hackerschool,
'octocat':octocat,
'hireme':hireme
}

def get_calendar(username):
"""retrieves the github commit calendar data for a username"""
BASEURL='https://github.com/'
Expand Down Expand Up @@ -118,29 +128,29 @@ def values_in_date_order(image, multiplier=1):
yield image[h][w]*multiplier

def commit(content, commitdate):
template = '''echo %s >> gitfiti\nGIT_AUTHOR_DATE=%s GIT_COMMITTER_DATE= %s git commit -a -m "gitfiti"\n'''
template = '''echo %s >> gitfiti\nGIT_AUTHOR_DATE=%s GIT_COMMITTER_DATE=%s git commit -a -m "gitfiti"\n'''
return template % (content, commitdate.isoformat(), commitdate.isoformat())

def fake_it(image, start_date, username, repo, offset=0, multiplier=1):
template = ('#!/bin/bash\n'
'git init gitfiti\n'
'cd gitfiti\n'
'REPO=%s\n'
'git init $"REPO"\n'
'cd $"REPO"\n'
'touch gitfiti\n'
'git add gitfiti\n'
'%s\n'
'git remote add origin git@github.com:%s/%s.git\n'
'git remote add origin git@github.com:%s/$"REPO".git\n'
'git pull\n'
'git push -u origin master\n')
strings = []
for value, date in zip(values_in_date_order(image, multiplier), date_gen(start_date, offset)):
for i in range(value):
strings.append(commit(i, date))
return template % ("".join(strings), username, repo)
return template % (repo, "".join(strings), username)

def save(output, filename):
"""Saves the list to a given filename"""
f = open(filename, "w")
f.write('\n')
f.write(output)
f.close()

Expand All @@ -155,6 +165,16 @@ def main():

print 'enter weeks to offset the image:'
offset = raw_input(">")
if offset == None: offset = 0
else: offset = int(offset)

print 'enter the image name to gitfiti'
print 'images: ' + ", ".join(images.keys())
image = raw_input(">")
if image == None: image = images['kitty']
else:
try: image = images[image]
except: image = images['kitty']

output = fake_it(image, get_start_date(), username, repo, offset, m)
save(output, 'gitfiti.sh')
Expand Down

0 comments on commit d029144

Please sign in to comment.