Sha256: 5ed9ecdcd82f365898b32aade998e41b5d02d0a90639a7967c40392a314c943f

Contents?: true

Size: 859 Bytes

Versions: 6

Compression:

Stored size: 859 Bytes

Contents

module GitPrettyAccept
  class MergeCommand
    MESSAGE_TEMPLATE_FILENAME = '.git-pretty-accept-template.txt'

    attr_reader :branch, :let_user_edit_message

    def initialize(branch, let_user_edit_message)
      @branch = branch
      @let_user_edit_message = let_user_edit_message
    end

    def merge_message
      if File.exists?(MESSAGE_TEMPLATE_FILENAME)
        File.read(MESSAGE_TEMPLATE_FILENAME)
      end
    end

    # http://www.seejohncode.com/2012/10/16/proper-escaping-of-single-quotes/
    def merge_message_with_escaped_single_quote
      merge_message.gsub("'") { %q{'\''} }
    end

    def to_s
      [
        "git merge",
        "--no-ff",
        let_user_edit_message ? '--edit' : '--no-edit',
        branch,
        merge_message && "--message '#{merge_message_with_escaped_single_quote}'"
      ].join(' ')
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
git_pretty_accept-1.0.0 lib/git_pretty_accept/merge_command.rb
git_pretty_accept-0.5.0 lib/git_pretty_accept/merge_command.rb
git_pretty_accept-0.4.0 lib/git_pretty_accept/merge_command.rb
git_pretty_accept-0.3.1 lib/git_pretty_accept/merge_command.rb
git_pretty_accept-0.3.0 lib/git_pretty_accept/merge_command.rb
git_pretty_accept-0.2.0 lib/git_pretty_accept/merge_command.rb