Skip to content

Instantly share code, notes, and snippets.

@zef
Forked from jerodsanto/bb.rb
Created November 11, 2014 04:57
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 zef/7618497ed374e8f71eb2 to your computer and use it in GitHub Desktop.
Save zef/7618497ed374e8f71eb2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
if remote = `git remote -v`.lines.find { |l| l.match /bitbucket/ }
matches = remote.match /(?<domain>bitbucket.org).(?<path>.*)\.git/
url = "https://#{matches[:domain]}/#{matches[:path]}"
branch = `git symbolic-ref --short HEAD`.lines.first
url += "/branch/#{branch}"
system "open #{url}"
else
puts "No BitBucket remote :("
end
@zef
Copy link
Author

zef commented Nov 11, 2014

Added support for remote URLs that use the SSH format. Modified to open current branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment