• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

sds / overcommit / 13042174175

29 Jan 2025 11:08PM UTC coverage: 90.924% (-0.008%) from 90.932%
13042174175

Pull #860

github

web-flow
Merge 9366c6641 into 9ce54927d
Pull Request #860: Add `-diff` cli option for running precommit hooks against diffs

31 of 34 new or added lines in 4 files covered. (91.18%)

3226 of 3548 relevant lines covered (90.92%)

2006.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

81.25
/lib/overcommit/hook_context/diff.rb
1
# frozen_string_literal: true
2

3
require 'overcommit/git_repo'
12✔
4

5
module Overcommit::HookContext
12✔
6
  # Simulates a pre-commit context based on the diff with another git ref.
7
  #
8
  # This results in pre-commit hooks running against the changes between the current
9
  # and another ref, which is useful for automated CI scripts.
10
  class Diff < Base
12✔
11
    def modified_files
12✔
12
      @modified_files ||= Overcommit::GitRepo.modified_files(refs: @options[:diff])
48✔
13
    end
14

15
    def modified_lines_in_file(file)
12✔
16
      @modified_lines ||= {}
24✔
17
      @modified_lines[file] ||= Overcommit::GitRepo.extract_modified_lines(file,
24✔
18
                                                                           refs: @options[:diff])
19
    end
20

21
    def hook_class_name
12✔
22
      'PreCommit'
24✔
23
    end
24

25
    def hook_type_name
12✔
NEW
26
      'pre_commit'
×
27
    end
28

29
    def hook_script_name
12✔
NEW
30
      'pre-commit'
×
31
    end
32

33
    def initial_commit?
12✔
NEW
34
      @initial_commit ||= Overcommit::GitRepo.initial_commit?
×
35
    end
36
  end
37
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc