File tree Expand file tree Collapse file tree
lib/overcommit/hook/commit_msg
spec/overcommit/hook/commit_msg Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,10 +8,7 @@ class Spellcheck < Base
88 MISSPELLING_REGEX = /^[&#]\s (?<word>\w +)(?:.+?:\s (?<suggestions>.*))?/
99
1010 def run
11- # Remove comments from commit message file
12- update_commit_message ( commit_message )
13-
14- result = execute ( command + [ commit_message_file ] )
11+ result = execute ( command + [ uncommented_commit_msg_file ] )
1512 return [ :fail , "Error running spellcheck: #{ result . stderr . chomp } " ] unless result . success?
1613
1714 misspellings = parse_misspellings ( result . stdout )
@@ -28,6 +25,13 @@ def run
2825
2926 private
3027
28+ def uncommented_commit_msg_file
29+ ::Tempfile . open ( 'commit-msg' ) do |file |
30+ file . write ( commit_message )
31+ file . path
32+ end
33+ end
34+
3135 def parse_misspellings ( output )
3236 output . scan ( MISSPELLING_REGEX ) . map do |word , suggestions |
3337 Misspelling . new ( word , suggestions )
Original file line number Diff line number Diff line change 77 subject { described_class . new ( config , context ) }
88
99 before do
10- subject . stub ( :update_commit_message )
11- subject . stub ( :commit_message )
12- subject . stub ( :commit_message_file )
10+ subject . stub ( :uncommented_commit_msg_file )
1311 subject . stub ( :execute ) . and_return ( result )
1412 end
1513
You can’t perform that action at this time.
0 commit comments