diff --git a/updater/lib/dependabot/dependency_snapshot.rb b/updater/lib/dependabot/dependency_snapshot.rb index fedcec6a9d7..0a31cc4db4a 100644 --- a/updater/lib/dependabot/dependency_snapshot.rb +++ b/updater/lib/dependabot/dependency_snapshot.rb @@ -56,6 +56,7 @@ def job_dependencies # Returns just the group that is specifically requested to be updated by # the job definition def job_group + return nil unless Dependabot::Experiments.enabled?(:grouped_updates_prototype) return nil unless job.dependency_group_to_refresh return @job_group if defined?(@job_group) @@ -63,6 +64,8 @@ def job_group end def groups + return [] unless Dependabot::Experiments.enabled?(:grouped_updates_prototype) + @dependency_group_engine.dependency_groups end @@ -81,6 +84,9 @@ def initialize(job:, base_commit_sha:, dependency_files:) @dependency_files = dependency_files @dependencies = parse_files! + + return unless Dependabot::Experiments.enabled?(:grouped_updates_prototype) + @dependency_group_engine = DependencyGroupEngine.from_job_config(job: job) @dependency_group_engine.assign_to_groups!(dependencies: allowed_dependencies) end diff --git a/updater/spec/dependabot/dependency_snapshot_spec.rb b/updater/spec/dependabot/dependency_snapshot_spec.rb index fb75fd66940..4f20c5c4a8f 100644 --- a/updater/spec/dependabot/dependency_snapshot_spec.rb +++ b/updater/spec/dependabot/dependency_snapshot_spec.rb @@ -105,6 +105,8 @@ end it "correctly instantiates any configured dependency groups" do + Dependabot::Experiments.register("grouped_updates_prototype", true) + snapshot = create_dependency_snapshot expect(snapshot.groups.length).to eql(1) @@ -117,6 +119,14 @@ expect(snapshot.ungrouped_dependencies.length).to eql(1) expect(snapshot.ungrouped_dependencies.first.name).to eql("dummy-pkg-b") + + Dependabot::Experiments.reset! + end + + it "ignores any configured dependency groups when the experiment is disabled" do + snapshot = create_dependency_snapshot + + expect(snapshot.groups.length).to eql(0) end end