Skip to content

Commit

Permalink
GHE対応
Browse files Browse the repository at this point in the history
  • Loading branch information
mizzy committed Mar 12, 2013
1 parent 6c2cc89 commit 884c7bc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
20 changes: 16 additions & 4 deletions main.thor
Expand Up @@ -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

Expand Down
15 changes: 9 additions & 6 deletions tasks/member.thor
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 884c7bc

Please sign in to comment.