Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raise a specific exception when the FileUpdater doesn't produce a change #8787

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions updater/lib/dependabot/dependency_change_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def initialize(job:, dependency_files:, updated_dependencies:, change_source:)

def run
updated_files = generate_dependency_files
raise DependabotError, "FileUpdater failed" unless updated_files.any?

# Remove any unchanged dependencies from the updated list
updated_deps = updated_dependencies.reject do |d|
# Avoid rejecting the source dependency
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ def check_and_create_pull_request(dependency)
change_source: checker.dependency
)

raise DependabotError, "FileUpdater failed" unless dependency_change.updated_dependency_files.any?

create_pull_request(dependency_change)
rescue Dependabot::AllVersionsIgnored
Dependabot.logger.info("All updates for #{dependency.name} were ignored")
Expand Down
26 changes: 26 additions & 0 deletions updater/spec/dependabot/dependency_change_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,31 @@
expect(dependency_change).to be_grouped_update
end
end

context "when there are no file changes" do
let(:change_source) do
Dependabot::Dependency.new(
name: "dummy-pkg-b",
package_manager: "bundler",
version: "1.1.0",
requirements: [
{
file: "Gemfile",
requirement: "~> 1.1.0",
groups: [],
source: nil
}
]
)
end

before do
allow_any_instance_of(Dependabot::Bundler::FileUpdater).to receive(:updated_dependency_files).and_return([])
end

it "raises an exception" do
expect { create_change }.to raise_error(Dependabot::DependabotError)
end
end
end
end