Skip to content

Commit 96a2fab

Browse files
committed
Expose initial_commit? helper to pre-commit hooks
This will allow these hooks to better handle odd situations that occur only on an empty branch.
1 parent 241ff62 commit 96a2fab

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/overcommit/hook/pre_commit/base.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module Overcommit::Hook::PreCommit
55
class Base < Overcommit::Hook::Base
66
extend Forwardable
77

8-
def_delegators :@context, :modified_lines_in_file, :amendment?
8+
def_delegators :@context, :modified_lines_in_file, :amendment?, :initial_commit?
99

1010
private
1111

lib/overcommit/hook_context/run_all.rb

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ def hook_script_name
3232
'pre-commit'
3333
end
3434

35+
def initial_commit?
36+
return @initial_commit unless @initial_commit.nil?
37+
@initial_commit = Overcommit::GitRepo.initial_commit?
38+
end
39+
3540
private
3641

3742
def count_lines(file)

0 commit comments

Comments
 (0)