Skip to content

Instantly share code, notes, and snippets.

@erotte
Created May 18, 2012 22:38
Show Gist options
  • Save erotte/2727949 to your computer and use it in GitHub Desktop.
Save erotte/2727949 to your computer and use it in GitHub Desktop.
Simple ruby script for creating ical calendars from local git repos
#! /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
@dennisreimann
Copy link

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