Skip to content

Commit a50653b

Browse files
committed
Remove last vestiges of Ruby 1.8.7 support
We dropped support for Ruby 1.8.7 in Overcommit 0.14.0, but didn't get around to updating the codebase to use Ruby 1.9 hashes and other such style changes. Change-Id: I9e86d4b2094a8bcb9a26b8e0863836bdda34be62 Reviewed-on: http://gerrit.causes.com/45275 Tested-by: jenkins <jenkins@brigade.com> Reviewed-by: Shane da Silva <shane.dasilva@brigade.com>
1 parent 99154c8 commit a50653b

13 files changed

+25
-42
lines changed

.rubocop.yml

+2-13
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,8 @@ Documentation:
1515
Exclude:
1616
- 'spec/overcommit/**/*'
1717

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
2720

2821
Encoding:
2922
EnforcedStyle: when_needed
@@ -43,10 +36,6 @@ FormatString:
4336
GuardClause:
4437
Enabled: false
4538

46-
# Ruby 1.8.7 only supports hash rockets.
47-
HashSyntax:
48-
EnforcedStyle: hash_rockets
49-
5039
IfUnlessModifier:
5140
Enabled: false
5241

lib/overcommit/configuration_validator.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ def ensure_hook_type_sections_exist(hash)
2626
# together, since it's easier to merge two hashes than to have to check if
2727
# one of the values is nil.
2828
def convert_nils_to_empty_hashes(hash)
29-
hash.inject({}) do |h, (key, value)|
29+
hash.each_with_object({}) do |(key, value), h|
3030
h[key] =
3131
case value
3232
when nil then {}
3333
when Hash then convert_nils_to_empty_hashes(value)
3434
else
3535
value
3636
end
37-
h
3837
end
3938
end
4039
end

lib/overcommit/hook/pre_commit/image_optim.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def run
2828
private
2929

3030
def optimize_images(image_paths)
31-
image_optim = ::ImageOptim.new(:skip_missing_workers => true)
31+
image_optim = ::ImageOptim.new(skip_missing_workers: true)
3232

3333
optimized_images =
3434
image_optim.optimize_images(image_paths) do |path, optimized|

lib/overcommit/hook_context/pre_commit.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def cleanup_environment
6464
# Get a list of added, copied, or modified files that have been staged.
6565
# Renames and deletions are ignored, since there should be nothing to check.
6666
def modified_files
67-
@modified_files ||= Overcommit::GitRepo.modified_files(:staged => true)
67+
@modified_files ||= Overcommit::GitRepo.modified_files(staged: true)
6868
end
6969

7070
# @deprecated
@@ -79,7 +79,7 @@ def modified_lines(file)
7979
def modified_lines_in_file(file)
8080
@modified_lines ||= {}
8181
@modified_lines[file] ||=
82-
Overcommit::GitRepo.extract_modified_lines(file, :staged => true)
82+
Overcommit::GitRepo.extract_modified_lines(file, staged: true)
8383
end
8484

8585
private

spec/integration/committing_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
repo do
1919
File.open('.overcommit.yml', 'w') { |f| f.write(config) }
2020
Overcommit::Installer.new(Overcommit::Logger.silent).
21-
run('.', :action => :install)
21+
run('.', action: :install)
2222
example.run
2323
end
2424
end
@@ -61,7 +61,7 @@
6161
around do |example|
6262
repo do
6363
Overcommit::Installer.new(Overcommit::Logger.silent).
64-
run('.', :action => :install)
64+
run('.', action: :install)
6565
File.open('.overcommit.yml', 'w') { |f| f.write(config) }
6666
File.open('test.txt', 'w') { |f| f.write(file_contents) }
6767
`git add test.txt`

spec/integration/disable_overcommit_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
around do |example|
77
repo do
88
Overcommit::Installer.new(Overcommit::Logger.silent).
9-
run('.', :action => :install)
9+
run('.', action: :install)
1010
Overcommit::Utils.with_environment('OVERCOMMIT_DISABLE' => overcommit_disable) do
1111
`touch blah`
1212
`git add blah`

