diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-10-04 19:19:51 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-10-04 19:27:34 +0900 |
commit | 94bcae1b2a2840c1a8031ef936870be693425551 (patch) | |
tree | 985bdfc6f113e30da04d9fa08ba4adb25f79912e /tool | |
parent | 465bc682a2b4823899be19440b0fd3395c22a255 (diff) | |
download | ruby-94bcae1b2a2840c1a8031ef936870be693425551.tar.gz |
Special treat when the first line ends with a dot [ci skip]
Diffstat (limited to 'tool')
-rwxr-xr-x | tool/sync_default_gems.rb | 6 | ||||
-rwxr-xr-x | tool/test/test_sync_default_gems.rb | 9 |
2 files changed, 14 insertions, 1 deletions
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 |