Skip to content

Instantly share code, notes, and snippets.

@PierrePaul PierrePaul/list.py
Created Apr 11, 2017

Embed
What would you like to do?
timetasks with git history
#!/usr/bin/python3
import sh
from datetime import datetime, timedelta
user = input("Your name, in git : ")
if user == '':
user = 'Pierre Paul'
from_date = input("Starting date, with format YYYY-MM-DD : ")
end_date = input("End date, with same format : ")
if from_date == '':
from_date = '2017-03-13'
time_format = '%Y-%m-%d'
from_date = datetime.strptime(from_date, time_format)
if end_date is None or end_date == '':
end_date = from_date + timedelta(days=10)
else:
end_date = datetime.strptime(end_date, time_format)
current_date = from_date
git = sh.git.bake("log",'--pretty=format:"%C(yellow)%h\\ %ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]"', '--decorate', '--date=short')
# git = sh.git.bake("log",'--decorate', '--date=short')
while current_date != end_date:
current_date += timedelta(days=1)
current_date_filter = '{}-{:0>2}-{:0>2}'.format(current_date.year, current_date.month, current_date.day)
for log in git(_tty_out=False, _iter=True):
if user in log and current_date_filter in log:
print(log.replace('\n', '').replace('\r', '').replace('\\', '').replace('"',''))
input("Press enter for next date")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.