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