-
-
Save denis/95316 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
# | |
# Git log to iCalendar | |
# | |
# Written by Dmitry Chestnykh, 5 Aug 2008 | |
# Public domain | |
# | |
# Usage: | |
# | |
# log2icalendar.rb path-to-git-repo > outfile.ics | |
# | |
require 'date' | |
puts "BEGIN:VCALENDAR" | |
puts "VERSION:2.0" | |
puts "PRODID:-//hacksw/handcal//NONSGML v1.0//EN" | |
puts "X-WR-CALNAME:Podcasts" | |
event_started = false | |
IO.popen("cd #{ARGV[0]}; git log","r").each do |line| | |
if line =~ /Date:/ | |
date_str = line.scan(/Date:(.*)/)[0][0] | |
date = DateTime.parse(date_str, '%a %-d %b %Y %T %z') | |
# print event | |
puts "\nEND:VEVENT" if event_started | |
event_started = true | |
puts "BEGIN:VEVENT" | |
puts "DTSTART:" + date.strftime("%Y%m%dT%H%M%S") | |
puts "DTEND:" + date.strftime("%Y%m%dT%H%M%S") | |
print "SUMMARY:" | |
elsif line =~ /[ ]{4}/ # commit message after 4 spaces | |
print line.strip.gsub(/([;,\\\\])/, '\\\\\\1') | |
end | |
end | |
puts "\nEND:VEVENT" | |
puts "END:VCALENDAR" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment