Skip to content

Commit

Permalink
raise a specific exception when the FileUpdater doesn't produce a cha…
Browse files Browse the repository at this point in the history
…nge (#8787)
  • Loading branch information
jakecoffman committed Jan 12, 2024
1 parent 8d1fe8a commit 8717791
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
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

0 comments on commit 8717791

Please sign in to comment.