From 94bcae1b2a2840c1a8031ef936870be693425551 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 4 Oct 2023 19:19:51 +0900 Subject: Special treat when the first line ends with a dot [ci skip] --- tool/sync_default_gems.rb | 6 +++++- tool/test/test_sync_default_gems.rb | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'tool') diff --git a/tool/sync_default_gems.rb b/tool/sync_default_gems.rb index 44f11e22d2..02e73b254a 100755 --- a/tool/sync_default_gems.rb +++ b/tool/sync_default_gems.rb @@ -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/" diff --git a/tool/test/test_sync_default_gems.rb b/tool/test/test_sync_default_gems.rb index 489feb2894..b48b51bb52 100755 --- a/tool/test/test_sync_default_gems.rb +++ b/tool/test/test_sync_default_gems.rb @@ -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 -- cgit v1.2.3