summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-23 09:36:05 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-23 09:36:05 +0000
commitb8081c7c4c9d959a4646d08c6b50dcf6318821c0 (patch)
tree84bd7b3193481593d2b83a091d2bfc33f36f53c3
parent8009794c09fd7873e0c0cbbd10c0e26ee5a271f3 (diff)
file2lastrev.rb: all ARGV
* tool/file2lastrev.rb: output for each arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rwxr-xr-xtool/file2lastrev.rb69
1 files changed, 42 insertions, 27 deletions
diff --git a/tool/file2lastrev.rb b/tool/file2lastrev.rb
index 100206d..39b3d63 100755
--- a/tool/file2lastrev.rb
+++ b/tool/file2lastrev.rb
@@ -40,38 +40,53 @@ parser = OptionParser.new {|opts|
}
parser.parse! rescue abort "#{File.basename(Program)}: #{$!}\n#{parser}"
+@output =
+ case @output
+ when :changed, nil
+ proc {|last, changed|
+ changed
+ }
+ when :revision_h
+ proc {|last, changed, modified, branch, title|
+ [
+ "#define RUBY_REVISION #{changed || 0}",
+ if branch
+ e = '..'
+ limit = 16
+ name = branch.sub(/\A(.{#{limit-e.size}}).{#{e.size+1},}/o) {$1+e}
+ "#define RUBY_BRANCH_NAME #{name.dump}"
+ end,
+ if title
+ "#define RUBY_LAST_COMMIT_TITLE #{title.dump}"
+ end,
+ ].compact
+ }
+ when :doxygen
+ proc {|last, changed|
+ "r#{changed}/r#{last}"
+ }
+ when :modified
+ proc {|last, changed, modified|
+ modified.strftime('%Y-%m-%dT%H:%M:%S%z')
+ }
+ else
+ raise "unknown output format `#{@output}'"
+ end
+
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
- begin
- last, changed, modified, branch, title = vcs.get_revisions(ARGV.shift)
- rescue => e
- abort "#{File.basename(Program)}: #{e.message}" unless @suppress_not_found
- exit false
+ ok = true
+ (ARGV.empty? ? [nil] : ARGV).each do |arg|
+ begin
+ puts @output[*vcs.get_revisions(arg)]
+ rescue => e
+ warn "#{File.basename(Program)}: #{e.message}" unless @suppress_not_found
+ ok = false
+ end
end
-end
-
-case @output
-when :changed, nil
- puts changed
-when :revision_h
- puts "#define RUBY_REVISION #{changed || 0}"
- if branch
- e = '..'
- limit = 16
- name = branch.sub(/\A(.{#{limit-e.size}}).{#{e.size+1},}/o) {$1+e}
- puts "#define RUBY_BRANCH_NAME #{name.dump}"
- end
- if title
- puts "#define RUBY_LAST_COMMIT_TITLE #{title.dump}"
- end
-when :doxygen
- puts "r#{changed}/r#{last}"
-when :modified
- puts modified.strftime('%Y-%m-%dT%H:%M:%S%z')
-else
- raise "unknown output format `#{@output}'"
+ exit ok
end