ruby-changes:73969
From: Nobuyoshi <ko1@a...>
Date: Thu, 13 Oct 2022 00:45:59 +0900 (JST)
Subject: [ruby-changes:73969] 80da7250c5 (master): file2lastrev.rb: Refactor VCS directory search
https://git.ruby-lang.org/ruby.git/commit/?id=80da7250c5 From 80da7250c5d7c862e3c1e1431683a1f1211a4d9c Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Wed, 12 Oct 2022 22:03:35 +0900 Subject: file2lastrev.rb: Refactor VCS directory search Search VCS directory after other options are in effective, i.e., `--srcdir=nonexitent --suppress_not_found` options, as well as the reverse order case, should print the current date only and exit successfully. --- tool/file2lastrev.rb | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/tool/file2lastrev.rb b/tool/file2lastrev.rb index 09cb959932..94c2b2a9d6 100755 --- a/tool/file2lastrev.rb +++ b/tool/file2lastrev.rb @@ -26,19 +26,11 @@ vcs = nil https://github.com/ruby/ruby/blob/trunk/tool/file2lastrev.rb#L26 OptionParser.new {|opts| opts.banner << " paths..." vcs_options = VCS.define_options(opts) - new_vcs = proc do |path| - begin - vcs = VCS.detect(path, vcs_options, opts.new) - rescue VCS::NotFoundError => e - abort "#{File.basename(Program)}: #{e.message}" unless @suppress_not_found - opts.remove - nil - end - end + srcdir = nil opts.new opts.on("--srcdir=PATH", "use PATH as source directory") do |path| - abort "#{File.basename(Program)}: srcdir is already set" if vcs - new_vcs[path] + abort "#{File.basename(Program)}: srcdir is already set" if srcdir + srcdir = path end opts.on("--changed", "changed rev") do self.output = :changed @@ -60,10 +52,11 @@ OptionParser.new {|opts| https://github.com/ruby/ruby/blob/trunk/tool/file2lastrev.rb#L52 @suppress_not_found = true end opts.order! rescue abort "#{File.basename(Program)}: #{$!}\n#{opts}" - if vcs - vcs.set_options(vcs_options) # options after --srcdir - elsif new_vcs["."] - else @suppress_not_found + begin + vcs = VCS.detect(srcdir || ".", vcs_options, opts.new) + rescue VCS::NotFoundError => e + abort "#{File.basename(Program)}: #{e.message}" unless @suppress_not_found + opts.remove (vcs = VCS::Null.new(nil)).set_options(vcs_options) end } -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/