lib/big_keeper/command/release/module.rb in bigkeeper-0.8.0 vs lib/big_keeper/command/release/module.rb in bigkeeper-0.8.1

- old
+ new

@@ -3,104 +3,57 @@ require 'big_keeper/util/gitflow_operator' require 'big_keeper/dependency/dep_type' require 'big_keeper/util/info_plist_operator' require 'big_keeper/util/git_operator' require 'big_keeper/util/logger' +require 'big_keeper/util/pod_operator' module BigKeeper - def self.release_module_start(path, version, user, module_name) + def self.release_module_start(path, version, user, module_name, ignore) BigkeeperParser.parse("#{path}/Bigkeeper") + module_path = BigkeeperParser.module_full_path(path, user, module_name) - Dir.chdir(path) do - git_info = GitInfo.new(BigkeeperParser::home_git, GitType::TAG, version) - module_path = self.get_module_path_default(path, user, module_name) - start_module_release(module_path, version, module_name, git_info, user) - end - end + # stash + StashService.new.stash(module_path, GitOperator.new.current_branch(module_path), module_name) - def self.release_module_finish(path, version, user, module_name) - BigkeeperParser.parse("#{path}/Bigkeeper") - module_path = self.get_module_path_default(path, user, module_name) - - Logger.error("current branch has changed") unless GitOperator.new.has_changes(module_path) - # check out master - if GitOperator.new.current_branch(module_path) != "master" - current_name = GitOperator.new.current_branch(module_path) - GitOperator.new.checkout(module_path, "master") - Logger.highlight("Push branch '#{current_name}' for '#{module_name}'...") - GitService.new.verify_push(module_path, "finish #{GitflowType.name(GitflowType::RELEASE)} #{current_name}", "master", "#{module_name}") + #check + if ignore != true + GitOperator.new.check_merge(module_path, "feature/#{version}") + GitOperator.new.check_diff(module_path, "develop", "master") + Logger.highlight(%Q(#{module_name} release check finish)) end - return - Dir.chdir(module_path) do - # rebase develop to master - Logger.highlight(%Q(Rebase develop to master)) + # checkout to develop branch + Logger.highlight(%Q(Start checkout #{module_name} to Branch develop)) + GitService.new.verify_checkout_pull(module_path, "develop") - #修改 podspec 文件 - # TO DO: - advanced to use Regular Expression - PodfileOperator.new.podspec_change(%Q(#{module_path}/#{module_name}.podspec), version, module_name) - - GitService.new.verify_rebase(module_path, 'develop', "#{module_name}") - GitOperator.new.verify_push(module_path, "finish rebase develop to master", "master", "#{module_name}") - GitOperator.new.tag(module_path, version) - - Logger.highlight(%Q(Start Pod repo push #{module_name})) - IO.popen("pod repo push #{module_name} #{module_name}.podspec --allow-warnings --sources=#{BigkeeperParser::sourcemodule_path}") do |io| - io.each do |line| - has_error = true if line.include? "ERROR" - end - end - if has_error - Logger.error("Pod repo push in '#{module_name}'") - return - end - - Logger.highlight(%Q(Success release #{module_name} V#{version})) - end + Logger.highlight(%Q(#{module_name} release start finish)) end - private - def self.start_module_release(module_path, version, module_name, source, user) - if GitOperator.new.has_changes(module_path) - StashService.new.stash_all(module_path, GitOperator.new.current_branch(module_path), user, module_name.split()) - end +## release finish + def self.release_module_finish(path, version, user, module_name, spec) + BigkeeperParser.parse("#{path}/Bigkeeper") + module_path = BigkeeperParser.module_full_path(path, user, module_name) - # step 1 checkout to develop branch - Logger.highlight(%Q(Start checkout #{module_name} to Branch develop)) - if GitOperator.new.current_branch(module_path) != "develop" - if GitOperator.new.has_branch(module_path, "develop") - GitOperator.new.checkout(module_path, "develop") - else - Logger.error("Cann't find develop branch, please check.") - end - end + # check commit + Logger.error("current branch has unpush files") if GitOperator.new.has_changes(module_path) + # check out master + Logger.highlight("'#{module_name}' checkout branch to master...") + GitService.new.verify_checkout_pull(module_path, "master") - Dir.chdir(module_path) do - # Pod lib lint - Logger.highlight(%Q(Start Pod lib lint #{module_name})) - has_error = false - IO.popen("pod lib lint --allow-warnings --verbose --use-libraries --sources=#{BigkeeperParser::sourcemodule_path}") do |io| - io.each do |line| - has_error = true if line.include? "ERROR" - end - end - if has_error - Logger.error("Pod lib error in '#{module_name}'") - return - end - end + Logger.highlight(%Q(Merge develop to master)) + # merge develop to master + GitOperator.new.merge(module_path, "develop") + GitOperator.new.push_to_remote(module_path, "master") - GitOperator.new.commit(module_path, "update podspec") - GitOperator.new.first_push(module_path, GitOperator.new.current_branch(module_path)) - Logger.highlight(%Q(Pod lib lint success)) - end - - def self.get_module_path_default(path, user, module_name) - module_path = BigkeeperParser::module_path(user, module_name) - if module_path == "../#{module_name}" - path_array = path.split('/') - path_array.pop() - module_path = path_array.join('/') + "/#{module_name}" + #修改 podspec 文件 + # TO DO: - advanced to use Regular Expression + has_change = PodfileOperator.new.podspec_change(%Q(#{module_path}/#{module_name}.podspec), version, module_name) + GitService.new.verify_push(module_path, "Change version number", "master", "#{module_name}") if has_change == true + GitOperator.new.tag(module_path, version) + # pod repo push + if spec == true + PodOperator.pod_repo_push(module_path, module_name, BigkeeperParser.source_spec_path(module_name), version) end - module_path end + end