Skip to content

Commit

Permalink
Merge pull request #139 from DeployGate/work/automatically_manage_team
Browse files Browse the repository at this point in the history
get automatically manage ProvisioningProfile team
  • Loading branch information
henteko authored Oct 20, 2016
2 parents e798e6c + 9d0fc89 commit 6aedb2a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 9 deletions.
4 changes: 3 additions & 1 deletion lib/deploygate/commands/deploy/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ def ios(workspaces, options)

bundle_identifier = analyze.target_bundle_identifier
xcode_provisioning_profile_uuid = analyze.target_xcode_setting_provisioning_profile_uuid
target_provisioning_profile = DeployGate::Xcode::Export.provisioning_profile(bundle_identifier, xcode_provisioning_profile_uuid)

provisioning_team = analyze.provisioning_team
target_provisioning_profile = DeployGate::Xcode::Export.provisioning_profile(bundle_identifier, xcode_provisioning_profile_uuid, provisioning_team)

method = DeployGate::Xcode::Export.method(target_provisioning_profile)

Expand Down
38 changes: 34 additions & 4 deletions lib/deploygate/xcode/analyze.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,13 @@ def target_xcode_setting_provisioning_profile_uuid
end

def provisioning_style
main_target = target_project_setting
main_target_uuid = main_target && main_target.uuid
target = target_provisioning_info

style = PROVISIONING_STYLE_MANUAL
if main_target_uuid
if target
# Manual or Automatic or nil (Xcode7 below)
begin
style = target_project.root_object.attributes['TargetAttributes'][main_target_uuid]['ProvisioningStyle']
style = target['ProvisioningStyle']
rescue
# Not catch error
end
Expand All @@ -101,8 +100,39 @@ def provisioning_style
style
end

def provisioning_team
target = target_provisioning_info

team = nil
if target
begin
team = target['DevelopmentTeam']
rescue
# Not catch error
end
end

team
end

private

def target_provisioning_info
main_target = target_project_setting
main_target_uuid = main_target && main_target.uuid

target = nil
if main_target_uuid
begin
target = target_project.root_object.attributes['TargetAttributes'][main_target_uuid]
rescue
# Not catch error
end
end

target
end

def target_build_configration
target_project_setting.build_configuration_list.build_configurations.reject{|conf| conf.name != BUILD_CONFIGRATION}.first
end
Expand Down
11 changes: 7 additions & 4 deletions lib/deploygate/xcode/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class << self

# @param [String] bundle_identifier
# @param [String] uuid
# @param [String] provisioning_team
# @return [String]
def provisioning_profile(bundle_identifier, uuid = nil)
local_teams = DeployGate::Xcode::Export.find_local_data(bundle_identifier, uuid)
def provisioning_profile(bundle_identifier, uuid = nil, provisioning_team = nil)
local_teams = DeployGate::Xcode::Export.find_local_data(bundle_identifier, uuid, provisioning_team)

target_provisioning_profile = nil
case local_teams.teams_count
when 0
target_provisioning_profile = create_provisioning(bundle_identifier, uuid)
Expand All @@ -30,8 +30,9 @@ def provisioning_profile(bundle_identifier, uuid = nil)

# @param [String] bundle_identifier
# @param [String] uuid
# @param [String] provisioning_team
# @return [LocalTeams]
def find_local_data(bundle_identifier, uuid = nil)
def find_local_data(bundle_identifier, uuid = nil, provisioning_team = nil)
local_teams = LocalTeams.new

profile_paths = load_profile_paths
Expand All @@ -44,6 +45,8 @@ def find_local_data(bundle_identifier, uuid = nil)
entities = profile['Entitlements']
unless entities['get-task-allow']
team_id = entities['com.apple.developer.team-identifier']
next if provisioning_team != nil && team_id != provisioning_team

application_id = entities['application-identifier']
application_id.slice!(/^#{team_id}\./)
application_id = '.' + application_id if application_id == '*'
Expand Down

0 comments on commit 6aedb2a

Please sign in to comment.