Skip to content

Commit

Permalink
Merge pull request gelstudios#42 from numberoverzero/master
Browse files Browse the repository at this point in the history
Use --allow-empty for performance, resolves gelstudios#32
  • Loading branch information
gelstudios authored Jun 28, 2016
2 parents 9e06be3 + 7a80c1d commit 92c44e6
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions gitfiti.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@


TITLE = '''
_ __ _____ __ _
_ __ _____ __ _
____ _(_) /_/ __(_) /_(_)
/ __ `/ / __/ /_/ / __/ /
/ /_/ / / /_/ __/ / /_/ /
\__, /_/\__/_/ /_/\__/_/
/____/
/ __ `/ / __/ /_/ / __/ /
/ /_/ / / /_/ __/ / /_/ /
\__, /_/\__/_/ /_/\__/_/
/____/
'''


Expand Down Expand Up @@ -153,13 +153,13 @@ def is_empty_line(line):


ONEUP_STR = str_to_sprite('''
*******
*******
*=~~-~~=*
*~~---~~*
*=*****=*
**-*-*-**
*-----*
*****
*-----*
*****
''')


Expand Down Expand Up @@ -211,7 +211,7 @@ def retrieve_contributions_calendar(username, base_url):
"""retrieves the GitHub commit calendar data for a username"""
base_url = base_url + 'users/' + username

try:
try:
url = base_url + '/contributions'
page = urlopen(url)
except (HTTPError, URLError) as e:
Expand Down Expand Up @@ -281,14 +281,12 @@ def generate_values_in_date_order(image, multiplier=1):
yield image[h][w] * multiplier


def commit(content, commitdate):
def commit(commitdate):
template = (
'''echo {0} >> gitfiti\n'''
'''GIT_AUTHOR_DATE={1} GIT_COMMITTER_DATE={2} '''
'''git commit -a -m "gitfiti" > /dev/null\n'''
'''GIT_AUTHOR_DATE={0} GIT_COMMITTER_DATE={1} '''
'''git commit --allow-empty -m "gitfiti" > /dev/null\n'''
)
return template.format(content, commitdate.isoformat(),
commitdate.isoformat())
return template.format(commitdate.isoformat(), commitdate.isoformat())


def fake_it(image, start_date, username, repo, git_url, offset=0, multiplier=1):
Expand All @@ -310,8 +308,8 @@ def fake_it(image, start_date, username, repo, git_url, offset=0, multiplier=1):
strings = []
for value, date in zip(generate_values_in_date_order(image, multiplier),
generate_next_dates(start_date, offset)):
for i in range(value):
strings.append(commit(i, date))
for _ in range(value):
strings.append(commit(date))

return template.format(repo, ''.join(strings), git_url, username)

Expand Down Expand Up @@ -380,9 +378,9 @@ def main():
if not image:
image = IMAGES[image_name_fallback]
else:
try:
try:
image = images[image]
except:
except:
image = IMAGES[image_name_fallback]

start_date = get_start_date()
Expand Down

0 comments on commit 92c44e6

Please sign in to comment.