Skip to content
代码片段 群组 项目
提交 b0b74962 编辑于 作者: Dylan Griffith's avatar Dylan Griffith
浏览文件

GitLab Housekeeper handle more special characters in identifiers

These special characters break the branch name. We might want to use
file paths and namespaced class names in `identifiers` in future and as
such we should strip these out when generating the branch name.
上级 8f360e97
无相关合并请求
......@@ -54,6 +54,7 @@ def create_commit(branch_name, change)
def branch_name(identifiers)
# Hyphen-case each identifier then join together with hyphens.
branch_name = identifiers
.map { |i| i.gsub(/[^\w]+/, '-') }
.map { |i| i.gsub(/[[:upper:]]/) { |w| "-#{w.downcase}" } }
.join('-')
.delete_prefix("-")
......
......@@ -9,7 +9,7 @@
let(:logger) { instance_double(Logger, info: nil) }
let(:git) { described_class.new(logger: logger) }
let(:repository_path) { Pathname(Dir.mktmpdir) }
let(:test_branch_name) { 'gitlab-housekeeper--test-branch' }
let(:test_branch_name) { 'gitlab-housekeeper--some-class--test--branch_123' }
let(:file_in_master) { 'file_in_master.txt' }
let(:file_in_another_branch) { 'file_in_another_branch.txt' }
......@@ -57,7 +57,7 @@ def setup_and_checkout_another_branch
split over multiple lines!
COMMIT
change.identifiers = %w[GitlabHousekeeper TestBranch]
change.identifiers = %w[GitlabHousekeeper::SomeClass Test/Branch_123]
Dir.mkdir('files')
File.write(test_file1, "Content in file 1!")
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册