spec/integration/installing_overcommit_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
describe 'installing Overcommit' do
44
context 'when template directory points to the Overcommit template directory' do
55
around do |example|
6-
repo(:template_dir => Overcommit::Installer::TEMPLATE_DIRECTORY) do
6+
repo(template_dir: Overcommit::Installer::TEMPLATE_DIRECTORY) do
77
example.run
88
end
99
end

spec/integration/resolving_merge_conflict_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
`git merge branch1`
3131
`git merge branch2` # Results in merge conflict
3232
Overcommit::Installer.new(Overcommit::Logger.silent).
33-
run('.', :action => :install)
33+
run('.', action: :install)
3434
`echo "Conflicts Resolved" > some-file`
3535
`git add some-file`
3636
example.run

spec/overcommit/cli_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
Overcommit::Installer.any_instance.
2020
should_receive(:run).
2121
with('current-dir',
22-
hash_including(:action => :install))
22+
hash_including(action: :install))
2323
subject
2424
end
2525
end
@@ -45,7 +45,7 @@
4545
Overcommit::Installer.any_instance.
4646
should_receive(:run).
4747
with('current-dir',
48-
hash_including(:action => :uninstall))
48+
hash_including(action: :uninstall))
4949
subject
5050
end
5151

@@ -56,7 +56,7 @@
5656
Overcommit::Installer.any_instance.
5757
should_receive(:run).
5858
with('target-dir',
59-
hash_including(:action => :uninstall))
59+
hash_including(action: :uninstall))
6060
subject
6161
end
6262
end
@@ -69,7 +69,7 @@
6969
Overcommit::Installer.any_instance.
7070
should_receive(:run).
7171
with('current-dir',
72-
hash_including(:action => :install))
72+
hash_including(action: :install))
7373
subject
7474
end
7575

@@ -80,7 +80,7 @@
8080
Overcommit::Installer.any_instance.
8181
should_receive(:run).
8282
with('target-dir',
83-
hash_including(:action => :install))
83+
hash_including(action: :install))
8484
subject
8585
end
8686
end

spec/overcommit/configuration_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@
6262
subject { config.enabled_builtin_hooks(context) }
6363

6464
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')
6767
end
6868

6969
it 'includes hooks that are not disabled' do

spec/overcommit/installer_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
let(:installer) { described_class.new(logger) }
66

77
describe '#run' do
8-
let(:options) { { :action => :install } }
8+
let(:options) { { action: :install } }
99
subject { installer.run(target.to_s, options) }
1010

1111
context 'when the target is not a directory' do
@@ -45,7 +45,7 @@
4545

4646
context 'and Overcommit hooks were previously installed' do
4747
before do
48-
installer.run(target, :action => :install)
48+
installer.run(target, action: :install)
4949
end
5050

5151
it 'keeps the master hook' do
@@ -77,7 +77,7 @@
7777
end
7878

7979
context 'and the force option is specified' do
80-
let(:options) { super().merge(:force => true) }
80+
let(:options) { super().merge(force: true) }
8181

8282
it 'does not raise an error' do
8383
expect { subject }.to_not raise_error
@@ -126,11 +126,11 @@
126126
end
127127

128128
context 'and an uninstall is requested' do
129-
let(:options) { { :action => :uninstall } }
129+
let(:options) { { action: :uninstall } }
130130

131131
context 'and Overcommit hooks were previously installed' do
132132
before do
133-
installer.run(target, :action => :install)
133+
installer.run(target, action: :install)
134134
end
135135

136136
it 'removes the master hook from the hooks directory' do

spec/support/matchers/hook.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# General spec matcher logic for checking hook status and output.
22
class HookMatcher
33
def initialize(status, args)
4-
options = args.empty? ? {} : { :message => args.first }
4+
options = args.empty? ? {} : { message: args.first }
55
@expected_status = status
66
@expected_message = options[:message]
77
end

template-dir/hooks/overcommit-hook

+1-6
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0
1818
exit
1919
end
2020

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-
2621
hook_type = File.basename($0)
2722
if hook_type == 'overcommit-hook'
2823
puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \
@@ -68,7 +63,7 @@ begin
6863

6964
# Ensure master hook is up-to-date
7065
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)
7267
exec($0, *ARGV) # Execute the updated hook with all original arguments
7368
end
7469

0 commit comments

Comments
 (0)