File tree 2 files changed +8
-2
lines changed
lib/overcommit/hook/pre_commit
spec/overcommit/hook/pre_commit
2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -3,8 +3,13 @@ module Overcommit::Hook::PreCommit
3
3
# Adapted from https://github.com/pre-commit/pre-commit-hooks
4
4
class CaseConflicts < Base
5
5
def run
6
- paths = Set . new ( applicable_files . map { |file | File . dirname ( file ) + File ::SEPARATOR } )
7
- repo_files = Set . new ( Overcommit ::GitRepo . list_files ( paths . to_a ) + applicable_files )
6
+ repo_files = Set . new ( applicable_files )
7
+
8
+ unless Overcommit ::GitRepo . initial_commit?
9
+ paths = repo_files . map { |file | File . dirname ( file ) + File ::SEPARATOR }
10
+ repo_files += Overcommit ::GitRepo . list_files ( paths )
11
+ end
12
+
8
13
conflict_hash = repo_files . classify ( &:downcase ) .
9
14
select { |_ , files | files . size > 1 }
10
15
conflict_files = applicable_files .
Original file line number Diff line number Diff line change 6
6
subject { described_class . new ( config , context ) }
7
7
8
8
before do
9
+ Overcommit ::GitRepo . stub ( :initial_commit? ) . and_return ( false )
9
10
Overcommit ::GitRepo . stub ( :list_files ) . and_return ( %w[ foo ] )
10
11
end
11
12
You can’t perform that action at this time.
0 commit comments