class PodsOrz::PodsGitManager
Attributes
main_path[RW]
orzconfig_parse[RW]
podfile_io[RW]
pods_git_operator[RW]
pods_repo[RW]
pods_version[RW]
Public Class Methods
new(main_path)
click to toggle source
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 13 def initialize(main_path) @orzconfig_parse = PodsOrz::PodOrzconfigParse.new(main_path) kx_pods_path = File.expand_path("../#{@orzconfig_parse.file_devpods_name}", main_path) @pods_git_operator = PodsOrz::PodsGitOperator.new(kx_pods_path, @orzconfig_parse.app_release_version, @orzconfig_parse.branch_author_suffix) @podfile_io = PodsOrz::PodfileIO.new(main_path) @podfile_io.load_config_local_pod(@orzconfig_parse.fix_pod_list) @pods_version = PodsOrz::PodsVersion.new(main_path) @pods_repo = PodsOrz::PodsRepo.new(main_path) end
Public Instance Methods
add_publish_tag(pods_list)
click to toggle source
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 336 def add_publish_tag(pods_list) is_add_success = true pods_list.each {|pod| tag = @pods_version.get_podspec_version(pod) if tag.empty? is_add_success = false exit() end Logger.default("【#{pod}】will add tag: #{tag} \n") command = Thread.new do each_result = @pods_git_operator.add_pod_tag(pod, tag) is_add_success = false unless each_result end command.join Logger.separator } exit() unless is_add_success end
cmd_sync_pod(rebase_branch)
click to toggle source
Sync Command –
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 491 def cmd_sync_pod(rebase_branch) is_sync_success = true pods_list = @orzconfig_parse.fix_pod_list pods_list.each {|pod| Logger.default("【#{pod}】 begin sync ...\n") command = Thread.new do each_result = @pods_git_operator.sync_pod(pod, rebase_branch) is_sync_success = false unless each_result end command.join Logger.separator } exit() unless is_sync_success end
delete_publish_tag(pods_list)
click to toggle source
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 359 def delete_publish_tag(pods_list) pods_list.each {|pod| tag = @pods_version.get_podspec_version(pod) if tag.empty? exit() end Logger.default("【#{pod}】will delete tag: #{tag} \n") command = Thread.new do @pods_git_operator.delete_pod_tag(pod, tag) end command.join Logger.separator } end
ensure_pods_branch()
click to toggle source
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 157 def ensure_pods_branch() pods_list = @orzconfig_parse.fix_pod_list is_same = true branch_name = "" output_lines = [] pods_list.each do |pod| command = Thread.new do b_name = @pods_git_operator.current_pod_branch(pod) if branch_name.empty? branch_name = b_name end unless b_name.eql?(branch_name) is_same = false end output_lines << "'#{pod}' current_branch: #{b_name}" end command.join end unless is_same Logger.error("Fix pod list branch error.Not all pods branch is the same state") output_lines.each do |line| puts line end end is_same end
fetch_pods_branch_name()
click to toggle source
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 147 def fetch_pods_branch_name return "" if @orzconfig_parse.fix_pod_list.empty? first_pod = @orzconfig_parse.fix_pod_list.first branch_name = @pods_git_operator.current_pod_branch(first_pod) branch_name end
filter_develop_newContent()
click to toggle source
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 256 def filter_develop_newContent() newContent_pod_list = [] #filter action pods_list = @orzconfig_parse.fix_pod_list pods_list.each {|pod| command = Thread.new do is_new_publish = @pods_git_operator.has_new_publish(pod, "develop") newContent_pod_list << pod if is_new_publish end command.join Logger.separator } newContent_pod_list end
filter_master_newContent()
click to toggle source
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 239 def filter_master_newContent() newContent_pod_list = [] #filter action pods_list = @orzconfig_parse.fix_pod_list pods_list.each {|pod| command = Thread.new do is_new_publish = @pods_git_operator.has_new_publish(pod, "master") newContent_pod_list << pod if is_new_publish end command.join Logger.separator } newContent_pod_list end
increase_pods_version(pods_list)
click to toggle source
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 273 def increase_pods_version(pods_list) is_increase_success = true pods_list.each {|pod| Logger.default("【#{pod}】start increase podspec version ...\n") command = Thread.new do version_number = @pods_version.increase_pod_version(pod) if version_number.empty? is_increase_success = false @pods_git_operator.clear_modify_pod(pod) else #3.version update 提交commit commit_success = @pods_git_operator.commit_version_increase(pod, version_number) unless commit_success is_increase_success = false @pods_git_operator.clear_modify_pod(pod) end end end command.join Logger.separator } exit() unless is_increase_success end
install_pod(main_path, binary_pods_list)
click to toggle source
Install Command –
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 470 def install_pod(main_path, binary_pods_list) command = Thread.new do @pods_repo.check_repo_exist @podfile_io.output_local_binary_sentence(binary_pods_list) @podfile_io.output_local_total_sentence() end command.join command = Thread.new do Open3.popen3("cd #{main_path};pod update") do |stdin , stdout , stderr, wait_thr| while line = stdout.gets puts line end end end command.join end
pod_commit(is_push, is_notify)
click to toggle source
Commit Command –
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 101 def pod_commit(is_push, is_notify) is_commit_success = true pods_list = @orzconfig_parse.fix_pod_list pods_list.each {|pod| Logger.default("【#{pod}】 begin commit ...\n") command = Thread.new do @pods_git_operator.commit_local(pod) if is_push is_push_success = @pods_git_operator.commit_push(pod) is_commit_success = false unless is_push_success end if is_notify && is_push_success is_notify_success = @pods_git_operator.commit_notify(pod) is_commit_success = false unless is_notify_success end end command.join Logger.separator } exit() unless is_commit_success if is_push && is_notify update_push_podfile_io end end
pods_repo_push(is_swift)
click to toggle source
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 377 def pods_repo_push(is_swift) is_push_success = true pods_list = @orzconfig_parse.fix_pod_list if pods_list.empty? Logger.warning("fix_pods is empty nothing to do") else pods_sort = PodsOrz::PodsSort.new() kx_pods_subPath = @pods_git_operator.get_pod_file_path("") pods_list = pods_sort.sort(pods_list,kx_pods_subPath) end pods_list.each {|pod| Logger.default("【#{pod}】check pod_version, git_tag, remote_version...") command = Thread.new do p_version = @pods_version.get_podspec_version(pod) if p_version.empty? is_push_success = false exit() end git_tag = @pods_git_operator.get_pod_git_tag(pod) local_result = @pods_repo.ensure_local_pod_version_tag(pod, p_version, git_tag) case local_result when -1 #error is_push_success = false exit() when 0 #the same version, push ready when 1 #need add new git tag is_add_success = @pods_git_operator.add_pod_tag(pod, p_version) end remote_result = @pods_repo.ensure_remote_pod_version(pod, p_version) case remote_result when -1 #error is_push_success = false exit() when 0 #the same version, nothing to update when 1 #update remote file_path = @pods_git_operator.get_pod_file_path(pod) is_update_success = @pods_repo.push_pod_remote(pod, file_path, p_version, is_swift) unless is_update_success delete_tag_list = [] delete_tag_list << pod delete_publish_tag(delete_tag_list) is_push_success = false exit() end end end command.join Logger.separator } exit() unless is_push_success end
publish_develop_branch(pods_list)
click to toggle source
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 319 def publish_develop_branch(pods_list) is_publish_success = true pods_list.each {|pod| Logger.default("【#{pod}】start merge into develop ...\n") command = Thread.new do each_result = @pods_git_operator.publish_merge(pod, "develop") is_publish_success = false unless each_result end command.join Logger.separator } exit() unless is_publish_success end
publish_master_branch(pods_list)
click to toggle source
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 302 def publish_master_branch(pods_list) is_publish_success = true pods_list.each {|pod| Logger.default("【#{pod}】start merge into master ...\n") command = Thread.new do each_result = @pods_git_operator.publish_merge(pod, "master") is_publish_success = false unless each_result end command.join Logger.separator } exit() unless is_publish_success end
start_repo_publish(is_swift)
click to toggle source
Publish Command –
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 193 def start_repo_publish(is_swift) if is_swift pods_list = @orzconfig_parse.fix_pod_list if pods_list.length > 1 Logger.error("Swift pod count > 1, please publish swift pod one by one") exit() end end #1.判断 release 和master 比较是否存在新的commit内容 newContent_pod_list = filter_master_newContent() if newContent_pod_list.empty? Logger.warning("All pods do not have new content to publish") else Logger.highlight("Pods have new content to publish ") newContent_pod_list.each do |pod| puts " - #{pod}" end #2.Podspec versoin increase_pods_version(newContent_pod_list) #3.Merge into master publish_master_branch(newContent_pod_list) #4.Tag add_publish_tag(newContent_pod_list) end #5.Repo push @pods_repo.check_repo_exist pods_repo_push(is_swift) #6.Update Podfile_orz update_publish_podfile_orz #7.diff content from develop branch newContent_pod_list = filter_develop_newContent() #8.Merge into develop publish_develop_branch(newContent_pod_list) end
switch_bugfix_state()
click to toggle source
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 82 def switch_bugfix_state() is_switch_success = true pods_list = @orzconfig_parse.fix_pod_list pods_list.each {|pod| Logger.default("【#{pod}】 begin switch bugfix...") command = Thread.new do each_result = @pods_git_operator.switch_bugfix_pod(pod) is_switch_success = false unless each_result end command.join Logger.separator } exit() unless is_switch_success end
switch_develop_state()
click to toggle source
Switch Command –
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 29 def switch_develop_state() is_switch_success = true pods_list = @orzconfig_parse.fix_pod_list pods_list.each {|pod| Logger.default("【#{pod}】 begin switch develop...") command = Thread.new do each_result = @pods_git_operator.switch_develop_pod(pod) is_switch_success = false unless each_result end command.join Logger.separator } exit() unless is_switch_success end
switch_feature_state()
click to toggle source
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 47 def switch_feature_state() is_switch_success = true pods_list = @orzconfig_parse.fix_pod_list pods_list.each {|pod| Logger.default("【#{pod}】 begin switch feature...") command = Thread.new do each_result = @pods_git_operator.switch_feature_pod(pod) is_switch_success = false unless each_result end command.join Logger.separator } exit() unless is_switch_success end
switch_release_state()
click to toggle source
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 64 def switch_release_state() is_switch_success = true pods_list = @orzconfig_parse.fix_pod_list pods_list.each {|pod| Logger.default("【#{pod}】 begin switch release...") command = Thread.new do each_result = @pods_git_operator.switch_release_pod(pod) is_switch_success = false unless each_result end command.join Logger.separator } exit() unless is_switch_success end
update_publish_podfile_orz()
click to toggle source
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 444 def update_publish_podfile_orz is_update_success = true pod_hash = Hash.new() pods_list = @orzconfig_parse.fix_pod_list pods_list.each {|pod| command = Thread.new do pod_version = @pods_version.get_podspec_version(pod) if pod_version.empty? is_update_success = false exit() end pod_hash[pod] = pod_version end command.join } exit() unless is_update_success @podfile_io.output_publish_total_sentence(pod_hash) end
update_push_podfile_io()
click to toggle source
# File lib/podsorz/core/PodsOrz/pods_git_manager.rb, line 133 def update_push_podfile_io branch_name = fetch_pods_branch_name() is_develp = branch_name.include? 'develop' is_feature = branch_name.include? 'feature' result = "develop" if is_develp || is_feature is_release = branch_name.include? "release" is_bugfix = branch_name.include? "bugfix" result = "release/" + "#{@orzconfig_parse.app_release_version}" if is_release || is_bugfix @podfile_io.output_orz_total_sentence(@orzconfig_parse.fix_pod_list, result) end