Skip to content

Commit

Permalink
put behind feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
judocode committed Jan 31, 2025
1 parent ff55f73 commit 4325ce3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,20 @@ def process_group_dependencies(job_group)

existing_pr_dependencies = {}

enable = Dependabot::Experiments.enabled?(:allow_refresh_for_existing_pr_dependencies)

# Preprocess to discover existing group PRs and add their dependencies to the handled list before processing
# the refresh. This prevents multiple PRs from being created for the same dependency during the refresh.
dependency_snapshot.groups.each do |group|
# Gather all dependencies in existing PRs so other groups will not consider them as handled when they
# are not also in the PR of the group being checked, preventing erroneous PR closures
group_pr_deps = dependency_snapshot.dependencies_in_existing_pr_for_group(group)
group_pr_deps.each do |dep|
dep_dir = dep["directory"] || "/"
existing_pr_dependencies[dep_dir] ||= Set.new
existing_pr_dependencies[dep_dir].add(dep["dependency-name"])
if enable
# Gather all dependencies in existing PRs so other groups will not consider them as handled when they
# are not also in the PR of the group being checked, preventing erroneous PR closures
group_pr_deps = dependency_snapshot.dependencies_in_existing_pr_for_group(group)
group_pr_deps.each do |dep|
dep_dir = dep["directory"] || "/"
existing_pr_dependencies[dep_dir] ||= Set.new
existing_pr_dependencies[dep_dir].add(dep["dependency-name"])
end
end

next unless group.name != job_group.name && pr_exists_for_dependency_group?(group)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@

before do
stub_rubygems_calls
allow(Dependabot::Experiments).to receive(:enabled?)
.with(:allow_refresh_for_existing_pr_dependencies)
.and_return(allow_refresh_for_existing_pr_dependencies)
end

it "updates the existing pull request without errors" do
Expand Down

0 comments on commit 4325ce3

Please sign in to comment.