From 30fa42eb9dd1b80c012c220368b5b2c994e1f28b Mon Sep 17 00:00:00 2001 From: Jason Frey Date: Wed, 12 Jun 2024 14:05:15 -0400 Subject: [PATCH] Fix issue where tags with dashes are ignored --- app/models/branch.rb | 2 +- spec/models/branch_spec.rb | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/models/branch.rb b/app/models/branch.rb index a6177750..0a3c14b5 100644 --- a/app/models/branch.rb +++ b/app/models/branch.rb @@ -84,7 +84,7 @@ def fq_pr_number end def pr_title_tags - pr_title.to_s.match(/^(?:\s*\[\w+\])+/).to_s.gsub("[", " [").split.map { |s| s[1...-1] } + pr_title.to_s.match(/^(?:\s*\[[\w-]+\])+/).to_s.gsub("[", " [").split.map { |s| s[1...-1] } end def github_pr_uri diff --git a/spec/models/branch_spec.rb b/spec/models/branch_spec.rb index ada37404..1e6df46d 100644 --- a/spec/models/branch_spec.rb +++ b/spec/models/branch_spec.rb @@ -152,6 +152,11 @@ expect(branch.pr_title_tags).to eq ["WIP", "foo_bar"] end + it "with a pr_title with tags with dashes" do + branch.pr_title = "[WIP] [2-EL9] This is a PR title" + expect(branch.pr_title_tags).to eq ["WIP", "2-EL9"] + end + it "with a pr_title with tag-like strings not at the start" do branch.pr_title = "This is a [PR] title" expect(branch.pr_title_tags).to eq []