Sha256: cbd858b444813c2c18a12fdb1feb725a45ba0607ac746a3bee4b3e48558a8cc5

Contents?: true

Size: 1.1 KB

Versions: 19

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Overcommit::HookContext
  # Contains helpers related to contextual information used by post-commit
  # hooks.
  class PostCommit < Base
    # Get a list of files that were added, copied, or modified in the last
    # commit. Renames and deletions are ignored, since there should be nothing
    # to check.
    def modified_files
      subcmd = 'show --format=%n'
      @modified_files ||= Overcommit::GitRepo.modified_files(subcmd: subcmd)
    end

    # Returns the set of line numbers corresponding to the lines that were
    # changed in a specified file.
    def modified_lines_in_file(file)
      subcmd = 'show --format=%n'
      @modified_lines ||= {}
      @modified_lines[file] ||=
        Overcommit::GitRepo.extract_modified_lines(file, subcmd: subcmd)
    end

    # Returns whether the commit that triggered this hook is the first commit on
    # the branch.
    #
    # @return [true,false]
    def initial_commit?
      return @initial_commit unless @initial_commit.nil?
      @initial_commit = !Overcommit::Utils.execute(%w[git rev-parse HEAD~]).success?
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
overcommit-0.58.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.57.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.56.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.55.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.54.1 lib/overcommit/hook_context/post_commit.rb
overcommit-0.54.0 lib/overcommit/hook_context/post_commit.rb
overcommit-jeygeethanmedia-0.53.1.2 lib/overcommit/hook_context/post_commit.rb
overcommit-jeygeethanmedia-0.53.1.1 lib/overcommit/hook_context/post_commit.rb
overcommit-jeygeethanmedia-0.53.1 lib/overcommit/hook_context/post_commit.rb
overcommit-0.53.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.52.1 lib/overcommit/hook_context/post_commit.rb
overcommit-0.52.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.51.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.50.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.49.1 lib/overcommit/hook_context/post_commit.rb
overcommit-0.49.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.48.1 lib/overcommit/hook_context/post_commit.rb
overcommit-0.48.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.47.0 lib/overcommit/hook_context/post_commit.rb