<commit_before>#!/usr/bin/ruby
require 'big_keeper/util/podfile_operator'
require 'big_keeper/util/gitflow_operator'
require 'big_keeper/model/podfile_type'
require 'big_keeper/util/info_plist_operator'
require 'big_keeper/util/git_operator'
require 'big_keeper/util/logger'

module BigKeeper
  def self.release_module_start(path, version, user, module_name)
    BigkeeperParser.parse("#{path}/Bigkeeper")

    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

  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}")
    end
    return

    Dir.chdir(module_path) do
<<<<<<< HEAD
      # rebase develop to master
=======
      # 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}")
      end
      return
      # rebase release to master
>>>>>>> develop
      Logger.highlight(%Q(Rebase develop to master))

      #修改 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
  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

<<<<<<< HEAD
    # 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.")
=======
      # step 1 checkout release
      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
>>>>>>> develop
      end
    end

    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

    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}"
    end
    module_path
  end
end<commit_msg>fix: remove confict<commit_after>#!/usr/bin/ruby
require 'big_keeper/util/podfile_operator'
require 'big_keeper/util/gitflow_operator'
require 'big_keeper/model/podfile_type'
require 'big_keeper/util/info_plist_operator'
require 'big_keeper/util/git_operator'
require 'big_keeper/util/logger'

module BigKeeper
  def self.release_module_start(path, version, user, module_name)
    BigkeeperParser.parse("#{path}/Bigkeeper")

    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

  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}")
    end
    return

    Dir.chdir(module_path) do
      # rebase develop to master
      Logger.highlight(%Q(Rebase develop to master))

      #修改 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
  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

    # 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

    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

    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}"
    end
    module_path
  end
end
{'fraction_non_alphanumeric': 0.12206828842587543, 'fraction_numerical': 0.00032726082687902256, 'mean_word_length': 3.7725143154606977, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6706527', 'n_tokens_mistral': 2876, 'n_tokens_neox': 2820, 'n_words': 590}