Sha256: 930bdcdfabfde9a779bc968568085dd7b263c01b2aadc4b6c7354b6ba9fedf8a

Contents?: true

Size: 1.09 KB

Versions: 33

Compression:

Stored size: 1.09 KB

Contents

module Overcommit::HookContext
  # Contains helpers related to contextual information used by post-merge
  # hooks.
  class PostMerge < Base
    attr_accessor :args
    # Get a list of files that were added, copied, or modified in the merge
    # commit. Renames and deletions are ignored, since there should be nothing
    # to check.
    def modified_files
      staged = squash?
      refs = 'HEAD^ HEAD' if merge_commit?
      @modified_files ||= Overcommit::GitRepo.modified_files(staged: staged, refs: refs)
    end

    # Returns the set of line numbers corresponding to the lines that were
    # changed in a specified file.
    def modified_lines_in_file(file)
      staged = squash?
      refs = 'HEAD^ HEAD' if merge_commit?
      @modified_lines ||= {}
      @modified_lines[file] ||=
        Overcommit::GitRepo.extract_modified_lines(file, staged: staged, refs: refs)
    end

    # Returns whether this merge was made using --squash
    def squash?
      @args[0].to_i == 1
    end

    # Returns whether this merge was made without --squash
    def merge_commit?
      !squash?
    end
  end
end

Version data entries

33 entries across 31 versions & 2 rubygems

Version Path
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook_context/post_merge.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook_context/post_merge.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook_context/post_merge.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook_context/post_merge.rb
overcommit-0.46.0 lib/overcommit/hook_context/post_merge.rb
overcommit-0.45.0 lib/overcommit/hook_context/post_merge.rb
overcommit-0.44.0 lib/overcommit/hook_context/post_merge.rb
overcommit-0.43.0 lib/overcommit/hook_context/post_merge.rb
overcommit-0.42.0 lib/overcommit/hook_context/post_merge.rb
overcommit-0.41.0 lib/overcommit/hook_context/post_merge.rb
overcommit-0.40.0 lib/overcommit/hook_context/post_merge.rb
overcommit-0.39.1 lib/overcommit/hook_context/post_merge.rb
overcommit-0.39.0 lib/overcommit/hook_context/post_merge.rb
overcommit-0.38.0 lib/overcommit/hook_context/post_merge.rb
overcommit-0.37.0 lib/overcommit/hook_context/post_merge.rb
overcommit-0.36.0 lib/overcommit/hook_context/post_merge.rb
overcommit-0.35.0 lib/overcommit/hook_context/post_merge.rb
overcommit-0.34.2 lib/overcommit/hook_context/post_merge.rb
overcommit-0.34.1 lib/overcommit/hook_context/post_merge.rb
overcommit-0.34.0 lib/overcommit/hook_context/post_merge.rb