1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.
This commit is contained in:
Nobuyoshi Nakada 2022-11-02 13:31:42 +09:00
parent 3475b66160
commit 8e2c70af14
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6

View file

@ -69,7 +69,7 @@ formatter =
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 =
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