From 298e03f7bed401da848af9998b08f693606c1e63 Mon Sep 17 00:00:00 2001 From: sachin-sandhu Date: Wed, 23 Oct 2024 21:58:27 -0400 Subject: [PATCH 1/4] draft changes --- common/lib/dependabot/pull_request_creator.rb | 6 ++++++ common/lib/dependabot/pull_request_creator/branch_namer.rb | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/common/lib/dependabot/pull_request_creator.rb b/common/lib/dependabot/pull_request_creator.rb index a9c52e03e5f..abdac46c5e1 100644 --- a/common/lib/dependabot/pull_request_creator.rb +++ b/common/lib/dependabot/pull_request_creator.rb @@ -396,6 +396,12 @@ def message sig { returns(Dependabot::PullRequestCreator::BranchNamer) } def branch_namer + if Dependabot::Experiments.enabled?(:dedup_branch_names) && existing_branches + Dependabot.logger.info( + "Dependabot::PullRequestCreator::branch_namer : #{existing_branches}" + ) + end + @branch_namer ||= T.let( BranchNamer.new( dependencies: dependencies, diff --git a/common/lib/dependabot/pull_request_creator/branch_namer.rb b/common/lib/dependabot/pull_request_creator/branch_namer.rb index 0be2610c00c..89b1ce64e97 100644 --- a/common/lib/dependabot/pull_request_creator/branch_namer.rb +++ b/common/lib/dependabot/pull_request_creator/branch_namer.rb @@ -77,6 +77,12 @@ def new_branch_name sig { returns(Dependabot::PullRequestCreator::BranchNamer::Base) } def strategy + if Dependabot::Experiments.enabled?(:dedup_branch_names) && existing_branches + Dependabot.logger.info( + "Dependabot::PullRequestCreator::strategy : #{existing_branches}" + ) + end + @strategy ||= T.let( if dependency_group.nil? SoloStrategy.new( From 9d9b29841c7dabefc112529264170a975108177d Mon Sep 17 00:00:00 2001 From: sachin-sandhu Date: Wed, 23 Oct 2024 23:19:16 -0400 Subject: [PATCH 2/4] adds logs for branching --- .../dependabot/pull_request_creator/branch_namer/base.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/common/lib/dependabot/pull_request_creator/branch_namer/base.rb b/common/lib/dependabot/pull_request_creator/branch_namer/base.rb index cda895920e1..0d4b48c9b6f 100644 --- a/common/lib/dependabot/pull_request_creator/branch_namer/base.rb +++ b/common/lib/dependabot/pull_request_creator/branch_namer/base.rb @@ -83,6 +83,9 @@ def sanitize_branch_name(ref_name) sig { params(ref: String).returns(String) } def dedup_existing_branches(ref) + Dependabot.logger.info( + "Dependabot::PullRequestCreator::dedup_existing_branches::ref : #{ref}" + ) return ref unless existing_branches.include?(ref) i = 1 @@ -92,6 +95,10 @@ def dedup_existing_branches(ref) new_ref = "#{ref}-#{i}" end + Dependabot.logger.info( + "Dependabot::PullRequestCreator::dedup_existing_branches::new_ref : #{new_ref}" + ) + new_ref end From 863308a54f74a928663e6d39b75c36605a578deb Mon Sep 17 00:00:00 2001 From: sachin-sandhu Date: Thu, 24 Oct 2024 12:06:33 -0400 Subject: [PATCH 3/4] fixes as per comments --- common/lib/dependabot/pull_request_creator.rb | 2 +- common/lib/dependabot/pull_request_creator/branch_namer.rb | 2 +- common/lib/dependabot/pull_request_creator/branch_namer/base.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/lib/dependabot/pull_request_creator.rb b/common/lib/dependabot/pull_request_creator.rb index abdac46c5e1..533f479a818 100644 --- a/common/lib/dependabot/pull_request_creator.rb +++ b/common/lib/dependabot/pull_request_creator.rb @@ -397,7 +397,7 @@ def message sig { returns(Dependabot::PullRequestCreator::BranchNamer) } def branch_namer if Dependabot::Experiments.enabled?(:dedup_branch_names) && existing_branches - Dependabot.logger.info( + Dependabot.logger.debug( "Dependabot::PullRequestCreator::branch_namer : #{existing_branches}" ) end diff --git a/common/lib/dependabot/pull_request_creator/branch_namer.rb b/common/lib/dependabot/pull_request_creator/branch_namer.rb index 89b1ce64e97..63ca44192d2 100644 --- a/common/lib/dependabot/pull_request_creator/branch_namer.rb +++ b/common/lib/dependabot/pull_request_creator/branch_namer.rb @@ -78,7 +78,7 @@ def new_branch_name sig { returns(Dependabot::PullRequestCreator::BranchNamer::Base) } def strategy if Dependabot::Experiments.enabled?(:dedup_branch_names) && existing_branches - Dependabot.logger.info( + Dependabot.logger.debug( "Dependabot::PullRequestCreator::strategy : #{existing_branches}" ) end diff --git a/common/lib/dependabot/pull_request_creator/branch_namer/base.rb b/common/lib/dependabot/pull_request_creator/branch_namer/base.rb index 0d4b48c9b6f..f39b39d15e6 100644 --- a/common/lib/dependabot/pull_request_creator/branch_namer/base.rb +++ b/common/lib/dependabot/pull_request_creator/branch_namer/base.rb @@ -83,7 +83,7 @@ def sanitize_branch_name(ref_name) sig { params(ref: String).returns(String) } def dedup_existing_branches(ref) - Dependabot.logger.info( + Dependabot.logger.debug( "Dependabot::PullRequestCreator::dedup_existing_branches::ref : #{ref}" ) return ref unless existing_branches.include?(ref) From fb787142b6155f3dbd6edd2415b3acff287087b4 Mon Sep 17 00:00:00 2001 From: sachin-sandhu Date: Thu, 24 Oct 2024 12:09:32 -0400 Subject: [PATCH 4/4] fixes --- common/lib/dependabot/pull_request_creator/branch_namer/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/lib/dependabot/pull_request_creator/branch_namer/base.rb b/common/lib/dependabot/pull_request_creator/branch_namer/base.rb index f39b39d15e6..887057c9d8c 100644 --- a/common/lib/dependabot/pull_request_creator/branch_namer/base.rb +++ b/common/lib/dependabot/pull_request_creator/branch_namer/base.rb @@ -95,7 +95,7 @@ def dedup_existing_branches(ref) new_ref = "#{ref}-#{i}" end - Dependabot.logger.info( + Dependabot.logger.debug( "Dependabot::PullRequestCreator::dedup_existing_branches::new_ref : #{new_ref}" )