class GitProc::AbstractMergeErrorBuilder

noinspection RubyTooManyInstanceVariablesInspection

Attributes

added[W]
continue_command[R]
deleted[W]
error_message[R]
gitlib[R]
modified[W]
unmerged[W]

Public Class Methods

new(gitlib, error_message, continue_command) click to toggle source
# File lib/git-process/git_abstract_merge_error_builder.rb, line 25
def initialize(gitlib, error_message, continue_command)
  @gitlib = gitlib
  @error_message = error_message
  @continue_command = continue_command
end

Public Instance Methods

added() click to toggle source
# File lib/git-process/git_abstract_merge_error_builder.rb, line 101
def added
  @added ||= status.added
end
build_commands() click to toggle source
# File lib/git-process/git_abstract_merge_error_builder.rb, line 67
def build_commands
  commands = []

  unless resolved_files.empty?
    escaped_files = shell_escaped_files(resolved_files)
    commands << "git add #{escaped_files}"
  end

  unless unresolved_files.empty?
    mergeable = unresolved_files & modified
    commands << "git mergetool #{shell_escaped_files(mergeable)}" unless mergeable.empty?
    mergeable.each do |f|
      commands << "# Verify '#{f}' merged correctly."
    end
    (unresolved_files & added).each do |f|
      commands << "# '#{f}' was added in both branches; Fix the conflict."
    end
    commands << "git add #{shell_escaped_files(unresolved_files)}"
  end

  commands << continue_command if continue_command

  commands
end
deleted() click to toggle source
# File lib/git-process/git_abstract_merge_error_builder.rb, line 106
def deleted
  @deleted ||= status.deleted
end
find_resolved_files() click to toggle source
# File lib/git-process/git_abstract_merge_error_builder.rb, line 42
def find_resolved_files
  resolved_files = []

  unmerged.each do |file|
    resolved_file = (/Resolved '#{file}' using previous resolution./m =~ error_message)
    resolved_files << file if resolved_file
  end

  resolved_files.sort
end
human_message() click to toggle source
# File lib/git-process/git_abstract_merge_error_builder.rb, line 54
def human_message
  msg = 'There was a problem merging.'

  unresolved_files.each do |file|
    if modified.include? file
      msg << "\n'#{file}' was modified in both branches."
    end
  end

  msg
end
modified() click to toggle source
# File lib/git-process/git_abstract_merge_error_builder.rb, line 111
def modified
  @modified ||= status.modified
end
resolved_files() click to toggle source
# File lib/git-process/git_abstract_merge_error_builder.rb, line 32
def resolved_files
  @resolved_files ||= find_resolved_files
end
unmerged() click to toggle source
# File lib/git-process/git_abstract_merge_error_builder.rb, line 96
def unmerged
  @unmerged ||= status.unmerged
end
unresolved_files() click to toggle source
# File lib/git-process/git_abstract_merge_error_builder.rb, line 37
def unresolved_files
  @unresolved_files ||= (unmerged - resolved_files)
end

Private Instance Methods

config() click to toggle source
# File lib/git-process/git_abstract_merge_error_builder.rb, line 119
def config
  gitlib.config
end
status() click to toggle source
# File lib/git-process/git_abstract_merge_error_builder.rb, line 124
def status
  @status ||= gitlib.status
end