Skip to content

Instantly share code, notes, and snippets.

@coffeeaddict
Forked from JiriChara/gist:11213670
Created April 23, 2014 12:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coffeeaddict/11213880 to your computer and use it in GitHub Desktop.
Save coffeeaddict/11213880 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'open3'
begin
stdout, status = Open3.capture2("git status -uno --porcelain")
rescue Errno::ENOENT
abort "Cannot run `git status -uno --porcelain`."
end
unless status.exitstatus == 0
abort "git status failed - is this a git repository?"
end
branch, err = Open3.capture2('git symbolic-ref --short HEAD')
branch.strip!
user, err = Open3.capture2('git config github.user')
repo_name, err = Open3.capture2('basename `git rev-parse --show-toplevel`')
exec("google-chrome 'https://github.com/#{user}/#{repo_name}/compare/OrganisedMinds:#{branch}...#{user}:#{branch}'")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment