public
Rubygem
Fork of defunkt/github-gem
Description: The official `github` command line helper for simplifying your GitHub experience.
Homepage: http://github.com
Clone URL: git://github.com/pjhyett/github-gem.git
Rename github open to home and implement browse to open the current 
branch's webpage!
halorgium (author)
Sat Mar 01 15:36:53 -0800 2008
commit  84ad7d1c284eb41ded08ef60291436b777f8f9d3
tree    a1cfb08ee270867973b55a800b83cc6cc3efbca5
parent  aeb4d6f83791b29c377e86601c353dab3d6e6c65
...
1
 
 
 
 
 
 
2
3
 
4
5
6
 
 
 
 
 
 
 
7
8
9
 
10
11
12
...
 
1
2
3
4
5
6
7
 
8
9
10
11
12
13
14
15
16
17
18
19
20
 
21
22
23
24
0
@@ -1,12 +1,24 @@
0
-GitHub.register :open do
0
+GitHub.register :helper do |name,comma_args|
0
+ comma_args ||= ''
0
+ puts helper.send(name, comma_args.split(/,/))
0
+end
0
+
0
+GitHub.register :home do
0
   if helper.project
0
- exec "open https://github.com/#{helper.current_user}/#{helper.project}"
0
+ exec "open #{helper.homepage_for(helper.owner, 'master')}"
0
   end
0
 end
0
 
0
+GitHub.register :browse do
0
+ if helper.project
0
+ exec "open #{helper.homepage_for(helper.branch_user, helper.branch_name)}"
0
+ end
0
+end
0
+
0
+
0
 GitHub.register :info do
0
   puts "== Info for #{helper.project}"
0
- puts "You are #{helper.current_user}"
0
+ puts "You are #{helper.owner}"
0
   puts "Currently tracking: "
0
   helper.tracking.each do |(name,user_or_url)|
0
     puts " - #{user_or_url} (as #{name})"
...
48
49
50
51
 
52
53
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
56
57
 
 
 
 
58
...
48
49
50
 
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
0
@@ -48,10 +48,32 @@ GitHub.helper :tracking? do |user|
0
   tracking.include?(user)
0
 end
0
 
0
-GitHub.helper :current_user do
0
+GitHub.helper :owner do
0
   user_for(:origin)
0
 end
0
 
0
+GitHub.helper :user_and_branch do
0
+ raw_branch = `git rev-parse --symbolic-full-name HEAD`.chomp.sub(/^refs\/heads\//, '')
0
+ user, branch = raw_branch.split(/\//, 2)
0
+ if branch
0
+ [user, branch]
0
+ else
0
+ [owner, branch]
0
+ end
0
+end
0
+
0
+GitHub.helper :branch_user do
0
+ user_and_branch.first
0
+end
0
+
0
+GitHub.helper :branch_name do
0
+ user_and_branch.last
0
+end
0
+
0
 GitHub.helper :public_url_for do |user|
0
   "git://github.com/#{user}/#{project}.git"
0
 end
0
+
0
+GitHub.helper :homepage_for do |user, branch|
0
+ "https://github.com/#{user}/#{project}/tree/#{branch}"
0
+end
0
\ No newline at end of file

Comments

    No one has commented yet.