Skip to content

Commit

Permalink
Remove square brackets from branch names
Browse files Browse the repository at this point in the history
  • Loading branch information
hmarr committed Feb 3, 2020
1 parent e8989c9 commit dcfaaaf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
7 changes: 6 additions & 1 deletion common/lib/dependabot/pull_request_creator/branch_namer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ def new_branch_name
elsif dependencies.count > 1 && updating_a_dependency_set?
dependency_set.fetch(:group)
else
dependencies.map(&:name).join("-and-").tr(":", "-").tr("@", "")
dependencies.
map(&:name).
join("-and-").
tr(":[]", "-").
tr("@", "")
end

dep = dependencies.first
Expand All @@ -42,6 +46,7 @@ def new_branch_name
end

branch_name = File.join(prefixes, @name).
gsub(/-+/, "-").
gsub(%r{/\.}, "/dot-").
gsub(%r{/\.}, "/dot-")

Expand Down
17 changes: 17 additions & 0 deletions common/spec/dependabot/pull_request_creator/branch_namer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,23 @@
end
end

context "with square brackets in the name" do
let(:dependency) do
Dependabot::Dependency.new(
name: "werkzeug[watchdog]",
version: "0.16.0",
previous_version: "0.15.0",
package_manager: "pip",
requirements: []
)
end

it "replaces the brackets with hyphens" do
expect(new_branch_name).
to eq("dependabot/pip/werkzeug-watchdog-0.16.0")
end
end

context "with a requirement only" do
let(:previous_version) { nil }
let(:requirements) do
Expand Down

0 comments on commit dcfaaaf

Please sign in to comment.