Use --allow-empty for performance gelstudios/gitfiti#32

* Improves the size of the generated file:

2365211 new-gitfiti.sh
2529001 original-gitfiti.sh

* Cutting the number of executed commands in half (no more echo)
* Vastly reduces the amount of gc git performs during push
This commit is contained in:
Joe Cross
2016-06-12 15:15:45 -07:00
parent 9e06be360b
commit 52884b2999

View File

@ -34,12 +34,12 @@ FALLBACK_IMAGE = 'kitty'
TITLE = ''' TITLE = '''
_ __ _____ __ _ _ __ _____ __ _
____ _(_) /_/ __(_) /_(_) ____ _(_) /_/ __(_) /_(_)
/ __ `/ / __/ /_/ / __/ / / __ `/ / __/ /_/ / __/ /
/ /_/ / / /_/ __/ / /_/ / / /_/ / / /_/ __/ / /_/ /
\__, /_/\__/_/ /_/\__/_/ \__, /_/\__/_/ /_/\__/_/
/____/ /____/
''' '''
@ -153,13 +153,13 @@ def str_to_sprite(content):
ONEUP_STR = str_to_sprite(''' ONEUP_STR = str_to_sprite('''
******* *******
*=~~-~~=* *=~~-~~=*
*~~---~~* *~~---~~*
*=*****=* *=*****=*
**-*-*-** **-*-*-**
*-----* *-----*
***** *****
''') ''')
@ -211,7 +211,7 @@ def retrieve_contributions_calendar(username, base_url):
"""retrieves the GitHub commit calendar data for a username""" """retrieves the GitHub commit calendar data for a username"""
base_url = base_url + 'users/' + username base_url = base_url + 'users/' + username
try: try:
url = base_url + '/contributions' url = base_url + '/contributions'
page = urlopen(url) page = urlopen(url)
except (HTTPError, URLError) as e: except (HTTPError, URLError) as e:
@ -283,12 +283,10 @@ def generate_values_in_date_order(image, multiplier=1):
def commit(content, commitdate): def commit(content, commitdate):
template = ( template = (
'''echo {0} >> gitfiti\n''' '''GIT_AUTHOR_DATE={0} GIT_COMMITTER_DATE={1} '''
'''GIT_AUTHOR_DATE={1} GIT_COMMITTER_DATE={2} ''' '''git commit --allow-empty -m "gitfiti" > /dev/null\n'''
'''git commit -a -m "gitfiti" > /dev/null\n'''
) )
return template.format(content, commitdate.isoformat(), return template.format(commitdate.isoformat(), commitdate.isoformat())
commitdate.isoformat())
def fake_it(image, start_date, username, repo, git_url, offset=0, multiplier=1): def fake_it(image, start_date, username, repo, git_url, offset=0, multiplier=1):
@ -380,9 +378,9 @@ def main():
if not image: if not image:
image = IMAGES[image_name_fallback] image = IMAGES[image_name_fallback]
else: else:
try: try:
image = images[image] image = images[image]
except: except:
image = IMAGES[image_name_fallback] image = IMAGES[image_name_fallback]
start_date = get_start_date() start_date = get_start_date()