File tree 13 files changed +25
-42
lines changed
13 files changed +25
-42
lines changed Original file line number Diff line number Diff line change @@ -15,15 +15,8 @@ Documentation:
15
15
Exclude :
16
16
- ' spec/overcommit/**/*'
17
17
18
- # Ruby 1.8.7 only supports trailing dots in method chains, but Rubocop still
19
- # reports it as an error for method calls chained onto do...end blocks. That's
20
- # too much noise, so remove it.
21
- DotPosition :
22
- Enabled : false
23
-
24
- # Ruby 1.8.7 doesn't have `each_with_object` defined.
25
- EachWithObject :
26
- Enabled : false
18
+ Style/DotPosition :
19
+ EnforcedStyle : trailing
27
20
28
21
Encoding :
29
22
EnforcedStyle : when_needed
@@ -43,10 +36,6 @@ FormatString:
43
36
GuardClause :
44
37
Enabled : false
45
38
46
- # Ruby 1.8.7 only supports hash rockets.
47
- HashSyntax :
48
- EnforcedStyle : hash_rockets
49
-
50
39
IfUnlessModifier :
51
40
Enabled : false
52
41
Original file line number Diff line number Diff line change @@ -26,15 +26,14 @@ def ensure_hook_type_sections_exist(hash)
26
26
# together, since it's easier to merge two hashes than to have to check if
27
27
# one of the values is nil.
28
28
def convert_nils_to_empty_hashes ( hash )
29
- hash . inject ( { } ) do |h , ( key , value ) |
29
+ hash . each_with_object ( { } ) do |( key , value ) , h |
30
30
h [ key ] =
31
31
case value
32
32
when nil then { }
33
33
when Hash then convert_nils_to_empty_hashes ( value )
34
34
else
35
35
value
36
36
end
37
- h
38
37
end
39
38
end
40
39
end
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ def run
28
28
private
29
29
30
30
def optimize_images ( image_paths )
31
- image_optim = ::ImageOptim . new ( : skip_missing_workers => true )
31
+ image_optim = ::ImageOptim . new ( skip_missing_workers : true )
32
32
33
33
optimized_images =
34
34
image_optim . optimize_images ( image_paths ) do |path , optimized |
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ def cleanup_environment
64
64
# Get a list of added, copied, or modified files that have been staged.
65
65
# Renames and deletions are ignored, since there should be nothing to check.
66
66
def modified_files
67
- @modified_files ||= Overcommit ::GitRepo . modified_files ( : staged => true )
67
+ @modified_files ||= Overcommit ::GitRepo . modified_files ( staged : true )
68
68
end
69
69
70
70
# @deprecated
@@ -79,7 +79,7 @@ def modified_lines(file)
79
79
def modified_lines_in_file ( file )
80
80
@modified_lines ||= { }
81
81
@modified_lines [ file ] ||=
82
- Overcommit ::GitRepo . extract_modified_lines ( file , : staged => true )
82
+ Overcommit ::GitRepo . extract_modified_lines ( file , staged : true )
83
83
end
84
84
85
85
private
Original file line number Diff line number Diff line change 18
18
repo do
19
19
File . open ( '.overcommit.yml' , 'w' ) { |f | f . write ( config ) }
20
20
Overcommit ::Installer . new ( Overcommit ::Logger . silent ) .
21
- run ( '.' , : action => :install )
21
+ run ( '.' , action : :install )
22
22
example . run
23
23
end
24
24
end
61
61
around do |example |
62
62
repo do
63
63
Overcommit ::Installer . new ( Overcommit ::Logger . silent ) .
64
- run ( '.' , : action => :install )
64
+ run ( '.' , action : :install )
65
65
File . open ( '.overcommit.yml' , 'w' ) { |f | f . write ( config ) }
66
66
File . open ( 'test.txt' , 'w' ) { |f | f . write ( file_contents ) }
67
67
`git add test.txt`
Original file line number Diff line number Diff line change 6
6
around do |example |
7
7
repo do
8
8
Overcommit ::Installer . new ( Overcommit ::Logger . silent ) .
9
- run ( '.' , : action => :install )
9
+ run ( '.' , action : :install )
10
10
Overcommit ::Utils . with_environment ( 'OVERCOMMIT_DISABLE' => overcommit_disable ) do
11
11
`touch blah`
12
12
`git add blah`
Original file line number Diff line number Diff line change 3
3
describe 'installing Overcommit' do
4
4
context 'when template directory points to the Overcommit template directory' do
5
5
around do |example |
6
- repo ( : template_dir => Overcommit ::Installer ::TEMPLATE_DIRECTORY ) do
6
+ repo ( template_dir : Overcommit ::Installer ::TEMPLATE_DIRECTORY ) do
7
7
example . run
8
8
end
9
9
end
Original file line number Diff line number Diff line change 30
30
`git merge branch1`
31
31
`git merge branch2` # Results in merge conflict
32
32
Overcommit ::Installer . new ( Overcommit ::Logger . silent ) .
33
- run ( '.' , : action => :install )
33
+ run ( '.' , action : :install )
34
34
`echo "Conflicts Resolved" > some-file`
35
35
`git add some-file`
36
36
example . run
Original file line number Diff line number Diff line change 19
19
Overcommit ::Installer . any_instance .
20
20
should_receive ( :run ) .
21
21
with ( 'current-dir' ,
22
- hash_including ( : action => :install ) )
22
+ hash_including ( action : :install ) )
23
23
subject
24
24
end
25
25
end
45
45
Overcommit ::Installer . any_instance .
46
46
should_receive ( :run ) .
47
47
with ( 'current-dir' ,
48
- hash_including ( : action => :uninstall ) )
48
+ hash_including ( action : :uninstall ) )
49
49
subject
50
50
end
51
51
56
56
Overcommit ::Installer . any_instance .
57
57
should_receive ( :run ) .
58
58
with ( 'target-dir' ,
59
- hash_including ( : action => :uninstall ) )
59
+ hash_including ( action : :uninstall ) )
60
60
subject
61
61
end
62
62
end
69
69
Overcommit ::Installer . any_instance .
70
70
should_receive ( :run ) .
71
71
with ( 'current-dir' ,
72
- hash_including ( : action => :install ) )
72
+ hash_including ( action : :install ) )
73
73
subject
74
74
end
75
75
80
80
Overcommit ::Installer . any_instance .
81
81
should_receive ( :run ) .
82
82
with ( 'target-dir' ,
83
- hash_including ( : action => :install ) )
83
+ hash_including ( action : :install ) )
84
84
subject
85
85
end
86
86
end
Original file line number Diff line number Diff line change 62
62
subject { config . enabled_builtin_hooks ( context ) }
63
63
64
64
before do
65
- context . stub ( : hook_class_name => 'PreCommit' ,
66
- : hook_type_name => 'pre_commit' )
65
+ context . stub ( hook_class_name : 'PreCommit' ,
66
+ hook_type_name : 'pre_commit' )
67
67
end
68
68
69
69
it 'includes hooks that are not disabled' do
Original file line number Diff line number Diff line change 5
5
let ( :installer ) { described_class . new ( logger ) }
6
6
7
7
describe '#run' do
8
- let ( :options ) { { : action => :install } }
8
+ let ( :options ) { { action : :install } }
9
9
subject { installer . run ( target . to_s , options ) }
10
10
11
11
context 'when the target is not a directory' do
45
45
46
46
context 'and Overcommit hooks were previously installed' do
47
47
before do
48
- installer . run ( target , : action => :install )
48
+ installer . run ( target , action : :install )
49
49
end
50
50
51
51
it 'keeps the master hook' do
77
77
end
78
78
79
79
context 'and the force option is specified' do
80
- let ( :options ) { super ( ) . merge ( : force => true ) }
80
+ let ( :options ) { super ( ) . merge ( force : true ) }
81
81
82
82
it 'does not raise an error' do
83
83
expect { subject } . to_not raise_error
126
126
end
127
127
128
128
context 'and an uninstall is requested' do
129
- let ( :options ) { { : action => :uninstall } }
129
+ let ( :options ) { { action : :uninstall } }
130
130
131
131
context 'and Overcommit hooks were previously installed' do
132
132
before do
133
- installer . run ( target , : action => :install )
133
+ installer . run ( target , action : :install )
134
134
end
135
135
136
136
it 'removes the master hook from the hooks directory' do
Original file line number Diff line number Diff line change 1
1
# General spec matcher logic for checking hook status and output.
2
2
class HookMatcher
3
3
def initialize ( status , args )
4
- options = args . empty? ? { } : { : message => args . first }
4
+ options = args . empty? ? { } : { message : args . first }
5
5
@expected_status = status
6
6
@expected_message = options [ :message ]
7
7
end
Original file line number Diff line number Diff line change @@ -18,11 +18,6 @@ if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0
18
18
exit
19
19
end
20
20
21
- # Required for Ruby 1.8 compatibility (for older OSX versions)
22
- if RUBY_VERSION . split ( '.' ) [ 0 ..1 ] == %w[ 1 8 ]
23
- require 'rubygems'
24
- end
25
-
26
21
hook_type = File . basename ( $0)
27
22
if hook_type == 'overcommit-hook'
28
23
puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \
68
63
69
64
# Ensure master hook is up-to-date
70
65
installer = Overcommit ::Installer . new ( logger )
71
- if installer . run ( Overcommit ::Utils . repo_root , : action => :update )
66
+ if installer . run ( Overcommit ::Utils . repo_root , action : :update )
72
67
exec ( $0, *ARGV ) # Execute the updated hook with all original arguments
73
68
end
74
69
You can’t perform that action at this time.
0 commit comments