File tree 15 files changed +37
-22
lines changed
spec/overcommit/hook/commit_msg
15 files changed +37
-22
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,9 @@ module Overcommit::Hook::CommitMsg
8
8
class GerritChangeId < Base
9
9
def run
10
10
result = execute ( [ SCRIPT_LOCATION , commit_message_file ] )
11
- return ( result . success? ? :good : :bad ) , result . stdout
11
+ return :good if result . success?
12
+
13
+ [ :bad , result . stdout ]
12
14
end
13
15
14
16
private
Original file line number Diff line number Diff line change 8
8
9
9
result = execute ( %w[ coffeelint --quiet ] + applicable_files )
10
10
return :good if result . success?
11
- return :bad , result . stdout
11
+
12
+ [ :bad , result . stdout ]
12
13
end
13
14
end
14
15
end
Original file line number Diff line number Diff line change 7
7
end
8
8
9
9
result = execute ( %w[ csslint --quiet --format=compact ] + applicable_files )
10
- output = result . stdout
11
- return ( output !~ /Error - (?!Unknown @ rule)/ ? :good : :bad ) , output
10
+ return :good if result . stdout !~ /Error - (?!Unknown @ rule)/
11
+
12
+ [ :bad , result . stdout ]
12
13
end
13
14
end
14
15
end
Original file line number Diff line number Diff line change @@ -19,8 +19,9 @@ def run
19
19
end
20
20
21
21
return :bad , error_lines . join ( "\n " ) unless error_lines . empty?
22
- return :warn , "Modified files have lints (on lines you didn't modify)\n " <<
23
- warning_lines . join ( "\n " )
22
+
23
+ [ :warn , "Modified files have lints (on lines you didn't modify)\n " <<
24
+ warning_lines . join ( "\n " ) ]
24
25
end
25
26
end
26
27
end
Original file line number Diff line number Diff line change 9
9
result = execute ( %w[ jshint ] + applicable_files )
10
10
output = result . stdout
11
11
12
- return ( output . empty? ? :good : :bad ) , output
12
+ return :good if output . empty?
13
+
14
+ [ :bad , output ]
13
15
end
14
16
end
15
17
end
Original file line number Diff line number Diff line change @@ -24,8 +24,9 @@ def run
24
24
end
25
25
26
26
return :bad , error_lines . join ( "\n " ) unless error_lines . empty?
27
- return :warn , "Modified files have lints (on lines you didn't modify)\n " <<
28
- warning_lines . join ( "\n " )
27
+
28
+ [ :warn , "Modified files have lints (on lines you didn't modify)\n " <<
29
+ warning_lines . join ( "\n " ) ]
29
30
end
30
31
end
31
32
end
Original file line number Diff line number Diff line change 7
7
end
8
8
9
9
result = execute ( %w[ flake8 ] + applicable_files )
10
+ return :good if result . success?
10
11
11
- return ( result . success? ? :good : : bad) , result . stdout
12
+ [ : bad, result . stdout ]
12
13
end
13
14
end
14
15
end
Original file line number Diff line number Diff line change @@ -21,8 +21,9 @@ def run
21
21
end
22
22
23
23
return :bad , error_lines . join ( "\n " ) unless error_lines . empty?
24
- return :warn , "Modified files have lints (on lines you didn't modify)\n " <<
25
- warning_lines . join ( "\n " )
24
+
25
+ [ :warn , "Modified files have lints (on lines you didn't modify)\n " <<
26
+ warning_lines . join ( "\n " ) ]
26
27
end
27
28
end
28
29
end
Original file line number Diff line number Diff line change @@ -19,8 +19,9 @@ def run
19
19
end
20
20
21
21
return :bad , error_lines . join ( "\n " ) unless error_lines . empty?
22
- return :warn , "Modified files have lints (on lines you didn't modify)\n " <<
23
- warning_lines . join ( "\n " )
22
+
23
+ [ :warn , "Modified files have lints (on lines you didn't modify)\n " <<
24
+ warning_lines . join ( "\n " ) ]
24
25
end
25
26
end
26
27
end
Original file line number Diff line number Diff line change 8
8
9
9
result = execute ( %w[ travis-lint ] + applicable_files )
10
10
return :good if result . success?
11
- return :bad , result . stdout . strip
11
+
12
+ [ :bad , result . stdout . strip ]
12
13
end
13
14
end
14
15
end
Original file line number Diff line number Diff line change @@ -4,19 +4,19 @@ module Overcommit::Hook::PreCommit
4
4
# Checks the syntax of any modified YAML files.
5
5
class YamlSyntax < Base
6
6
def run
7
- clean = true
8
7
output = [ ]
9
8
10
9
applicable_files . each do |file |
11
10
begin
12
11
YAML . load_file ( file )
13
12
rescue ArgumentError => e
14
13
output << "#{ e . message } parsing #{ file } "
15
- clean = false
16
14
end
17
15
end
18
16
19
- return ( clean ? :good : :bad ) , output
17
+ return :good if output . empty?
18
+
19
+ [ :bad , output ]
20
20
end
21
21
end
22
22
end
Original file line number Diff line number Diff line change 1
1
module Overcommit ::HookContext
2
+ # Contains helpers related to contextual information used by post-checkout
3
+ # hooks.
2
4
class PostCheckout < Base
3
5
# Returns the ref of the HEAD that we transitioned from.
4
6
def previous_head
Original file line number Diff line number Diff line change @@ -78,7 +78,8 @@ def install_hook_symlinks
78
78
Overcommit ::Utils . supported_hook_types . each do |hook_type |
79
79
unless can_replace_file? ( hook_type )
80
80
raise Overcommit ::Exceptions ::PreExistingHooks ,
81
- "Hook '#{ File . expand_path ( hook_type ) } ' already exists and was not installed by Overcommit"
81
+ "Hook '#{ File . expand_path ( hook_type ) } ' already exists and " <<
82
+ 'was not installed by Overcommit'
82
83
end
83
84
FileUtils . ln_sf ( 'overcommit-hook' , hook_type )
84
85
end
Original file line number Diff line number Diff line change 81
81
let ( :commit_msg ) { <<-MSG }
82
82
Some summary
83
83
84
- This line is longer than 80 characters which can clearly be seen by counting the number of characters.
84
+ This line is longer than #{ 'A' * 80 } characters.
85
85
MSG
86
86
87
87
it { should warn 'Line 3 of commit message has > 80 characters' }
103
103
let ( :commit_msg ) { <<-MSG }
104
104
A subject line that is way too long. A subject line that is way too long.
105
105
106
- A message line that is way too long. A message line that is way too long. A message line that is way too long .
106
+ This line is longer than #{ 'A' * 80 } characters .
107
107
MSG
108
108
109
109
it { should warn /keep.*subject <= 70.*\n .*line 3.*> 80.*/im }
Original file line number Diff line number Diff line change 5
5
# to manage your hooks for you.
6
6
7
7
# Required for Ruby 1.8 compatibility (for older OSX versions)
8
- if RUBY_VERSION . split ( '.' ) [ 0 ..1 ] == [ '1' , '8' ]
8
+ if RUBY_VERSION . split ( '.' ) [ 0 ..1 ] == %w[ 1 8 ]
9
9
require 'rubygems'
10
10
end
11
11
You can’t perform that action at this time.
0 commit comments