Special treat when the first line ends with a dot [ci skip]

This commit is contained in:
Nobuyoshi Nakada 2023-10-04 19:19:51 +09:00
Родитель 465bc682a2
Коммит 94bcae1b2a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 3582D74E1FEE4465
2 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -449,7 +449,11 @@ module SyncDefaultGems
log.delete!("\r")
log << "\n" if !log.end_with?("\n")
repo_url = "https://github.com/#{repo}"
subject, log = log.split(/\n(?:[ \t]*(?:\n|\z))/, 2)
# Split the subject from the log message according to git conventions.
# SPECIAL TREAT: when the first line ends with a dot `.` (which is not
# obeying the conventions too), takes only that line.
subject, log = log.split(/\A.+\.\K\n(?=\S)|\n(?:[ \t]*(?:\n|\z))/, 2)
conv = proc do |s|
mod = true if s.gsub!(/\b(?:(?i:fix(?:e[sd])?|close[sd]?|resolve[sd]?) +)\K#(?=\d+\b)|\bGH-#?(?=\d+\b)|\(\K#(?=\d+\))/) {
"#{repo_url}/pull/"

Просмотреть файл

@ -73,6 +73,15 @@ module Test_SyncDefaultGems
]
assert_message_filter(expected, trailers, [expected, "", trailers].join("\n"))
end
def test_dot_ending_subject
expected = [
"subject with a dot.",
"",
"- next body line",
]
assert_message_filter(expected, nil, [expected[0], expected[2], ""].join("\n"))
end
end
class TestSyncWithCommits < Test::Unit::TestCase