-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a24089f
Showing
6 changed files
with
739 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# greenhat <img src="https://github.com/4148/greenhat/blob/master/greenhat.png" alt="greenhat image" width="10%" height="10%"/> | ||
greenhat is a quick hack for decorating your GitHub contribution calendar with commits for the past `n` days. It uses the `GIT_AUTHOR_DATE` and `GIT_COMMITTER_DATE` environmental variables to make commits appear in the past. Be warned that greenhat will clobber your repository's commit history. | ||
|
||
### How to Use | ||
Place `greenhat.py` in your Git repository. Make sure your [remote repository URL is set](https://help.github.com/articles/adding-a-remote/), and that you have a [public SSH key set up](https://help.github.com/articles/generating-ssh-keys/). Then run the script with the python interpreter, with an integer specifying `n` number of days before today to generate commits for. E.g., | ||
|
||
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). | ||
|
||
#### An Example | ||
|
||
The following calendar is the result of running `python greenhat.py 365`: | ||
|
||
<img src="https://github.com/4148/greenhat/blob/master/example.png" alt="example image"/> | ||
|
||
The run took a total of eight hours. Beautiful, isn't it? | ||
|
||
Enjoy your decorated calendar! | ||
|
||
### License | ||
greenhat is distributed under the GNU General Public License v3.0 (GPLv3). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright (c) 2015 Angus H. (4148) | ||
# Distributed under the GNU General Public License v3.0 (GPLv3). | ||
|
||
from datetime import date, timedelta | ||
from random import randint | ||
from time import sleep | ||
import sys | ||
import subprocess | ||
import os | ||
|
||
# returns a date string for the date that is N days before STARTDATE | ||
def get_date_string(n, startdate): | ||
d = startdate - timedelta(days=n) | ||
rtn = d.strftime("%a %b %d %X %Y %z -0400") | ||
return rtn | ||
|
||
# main app | ||
def main(argv): | ||
if len(argv) < 1 or len(argv) > 2: | ||
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])) | ||
i = 0 | ||
while i <= n: | ||
curdate = get_date_string(i, startdate) | ||
num_commits = randint(1, 10) | ||
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) | ||
i += 1 | ||
subprocess.call("git rm realwork.txt; git commit -m 'delete'; git push;", shell=True) | ||
|
||
if __name__ == "__main__": | ||
main(sys.argv[1:]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fri Jan 15 00:00:00 2016 -040097142 |