Created
May 18, 2012 22:38
-
-
Save erotte/2727949 to your computer and use it in GitHub Desktop.
Simple ruby script for creating ical calendars from local git repos
This file contains hidden or 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 | |
# gitcal.rb | |
# creates an .ics file from a local git repository and loads it into iCal.app | |
# Usage: `[bundle exec] ruby gitcal.rb [repo_path] [branch] [count_back]` | |
# A shell wrapper script maybe a good idea, but for me this works as it is. | |
require 'grit' # https://github.com/mojombo/grit | |
require 'ri_cal' # https://github.com/rubyredrick/ri_cal | |
repo_path = ARGV[0] ? File.expand_path(ARGV[0]) : Dir.pwd | |
branch = ARGV[1] || 'develop' | |
count_back = ARGV[2] || 500 | |
repo = Grit::Repo.new repo_path | |
repo_name = repo.working_dir.split('/').last | |
file_name = "#{repo_name}.ics" | |
my_commits = repo.commits(branch, count_back).select do |c| | |
c.author.name == 'Eckhard Rotte' | |
end | |
cal = RiCal.Calendar do | |
my_commits.uniq.each do |c| | |
event do | |
summary c.short_message | |
description "id: #{c.id}\n #{c.message}\nauthored: #{c.authored_date}\ncommitted:#{c.committed_date}" | |
dtstart c.authored_date | |
end | |
end | |
end | |
File.open(file_name, 'w') do |file| | |
file.write cal | |
end | |
system "open #{file_name}" | |
# or | |
# $stdout.puts cal |
My surrender to the power of my laziness…
A very creative and hacky way to surrender :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hehe, http://www.youtube.com/watch?v=jPnR0fLidqw