<commit_before>desc 'Merges two branches to the working directory'
arg_name '<branch name>'
command :merge do |c|
  c.action do |global_options, options, args|
    repository = global_options[:repository]
    commit     = repository.resolve(:head, :commit)

    raise 'No branch specified to merge from' if args.empty?

    commit_two = repository.resolve(args.first, :commit)

    raise 'There is no branch with that name' if commit_two.nil?

    merge_status = repository.merge commit, commit_two

    # Save the merged commit ids so that the next
    # commit has both as parents.
    repository.config['merge'] = {
      'parents' => [
        commit.id,
        commit_two.id,
      ]
    }
    repository.config.save

    puts "# Merged #{args.first} into #{repository.head}"
    puts

    if merge_status[:merged].any?
      puts "# Automatic merges:"

      merge_status[:merged].each do |file|<commit_msg>Add --abort switch to `scv merge`<commit_after>desc 'Merges two branches to the working directory'
arg_name '<branch name>'
command :merge do |c|
  c.desc          'Abort the current merge. Resets the working dir and the next commit parents'
  c.arg_name      'abort'
  c.switch        :abort

  c.action do |global_options, options, args|
    repository = global_options[:repository]
    commit     = repository.resolve(:head, :commit)

    if options[:abort]
      repository.config['merge'] = {}
      repository.config.save

      repository.restore '.', commit

      next
    end

    raise 'No branch specified to merge from' if args.empty?

    commit_two = repository.resolve(args.first, :commit)

    raise 'There is no branch with that name' if commit_two.nil?

    merge_status = repository.merge commit, commit_two

    # Save the merged commit ids so that the next
    # commit has both as parents.
    repository.config['merge'] = {
      'parents' => [
        commit.id,
        commit_two.id,
      ]
    }
    repository.config.save

    puts "# Merged #{args.first} into #{repository.head}"
    puts

    if merge_status[:merged].any?
      puts "# Automatic merges:"

      merge_status[:merged].each do |file|
{'fraction_non_alphanumeric': 0.10303030303030303, 'fraction_numerical': 0.0, 'mean_word_length': 2.85278276481149, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6572950', 'n_tokens_mistral': 631, 'n_tokens_neox': 617, 'n_words': 198}