Skip to content

Commit

Permalink
replace deprecated GitExecuteError by Error
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-clerc committed Jun 26, 2024
1 parent e53282c commit 70b87d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/knife/changelog/policyfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def git_ref(myref, repo, cookbook_name = nil)
existing_ref = possible_refs.find do |ref|
begin
repo.checkout(ref)
rescue ::Git::GitExecuteError
rescue ::Git::Error
false
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/unit/policyfile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@

context 'when tag valid' do
it 'returns correct git tag' do
allow(repo).to receive(:checkout).with('v1.0.0').and_raise(::Git::GitExecuteError)
allow(repo).to receive(:checkout).with('v1.0.0').and_raise(::Git::Error)
allow(repo).to receive(:checkout).with('1.0.0').and_return(true)

expect(changelog.git_ref('1.0.0', repo)).to eq('1.0.0')
Expand All @@ -209,13 +209,13 @@

context 'when tag invalid and able to correct' do
it 'returns correct git tag' do
allow(repo).to receive(:checkout).with('1.0.0').and_raise(::Git::GitExecuteError)
allow(repo).to receive(:checkout).with('1.0.0').and_raise(::Git::Error)

tags = %w[v1.0.0 1.0 v1.0 cookbook_name-1.0.0 cookbook_name-1.0 cookbook_name-v1.0.0 cookbook_name-v1.0]
tags.each do |valid_result|
allow(repo).to receive(:checkout).with(valid_result).and_return(true)
tags.reject { |v| v == valid_result }.each do |invalid_result|
allow(repo).to receive(:checkout).with(invalid_result).and_raise(::Git::GitExecuteError)
allow(repo).to receive(:checkout).with(invalid_result).and_raise(::Git::Error)
end
expect(changelog.git_ref('1.0.0', repo, 'cookbook_name')).to eq valid_result
end
Expand All @@ -225,7 +225,7 @@
context 'when tags invalid and unable to correct' do
it 'raises exception' do
allow(repo).to receive(:remote).and_return(double('remote', url: 'url.com'))
allow(repo).to receive(:checkout).with(any_args).and_raise(::Git::GitExecuteError)
allow(repo).to receive(:checkout).with(any_args).and_raise(::Git::Error)

expect { changelog.git_ref('1.0.0', repo) }
.to raise_error(RuntimeError, /Impossible to find existing/)
Expand Down

0 comments on commit 70b87d6

Please sign in to comment.