diff --git a/lib/prettyprint.rb b/lib/prettyprint.rb index a65407c1304df9..44ca5e816fb527 100644 --- a/lib/prettyprint.rb +++ b/lib/prettyprint.rb @@ -487,8 +487,10 @@ def delete(group) # It is passed to be similar to a PrettyPrint object itself, by responding to: # * #text # * #breakable + # * #fill_breakable # * #nest # * #group + # * #group_sub # * #flush # * #first? # @@ -522,6 +524,13 @@ def breakable(sep=' ', width=nil) @output << sep end + # Appends +sep+ to the text to be output. By default +sep+ is ' ' + # + # +width+ argument is here for compatibility. It is a noop argument. + def fill_breakable(sep=' ', width=nil) + @output << sep + end + # Takes +indent+ arg, but does nothing with it. # # Yields to a block. @@ -545,6 +554,15 @@ def group(indent=nil, open_obj='', close_obj='', open_width=nil, close_width=nil @first.pop end + # Yields to a block for compatibility. + def group_sub # :nodoc: + yield + end + + # Method present for compatibility, but is a noop + def break_outmost_groups # :nodoc: + end + # Method present for compatibility, but is a noop def flush # :nodoc: end diff --git a/test/test_prettyprint.rb b/test/test_prettyprint.rb index 27e7198886bcf0..a9ea55d5b3a018 100644 --- a/test/test_prettyprint.rb +++ b/test/test_prettyprint.rb @@ -518,4 +518,75 @@ def test_27 end +class SingleLineFormat < Test::Unit::TestCase # :nodoc: + + def test_singleline_format_with_breakables + singleline_format = PrettyPrint.singleline_format("".dup) do |q| + q.group 0, "(", ")" do + q.text "abc" + q.breakable + q.text "def" + q.breakable + q.text "ghi" + q.breakable + q.text "jkl" + q.breakable + q.text "mno" + q.breakable + q.text "pqr" + q.breakable + q.text "stu" + end + end + expected = <<'End'.chomp +(abc def ghi jkl mno pqr stu) +End + + assert_equal(expected, singleline_format) + end + + def test_singleline_format_with_fill_breakables + singleline_format = PrettyPrint.singleline_format("".dup) do |q| + q.group 0, "(", ")" do + q.text "abc" + q.fill_breakable + q.text "def" + q.fill_breakable + q.text "ghi" + q.fill_breakable + q.text "jkl" + q.fill_breakable + q.text "mno" + q.fill_breakable + q.text "pqr" + q.fill_breakable + q.text "stu" + end + end + expected = <<'End'.chomp +(abc def ghi jkl mno pqr stu) +End + + assert_equal(expected, singleline_format) + end + + def test_singleline_format_with_group_sub + singleline_format = PrettyPrint.singleline_format("".dup) do |q| + q.group 0, "(", ")" do + q.group_sub do + q.text "abc" + q.breakable + q.text "def" + end + q.breakable + q.text "ghi" + end + end + expected = <<'End'.chomp +(abc def ghi) +End + + assert_equal(expected, singleline_format) + end +end end diff --git a/tool/lib/vcs.rb b/tool/lib/vcs.rb index 4169031436e993..ce545ec368eef9 100644 --- a/tool/lib/vcs.rb +++ b/tool/lib/vcs.rb @@ -595,15 +595,6 @@ def changelog_formatter(path, arg, base_url = nil) s = s.join('') end - s.gsub!(%r[(?!<\w)([-\w]+/[-\w]+)(?:@(\h{8,40})|#(\d{5,}))\b]) do - path = defined?($2) ? "commit/#{$2}" : "pull/#{$3}" - "[#$&](https://github.com/#{$1}/#{path})" - end - if %r[^ +(https://github\.com/[^/]+/[^/]+/)commit/\h+\n(?=(?: +\n(?i: +Co-authored-by: .*\n)+)?(?:\n|\Z))] =~ s - issue = "#{$1}pull/" - s.gsub!(/\b(?:(?i:fix(?:e[sd])?) +|GH-)\K#(?=\d+\b)|\(\K#(?=\d+\))/) {issue} - end - s.gsub!(/ +\n/, "\n") s.sub!(/^Notes:/, ' \&') w.print sep, h, s