зеркало из https://github.com/github/ruby.git
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
This commit is contained in:
Родитель
8009794c09
Коммит
b8081c7c4c
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче