Skip to content

Commit

Permalink
Allow BranchNamer to be passed a nil branch (dependabot#8869)
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez authored Jan 23, 2024
1 parent 7cfbbdd commit 34f9389
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion common/lib/dependabot/pull_request_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ def branch_namer
BranchNamer.new(
dependencies: dependencies,
files: files,
target_branch: T.must(source.branch),
target_branch: source.branch,
dependency_group: dependency_group,
separator: branch_name_separator,
prefix: branch_name_prefix,
Expand Down
15 changes: 15 additions & 0 deletions common/spec/dependabot/pull_request_creator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,21 @@
end
end

context "with a GitHub source and no target branch" do
let(:source) { Dependabot::Source.new(provider: "github", repo: "gc/bp") }
let(:dummy_creator) { instance_double(described_class::Github) }

it "delegates to PullRequestCreator::Github with a branch name that does not include any branch" do
expect(described_class::Github)
.to receive(:new)
.with(
a_hash_including(branch_name: "dependabot/bundler/business-1.5.0")
).and_return(dummy_creator)
expect(dummy_creator).to receive(:create)
creator.create
end
end

context "with a GitLab source" do
let(:source) { Dependabot::Source.new(provider: "gitlab", repo: "gc/bp", branch: "main") }
let(:dummy_creator) { instance_double(described_class::Gitlab) }
Expand Down

0 comments on commit 34f9389

Please sign in to comment.