ruby-changes:74318
From: Nobuyoshi <ko1@a...>
Date: Wed, 2 Nov 2022 13:39:06 +0900 (JST)
Subject: [ruby-changes:74318] 8e2c70af14 (master): file2lastrev.rb: changed revision may be `nil` [ci skip]
https://git.ruby-lang.org/ruby.git/commit/?id=8e2c70af14 From 8e2c70af141239f5142642db35cee11c3d00bd24 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Wed, 2 Nov 2022 13:31:42 +0900 Subject: file2lastrev.rb: changed revision may be `nil` [ci skip] When `--suppress_not_found` option is given, no revision information is available. And remove extraneous newline, when result is empty or ends with a newline. --- tool/file2lastrev.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tool/file2lastrev.rb b/tool/file2lastrev.rb index 48b8a1ae99..1dfb01ab9e 100755 --- a/tool/file2lastrev.rb +++ b/tool/file2lastrev.rb @@ -69,7 +69,7 @@ formatter = https://github.com/ruby/ruby/blob/trunk/tool/file2lastrev.rb#L69 case @format when :changed, nil Proc.new {|last, changed| - changed + changed || "" } when :revision_h Proc.new {|last, changed, modified, branch, title| @@ -90,7 +90,9 @@ formatter = https://github.com/ruby/ruby/blob/trunk/tool/file2lastrev.rb#L90 ok = true (ARGV.empty? ? [nil] : ARGV).each do |arg| begin - @output.write(formatter[*vcs.get_revisions(arg)]+"\n", overwrite: true) + data = formatter[*vcs.get_revisions(arg)] + data.sub!(/(?<!\A|\n)\z/, "\n") + @output.write(data, overwrite: true) rescue => e warn "#{File.basename(Program)}: #{e.message}" ok = false -- cgit v1.2.3 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/