Permalink
Browse files

GHE対応

  • Loading branch information...
1 parent 6c2cc89 commit 884c7bca2f0fcf098937f934779e98b2d21cf4d6 @mizzy committed Mar 12, 2013
Showing with 25 additions and 10 deletions.
  1. +16 −4 main.thor
  2. +9 −6 tasks/member.thor
View
@@ -9,10 +9,22 @@ require 'uri'
class GhTools < Thor
private
def octokit
- config = Pit.get('github', :require => {
- 'username' => 'Your user name of GitHub',
- 'password' => 'Your password of GitHub',
- })
+ if options.ghe
+ config = Pit.get('ghe', :require => {
+ 'username' => 'Your user name of GitHub Enterprise',
+ 'password' => 'Your password of GitHub Enterprise',
+ })
+ Octokit.configure do |c|
+ c.api_endpoint = 'http://ghe.tokyo.pb/api/v3'
+ c.web_endpoint = 'http://ghe.tokyo.pb/'
+ end
+ else
+ config = Pit.get('github', :require => {
+ 'username' => 'Your user name of GitHub',
+ 'password' => 'Your password of GitHub',
+ })
+ end
+
Octokit::Client.new(:login => config['username'], :password => config['password'])
end
View
@@ -4,7 +4,8 @@ class Member < GhTools
method_options organization: :string,
team: :string,
user: :string,
- public: :boolean
+ public: :boolean,
+ ghe: :boolean
def add
organization = options.organization
team = options.team
@@ -14,7 +15,7 @@ class Member < GhTools
members = find_team_members(team)
unless members.include?(user)
- puts "Adding #{user} to #{team} of #{organization} ..."
+ puts "Adding #{user} to #{team.name} of #{organization} ..."
add_team_member(team, user)
publicize_member(organization, user) if options.public
end
@@ -47,7 +48,8 @@ class Member < GhTools
desc 'remove', 'Remove a member from a organization'
method_options organization: :string,
team: :string,
- user: :string
+ user: :string,
+ ghe: :boolean
def remove
organization = options.organization
team = options.team
@@ -91,7 +93,8 @@ class Member < GhTools
method_options srcorg: :string,
srcteam: :string,
destorg: :string,
- destteam: :string
+ destteam: :string,
+ ghe: :boolean
def sync
src_org = options.srcorg
src_team = options.srcteam
@@ -107,13 +110,13 @@ class Member < GhTools
members_to_add = src_members - dest_members
members_to_add.each do |member|
puts "Adding #{member} of #{src_org}/#{src_team.name} to #{dest_org}/#{dest_team.name} ..."
- `thor member:add --user=#{member} --organization=#{dest_org} --team=#{dest_team.name}`
+ `thor member:add --user=#{member} --organization=#{dest_org} --team=#{dest_team.name} --ghe=#{options.ghe}`
end
members_to_remove = dest_members - src_members
members_to_remove.each do |member|
puts "Rmoving #{member} of #{src_org}/#{src_team.name} to #{dest_org}/#{dest_team.name} ..."
- `thor member:remove --user=#{member} --organization=#{dest_org} --team=#{dest_team.name}`
+ `thor member:remove --user=#{member} --organization=#{dest_org} --team=#{dest_team.name} --ghe=#{options.ghe}`
end
end

0 comments on commit 884c7bc

Please sign in to comment.