mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 21:49:06 +02:00
Refined file2lastrev.rb options
* check --srcdir if given twice or more * falls back to the current working directory if no --srcdir option is given. * define common VCS options.
This commit is contained in:
parent
799de9122e
commit
71f7b0421a
1 changed files with 30 additions and 20 deletions
|
@ -22,10 +22,22 @@ end
|
||||||
@limit = 20
|
@limit = 20
|
||||||
|
|
||||||
format = '%Y-%m-%dT%H:%M:%S%z'
|
format = '%Y-%m-%dT%H:%M:%S%z'
|
||||||
srcdir = nil
|
vcs = nil
|
||||||
parser = OptionParser.new {|opts|
|
OptionParser.new {|opts|
|
||||||
|
opts.banner << " paths..."
|
||||||
|
vcs_options = VCS.define_options(opts)
|
||||||
|
new_vcs = proc do |path|
|
||||||
|
begin
|
||||||
|
VCS.detect(path, vcs_options, opts.new)
|
||||||
|
rescue VCS::NotFoundError => e
|
||||||
|
abort "#{File.basename(Program)}: #{e.message}" unless @suppress_not_found
|
||||||
|
opts.pop
|
||||||
|
end
|
||||||
|
end
|
||||||
|
opts.new
|
||||||
opts.on("--srcdir=PATH", "use PATH as source directory") do |path|
|
opts.on("--srcdir=PATH", "use PATH as source directory") do |path|
|
||||||
srcdir = path
|
abort "#{File.basename(Program)}: srcdir is already set" if vcs
|
||||||
|
vcs = new_vcs[path]
|
||||||
end
|
end
|
||||||
opts.on("--changed", "changed rev") do
|
opts.on("--changed", "changed rev") do
|
||||||
self.output = :changed
|
self.output = :changed
|
||||||
|
@ -46,10 +58,14 @@ parser = OptionParser.new {|opts|
|
||||||
opts.on("-q", "--suppress_not_found") do
|
opts.on("-q", "--suppress_not_found") do
|
||||||
@suppress_not_found = true
|
@suppress_not_found = true
|
||||||
end
|
end
|
||||||
|
opts.order! rescue abort "#{File.basename(Program)}: #{$!}\n#{opts}"
|
||||||
|
if vcs
|
||||||
|
vcs.set_options(vcs_options) # options after --srcdir
|
||||||
|
else
|
||||||
|
vcs = new_vcs["."]
|
||||||
|
end
|
||||||
}
|
}
|
||||||
parser.parse! rescue abort "#{File.basename(Program)}: #{$!}\n#{parser}"
|
|
||||||
|
|
||||||
vcs = nil
|
|
||||||
@output =
|
@output =
|
||||||
case @output
|
case @output
|
||||||
when :changed, nil
|
when :changed, nil
|
||||||
|
@ -94,11 +110,6 @@ vcs = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
srcdir ||= File.dirname(File.dirname(Program))
|
srcdir ||= File.dirname(File.dirname(Program))
|
||||||
begin
|
|
||||||
vcs = VCS.detect(srcdir)
|
|
||||||
rescue VCS::NotFoundError => e
|
|
||||||
abort "#{File.basename(Program)}: #{e.message}" unless @suppress_not_found
|
|
||||||
else
|
|
||||||
ok = true
|
ok = true
|
||||||
(ARGV.empty? ? [nil] : ARGV).each do |arg|
|
(ARGV.empty? ? [nil] : ARGV).each do |arg|
|
||||||
begin
|
begin
|
||||||
|
@ -110,4 +121,3 @@ else
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
exit ok
|
exit ok
|
||||||
end
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue