Skip to content

Commit 869e788

Browse files
committed
fix: fix Rubocop Lint/SuppressedException offense
1 parent 8d39fe4 commit 869e788

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

.rubocop_todo.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@
66
# Note that changes in the inspected code, or installation of new
77
# versions of RuboCop, may require this file to be generated again.
88

9-
10-
# Offense count: 2
11-
# Configuration parameters: AllowComments, AllowNil.
12-
Lint/SuppressedException:
13-
Exclude:
14-
- 'lib/git/lib.rb'
15-
- 'tests/units/test_each_conflict.rb'
16-
179
# Offense count: 1
1810
Lint/UselessConstantScoping:
1911
Exclude:

lib/git/lib.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -707,12 +707,7 @@ def worktree_prune
707707

708708
def list_files(ref_dir)
709709
dir = File.join(@git_dir, 'refs', ref_dir)
710-
files = []
711-
begin
712-
files = Dir.glob('**/*', base: dir).select { |f| File.file?(File.join(dir, f)) }
713-
rescue StandardError
714-
end
715-
files
710+
Dir.glob('**/*', base: dir).select { |f| File.file?(File.join(dir, f)) }
716711
end
717712

718713
# The state and name of branch pointed to by `HEAD`

tests/units/test_each_conflict.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
class TestEachConflict < Test::Unit::TestCase
66
def test_conflicts
77
in_temp_repo('working') do
8+
# Setup a repository with a conflict
89
g = Git.open('.')
910

10-
g.branch('new_branch').in_branch('test') do
11+
g.branch('new_branch').in_branch('commit message') do
1112
new_file('example.txt', "1\n2\n3")
1213
g.add
1314
true
@@ -20,11 +21,17 @@ def test_conflicts
2021
end
2122

2223
g.merge('new_branch')
24+
2325
begin
2426
g.merge('new_branch2')
25-
rescue StandardError
27+
rescue Git::FailedError => e
28+
assert_equal(1, e.result.status.exitstatus)
29+
assert_match(/CONFLICT/, e.result.stdout)
2630
end
2731

32+
assert_equal(1, g.lib.unmerged.size)
33+
34+
# Check the conflict
2835
g.each_conflict do |file, your, their|
2936
assert_equal('example.txt', file)
3037
assert_equal("1\n2\n3\n", File.read(your))

0 commit comments

Comments
 (0)