<commit_before>class GitDj
  require 'git_dj/version'
  INTEGRATION_BRANCH = 'staging'
  RELEASE_BRANCH = 'master'
  LOG_FILE_NAME = '/tmp/gdj_activity'

  class CommandFailedError < StandardError; end;

  def initialize
  end

  def perform
    case ARGV[0]
    when 'integrate'
      integrate_current_branch
    when 'integrate2'
      integrate_current_branch2
    when 'release'
      release_current_branch
    when 'get'
      get_updates_from_origin
    when 'put'
      push_updates_to_origin
    when 'continue'
      continue_prev_commands
    when 'help'
      print_help
    else
      print_help
    end
  end

  def integrate_current_branch
    send_branch_to_integration('')
  end

  def integrate_current_branch2
    send_branch_to_integration('2')
  end

  def send_branch_to_integration(staging_ver = '')
    drop_commands_cache
    cur_branch = current_branch_name
    integration_branch = INTEGRATION_BRANCH + staging_ver
    if has_uncommited_changes
      puts red_color("Failed to integrate #{cur_branch}: you have uncommited changes")
    elsif cur_branch == integration_branch
      puts red_color("Can not integrate #{integration_branch} into #{integration_branch}")
    else
      run_cmds [
        "git checkout #{integration_branch}",
        "git pull origin #{integration_branch}",
        "git merge #{cur_branch}",
        "git push origin #{integration_branch}",
        "git checkout #{cur_branch}"
      ]

      puts green_color("Successfully integrated #{cur_branch}")
    end
  end

  def release_current_branch
    drop_commands_cache
    cur_branch = current_branch_name
    if has_uncommited_changes
      puts red_color("Failed to release #{cur_branch}: you have uncommited changes")
    elsif cur_branch == RELEASE_BRANCH || cur_branch == INTEGRATION_BRANCH
      puts red_color("Can not integrate #{cur_branch} into #{RELEASE_BRANCH}")
    else
      run_cmds [
        "git checkout #{RELEASE_BRANCH}",
        "git merge #{cur_branch}",
        "git pull origin #{RELEASE_BRANCH}",
        "git push origin #{RELEASE_BRANCH}",
        "git checkout #{cur_branch}"
      ]

      puts green_color("Successfully released #{cur_branch}")
    end
  end

  def continue_prev_commands
    cmds = File.read(LOG_FILE_NAME).chomp.strip.split("\n")
    run_cmds(cmds)<commit_msg>no prompt message when merging into staging branches<commit_after>class GitDj
  require 'git_dj/version'
  INTEGRATION_BRANCH = 'staging'
  RELEASE_BRANCH = 'master'
  LOG_FILE_NAME = '/tmp/gdj_activity'

  class CommandFailedError < StandardError; end;

  def initialize
  end

  def perform
    case ARGV[0]
    when 'integrate'
      integrate_current_branch
    when 'integrate2'
      integrate_current_branch2
    when 'release'
      release_current_branch
    when 'get'
      get_updates_from_origin
    when 'put'
      push_updates_to_origin
    when 'continue'
      continue_prev_commands
    when 'help'
      print_help
    else
      print_help
    end
  end

  def integrate_current_branch
    send_branch_to_integration('')
  end

  def integrate_current_branch2
    send_branch_to_integration('2')
  end

  def send_branch_to_integration(staging_ver = '')
    drop_commands_cache
    cur_branch = current_branch_name
    integration_branch = INTEGRATION_BRANCH + staging_ver
    if has_uncommited_changes
      puts red_color("Failed to integrate #{cur_branch}: you have uncommited changes")
    elsif cur_branch == integration_branch
      puts red_color("Can not integrate #{integration_branch} into #{integration_branch}")
    else
      run_cmds [
        "git checkout #{integration_branch}",
        "git pull origin #{integration_branch}",
        "git merge --no-edit #{cur_branch}",
        "git push origin #{integration_branch}",
        "git checkout #{cur_branch}"
      ]

      puts green_color("Successfully integrated #{cur_branch}")
    end
  end

  def release_current_branch
    drop_commands_cache
    cur_branch = current_branch_name
    if has_uncommited_changes
      puts red_color("Failed to release #{cur_branch}: you have uncommited changes")
    elsif cur_branch == RELEASE_BRANCH || cur_branch == INTEGRATION_BRANCH
      puts red_color("Can not integrate #{cur_branch} into #{RELEASE_BRANCH}")
    else
      run_cmds [
        "git checkout #{RELEASE_BRANCH}",
        "git merge #{cur_branch}",
        "git pull origin #{RELEASE_BRANCH}",
        "git push origin #{RELEASE_BRANCH}",
        "git checkout #{cur_branch}"
      ]

      puts green_color("Successfully released #{cur_branch}")
    end
  end

  def continue_prev_commands
    cmds = File.read(LOG_FILE_NAME).chomp.strip.split("\n")
    run_cmds(cmds)
{'fraction_non_alphanumeric': 0.08046958377801494, 'fraction_numerical': 0.0021344717182497333, 'mean_word_length': 3.338888888888889, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4573749', 'n_tokens_mistral': 1472, 'n_tokens_neox': 1432, 'n_words': 339}