diff options
author | Takashi Kokubun <takashikkbn@gmail.com> | 2022-12-12 23:34:30 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-12 23:34:30 -0800 |
commit | 7edcdc380f3bb6f5a81bfb5798c339acd844a0d3 (patch) | |
tree | 4a3b22f1765fe2edc6525595af264c3970201799 /tool/lib | |
parent | 3e00cb8256cfe0640cb1d744d07d496128edb7e9 (diff) | |
download | ruby-7edcdc380f3bb6f5a81bfb5798c339acd844a0d3.tar.gz |
Avoid overwriting revision.h when .git doesn't exist (#6915)
* Avoid overwriting revision.h when .git doesn't exist
* Overwrite revision.h if it's blank
Diffstat (limited to 'tool/lib')
-rw-r--r-- | tool/lib/output.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tool/lib/output.rb b/tool/lib/output.rb index 3a9f3d87ae..b1c4f4a866 100644 --- a/tool/lib/output.rb +++ b/tool/lib/output.rb @@ -18,7 +18,7 @@ class Output @vpath.def_options(opt) end - def write(data, overwrite: false) + def write(data, overwrite: false, create_only: false) unless @path $stdout.print data return true @@ -28,8 +28,8 @@ class Output updated = color.fail("updated") outpath = nil - if (@ifchange or overwrite) and - (@vpath.open(@path, "rb") {|f| outpath = f.path; f.read == data if @ifchange} rescue false) + if (@ifchange or overwrite or create_only) and + (@vpath.open(@path, "rb") {|f| outpath = f.path; (@ifchange and f.read == data) or (create_only and !f.read.empty?)} rescue false) puts "#{outpath} #{unchanged}" written = false else |