diff --git a/tool/file2lastrev.rb b/tool/file2lastrev.rb index a3cdcf05c3..09cb959932 100755 --- a/tool/file2lastrev.rb +++ b/tool/file2lastrev.rb @@ -32,8 +32,8 @@ OptionParser.new {|opts| rescue VCS::NotFoundError => e abort "#{File.basename(Program)}: #{e.message}" unless @suppress_not_found opts.remove + nil end - nil end opts.new opts.on("--srcdir=PATH", "use PATH as source directory") do |path| @@ -62,15 +62,11 @@ OptionParser.new {|opts| opts.order! rescue abort "#{File.basename(Program)}: #{$!}\n#{opts}" if vcs vcs.set_options(vcs_options) # options after --srcdir - else - new_vcs["."] + elsif new_vcs["."] + else @suppress_not_found + (vcs = VCS::Null.new(nil)).set_options(vcs_options) end } -unless vcs - # Output only release_date when .git is missing - puts VCS.release_date if @output == :revision_h - exit -end output = case @output @@ -99,10 +95,6 @@ ok = true begin puts output[*vcs.get_revisions(arg)] rescue => e - if @suppress_not_found and VCS::NotFoundError === e - puts VCS.release_date if @output == :revision_h - next - end warn "#{File.basename(Program)}: #{e.message}" ok = false end diff --git a/tool/lib/vcs.rb b/tool/lib/vcs.rb index d0301b92d8..8944189bce 100644 --- a/tool/lib/vcs.rb +++ b/tool/lib/vcs.rb @@ -98,7 +98,7 @@ class VCS opts end - def self.release_date(time = Time.now - 10) # the same default as make-snapshot + def release_date(time) t = time.utc [ t.strftime('#define RUBY_RELEASE_YEAR %Y'), @@ -246,7 +246,7 @@ class VCS t = release_datetime.utc code << t.strftime('#define RUBY_RELEASE_DATETIME "%FT%TZ"') end - code += VCS.release_date(release_date) + code += self.release_date(release_date) code end @@ -775,4 +775,15 @@ class VCS true end end + + class Null < self + def get_revisions(path, srcdir = nil) + @modified ||= Time.now - 10 + return nil, nil, @modified + end + + def revision_header(last, release_date, release_datetime = nil, branch = nil, title = nil, limit: 20) + self.release_date(release_date) + end + end end diff --git a/tool/make-snapshot b/tool/make-snapshot index 22ae360c3e..d9c0b125fa 100755 --- a/tool/make-snapshot +++ b/tool/make-snapshot @@ -295,7 +295,7 @@ def package(vcs, rev, destdir, tmp = nil) if info = vcs.get_revisions(url) modified = info[2] else - modified = Time.now - 10 + _, _, modified = VCS::Null.new(nil).get_revisions(url) end if !revision and info revision = info