Skip to content

Instantly share code, notes, and snippets.

@jivebot
Forked from erithmetic/git-hub-diff
Created September 28, 2011 19:03
Show Gist options
  • Save jivebot/1248890 to your computer and use it in GitHub Desktop.
Save jivebot/1248890 to your computer and use it in GitHub Desktop.
git hub-diff - a command line utility for generating diffs on github
#!/usr/bin/env ruby
#
# Usage:
# cd /git/project/directory
# git hub-diff 223d60f5486075e74851075fcfeb366d45c17d8b 13c86f00cbfe820c415b46bfd19268284db2a274
# Future features:
# * generate SHAs from refs
# * launchy support
require 'rubygems'
require 'git'
require 'uri'
repo = Git.open(Dir.pwd)
github = repo.remotes.find { |r| r.url =~ /github/ }
http_uri = github.url.sub(/(.*)github\.com/,'http://github.com').
sub(/\.git$/,'').
sub(/github\.com:/,'github.com/')
from = ARGV[0]
# Compare to HEAD if "to" ref is omitted.
to = ARGV[1] || repo.revparse('HEAD')
exec("open #{http_uri}/compare/#{from}...#{to}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment