Skip to content
Browse files

add 'gh admin [user]' command

  • Loading branch information...
1 parent 6d7194b commit a7ce024976831be4f00bbab38a734d5b228c8bcd @drnic drnic committed Oct 25, 2010
Showing with 32 additions and 0 deletions.
  1. +2 −0 History.txt
  2. +10 −0 lib/commands/commands.rb
  3. +20 −0 spec/commands/command_admin_spec.rb
View
2 History.txt
@@ -1,3 +1,5 @@
+* Added "gh admin" - to open the Admin page for this project
+
== 0.4.4 2010-10-17
* Fixed 'create-from-local' to correctly select public/private [scott]
View
10 lib/commands/commands.rb
@@ -7,6 +7,16 @@
end
end
+desc "Open this repo's Admin panel a web browser."
+command :admin do |user|
+ if helper.project
+ homepage = helper.homepage_for(user || helper.owner, 'master')
+ homepage.gsub!(%r{/tree/master$}, '')
+ homepage += "/admin"
+ helper.open homepage
+ end
+end
+
desc "Automatically set configuration info, or pass args to specify."
usage "github config [my_username] [my_repo_name]"
command :config do |user, repo|
View
20 spec/commands/command_admin_spec.rb
@@ -0,0 +1,20 @@
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require File.dirname(__FILE__) + '/command_helper'
+
+describe "github admin" do
+ include CommandHelper
+
+ specify "admin should open the project admin page" do
+ running :admin do
+ setup_url_for
+ @helper.should_receive(:open).once.with("https://github.com/user/project/admin")
+ end
+ end
+
+ specify "admin drnic should open the home page of drnic's fork" do
+ running :admin, "drnic" do
+ setup_url_for
+ @helper.should_receive(:open).once.with("https://github.com/drnic/project/admin")
+ end
+ end
+end

0 comments on commit a7ce024

Please sign in to comment.
Something went wrong with that request. Please try again.