Sha256: 2bdc291268af1641b358abc211e5e8151f2069f230dca9952f754abd2fbe67bf

Contents?: true

Size: 1.07 KB

Versions: 33

Compression:

Stored size: 1.07 KB

Contents

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

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_commit.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_commit.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/overcommit-0.46.0/lib/overcommit/hook_context/post_commit.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_commit.rb
overcommit-0.46.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.45.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.44.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.43.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.42.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.41.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.40.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.39.1 lib/overcommit/hook_context/post_commit.rb
overcommit-0.39.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.38.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.37.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.36.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.35.0 lib/overcommit/hook_context/post_commit.rb
overcommit-0.34.2 lib/overcommit/hook_context/post_commit.rb
overcommit-0.34.1 lib/overcommit/hook_context/post_commit.rb
overcommit-0.34.0 lib/overcommit/hook_context/post_commit.rb