Created
December 28, 2015 23:23
-
-
Save fitnr/0d472fa298afe33fa113 to your computer and use it in GitHub Desktop.
git tool for converting log to ICS file
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
# git-ics | |
# Place in your $PATH (e.g. ~/bin) | |
# Accepts any options that can be passed to git log | |
# usage: git ics [opts] > cal.ics | |
echo BEGIN:VCALENDAR | |
echo METHOD:PUBLISH | |
echo VERSION:2.0 | |
echo PRODID:-//git-ics//git-ics//EN | |
echo CALSCALE:GREGORIAN | |
git log --date=iso8601 --pretty="hash:%H%ndate:%ad%nsummary:%s%n" "$@" | \ | |
while read -r line; do | |
prefix=$(cut -f 1 -d: <<< "$line") | |
content=$(cut -f 2- -d: <<< "$line") | |
# if commit | |
if [ "$prefix" == "hash" ]; then | |
echo BEGIN:VEVENT | |
echo UID:$content | |
echo LOCATION:$content | |
fi | |
# if date | |
if [ "$prefix" == "date" ]; then | |
DATE=$(date -juf "%Y-%m-%d %H:%M:%S %z" "$content" +"%Y%m%dT%H%M%SZ") | |
echo DTEND:$DATE | |
echo DTSTART:$DATE | |
fi | |
# if summary | |
if [ "$prefix" == "summary" ]; then | |
echo SUMMARY:$content | |
fi | |
if [ "$prefix" == "" ]; then | |
echo END:VEVENT | |
fi | |
done | |
echo END:VCALENDAR |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment