-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[Updater] Wire up and flesh out branch naming for Grouped Update PRs #7084
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
Merged
brrygrdn
merged 5 commits into
main
from
brrygrdn/finalise-dependency-group-branch-naming
Apr 14, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6ce5dcf
Add prefixing to the dependency group strategy
brrygrdn 6672ed3
Wire up dependency_group pass through from the PR builder
brrygrdn 3ee8d28
Prefer positional arguments for Dependabot::DependencyGroup
brrygrdn 8b761b6
Suffix PRs with a prototype timestamp
brrygrdn 0193c77
Add rules kwarg to DependencyGroup
brrygrdn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 84 additions & 10 deletions
94
common/spec/dependabot/pull_request_creator/branch_namer/dependency_group_strategy_spec.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,93 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require "dependabot/dependency" | ||
| require "dependabot/dependency_file" | ||
| require "dependabot/dependency_group" | ||
| require "dependabot/pull_request_creator/branch_namer/dependency_group_strategy" | ||
|
|
||
| RSpec.describe Dependabot::PullRequestCreator::BranchNamer::DependencyGroupStrategy do | ||
| subject(:namer) do | ||
| described_class.new( | ||
| dependencies: dependencies, | ||
| files: [gemfile], | ||
| target_branch: target_branch, | ||
| separator: separator, | ||
| dependency_group: dependency_group | ||
| ) | ||
| end | ||
|
|
||
| let(:dependencies) { [dependency] } | ||
| let(:dependency) do | ||
| Dependabot::Dependency.new( | ||
| name: "business", | ||
| version: "1.5.0", | ||
| previous_version: "1.4.0", | ||
| package_manager: "bundler", | ||
| requirements: {}, | ||
| previous_requirements: {} | ||
| ) | ||
| end | ||
| let(:gemfile) do | ||
| Dependabot::DependencyFile.new( | ||
| name: "Gemfile", | ||
| content: "anything", | ||
| directory: directory | ||
| ) | ||
| end | ||
|
|
||
| let(:dependency_group) do | ||
| Dependabot::DependencyGroup.new(name: "my-dependency-group", rules: anything) | ||
| end | ||
|
|
||
| describe "#new_branch_name" do | ||
| it "returns the name of the dependency group" do | ||
| dependency_group = double("DependencyGroup", name: "my_dependency_group") | ||
| strategy = described_class.new( | ||
| dependencies: [], | ||
| files: [], | ||
| target_branch: "main", | ||
| dependency_group: dependency_group | ||
| ) | ||
|
|
||
| expect(strategy.new_branch_name).to eq(dependency_group.name) | ||
| context "with defaults for separator, target branch and files in the root directory" do | ||
| let(:directory) { "/" } | ||
| let(:target_branch) { nil } | ||
| let(:separator) { "/" } | ||
|
|
||
| it "returns the name of the dependency group prefixed correctly" do | ||
| expect(namer.new_branch_name).to start_with("dependabot/bundler/my-dependency-group") | ||
| end | ||
| end | ||
|
|
||
| context "with a custom separator" do | ||
| let(:directory) { "/" } | ||
| let(:target_branch) { nil } | ||
| let(:separator) { "_" } | ||
|
|
||
| it "returns the name of the dependency group prefixed correctly" do | ||
| expect(namer.new_branch_name).to start_with("dependabot_bundler_my-dependency-group") | ||
| end | ||
| end | ||
|
|
||
| context "for files in a non-root directory" do | ||
| let(:directory) { "rails app/" } # let's make sure we deal with spaces too | ||
| let(:target_branch) { nil } | ||
| let(:separator) { "/" } | ||
|
|
||
| it "returns the name of the dependency group prefixed correctly" do | ||
| expect(namer.new_branch_name).to start_with("dependabot/bundler/rails-app/my-dependency-group") | ||
| end | ||
| end | ||
|
|
||
| context "targeting a branch" do | ||
| let(:directory) { "/" } | ||
| let(:target_branch) { "develop" } | ||
| let(:separator) { "/" } | ||
|
|
||
| it "returns the name of the dependency group prefixed correctly" do | ||
| expect(namer.new_branch_name).to start_with("dependabot/bundler/develop/my-dependency-group") | ||
| end | ||
| end | ||
|
|
||
| context "for files in a non-root directory targetting a branch" do | ||
| let(:directory) { "rails-app/" } | ||
| let(:target_branch) { "develop" } | ||
| let(:separator) { "_" } | ||
|
|
||
| it "returns the name of the dependency group prefixed correctly" do | ||
| expect(namer.new_branch_name).to start_with("dependabot_bundler_rails-app_develop_my-dependency-group") | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think it would make sense to update GROUP_NAME_PLACEHOLDER here to "all-dependencies". Otherwise branch names will pop up with a
*There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good spot, yep, we should be consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I've actually realised we don't use this name to generate the branch name as API is the one that actually generates the object that gets used.
I'm going to leave this as-is for now to avoid CI churn, etc as we should yoink this placeholder out once #7075 merges