file2lastrev.rb: try to overwrite the found revision.h as before
This commit is contained in:
parent
ac06951c31
commit
3475b66160
@ -90,7 +90,7 @@ formatter =
|
|||||||
ok = true
|
ok = true
|
||||||
(ARGV.empty? ? [nil] : ARGV).each do |arg|
|
(ARGV.empty? ? [nil] : ARGV).each do |arg|
|
||||||
begin
|
begin
|
||||||
@output.write(formatter[*vcs.get_revisions(arg)]+"\n")
|
@output.write(formatter[*vcs.get_revisions(arg)]+"\n", overwrite: true)
|
||||||
rescue => e
|
rescue => e
|
||||||
warn "#{File.basename(Program)}: #{e.message}"
|
warn "#{File.basename(Program)}: #{e.message}"
|
||||||
ok = false
|
ok = false
|
||||||
|
@ -18,7 +18,7 @@ class Output
|
|||||||
@vpath.def_options(opt)
|
@vpath.def_options(opt)
|
||||||
end
|
end
|
||||||
|
|
||||||
def write(data)
|
def write(data, overwrite: false)
|
||||||
unless @path
|
unless @path
|
||||||
$stdout.print data
|
$stdout.print data
|
||||||
return true
|
return true
|
||||||
@ -26,13 +26,16 @@ class Output
|
|||||||
color = Colorize.new(@color)
|
color = Colorize.new(@color)
|
||||||
unchanged = color.pass("unchanged")
|
unchanged = color.pass("unchanged")
|
||||||
updated = color.fail("updated")
|
updated = color.fail("updated")
|
||||||
|
outpath = nil
|
||||||
|
|
||||||
if @ifchange and (@vpath.read(@path, "rb") == data rescue false)
|
if @ifchange and (@vpath.open(@path, "rb") {|f| outpath = f.path; f.read == data} rescue false)
|
||||||
puts "#{@path} #{unchanged}"
|
puts "#{outpath} #{unchanged}"
|
||||||
written = false
|
written = false
|
||||||
else
|
else
|
||||||
File.binwrite(@path, data)
|
unless overwrite and outpath and (File.binwrite(outpath, data) rescue nil)
|
||||||
puts "#{@path} #{updated}"
|
File.binwrite(outpath = @path, data)
|
||||||
|
end
|
||||||
|
puts "#{outpath} #{updated}"
|
||||||
written = true
|
written = true
|
||||||
end
|
end
|
||||||
if timestamp = @timestamp
|
if timestamp = @timestamp
|
||||||
|
Loading…
x
Reference in New Issue
Block a user