-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgtr
More file actions
executable file
·28 lines (24 loc) · 749 Bytes
/
gtr
File metadata and controls
executable file
·28 lines (24 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env ruby
require 'rubygems' unless RUBY_VERSION.to_i > 1.9
require 'git'
call_path = ENV["PWD"]
begin
git = Git.open(call_path)
rescue ArgumentError => e
system("echo \"gto: #{call_path}: Not a git repository\"")
exit
else
if git
branch_name = `git rev-parse --abbrev-ref HEAD`.chomp
remote_url = git.remote("origin").url.gsub(/git@/, 'http://').gsub(/\.git/, '').gsub(/\.com:/, '.com/') + "/compare/" + branch_name + "?expand=1"
sys = `uname -s`.chomp
if sys == "Darwin"
open_cmd = "open"
elsif sys == "Linux"
open_cmd = "xdg-open"
end
`#{open_cmd} \"#{remote_url}\"`
else
system("echo \"gtr: Could not open.\"")
end
end