diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-22 13:19:08 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-22 13:19:08 +0000 |
commit | c09e5abeee5e08e6c261e3618afa60020371eb96 (patch) | |
tree | 0871288276c8d388f2c269df6d560220edf77d2d /tool/file2lastrev.rb | |
parent | a550f2992bfbde8649e975eb345a4b478adbdd05 (diff) | |
download | ruby-c09e5abeee5e08e6c261e3618afa60020371eb96.tar.gz |
* Doxyfile.in: new file. Template of a configuration file for
Doxygen.
Intorduces C-level API reference generation with Doxygen.
* tool/file2lastrev.rb: wrapper script that abstracts subversion
and git-svn.
* tool/strip-rdoc.rb: filter for preventing doxygen from processing
rdoc comments.
* configure.in: (Doxyfile): Doxyfile is generated together with
Makefile.
(PACKAGE): configuration $(PACKAGE) is necessary for $(docdir).
* instruby.rb: adds a new install target 'capi'
* common.mk (capi): new target that generates C API documents with
Doxygen.
(install-capi): new target.
(pre-install-capi): ditto.
(do-install-capi): ditto.
(post-install-capi): ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/file2lastrev.rb')
-rw-r--r-- | tool/file2lastrev.rb | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/tool/file2lastrev.rb b/tool/file2lastrev.rb new file mode 100644 index 0000000000..f8f1470574 --- /dev/null +++ b/tool/file2lastrev.rb @@ -0,0 +1,84 @@ +#!/usr/bin/env ruby + +require 'optparse' +require 'pathname' + +class VCSNotFoundError < RuntimeError; end + +def detect_vcs(path) + target_path = Pathname(File.expand_path(path)) + + path = target_path.directory? ? target_path : target_path.parent + begin + return :svn, target_path.relative_path_from(path) if File.directory?("#{path}/.svn") + return :git, target_path.relative_path_from(path) if File.directory?("#{path}/.git") + path, orig = path.parent, path + end until path == orig + raise VCSNotFoundError, "does not seem to be under a vcs" +end + +def get_revisions(path) + ENV['LANG'] = ENV['LC_ALL'] = ENV['LC_MESSAGES'] = 'C' + vcs, path = detect_vcs(path) + + info = case vcs + when :svn + `svn info #{path}` + when :git + `git svn info #{path}` + end + + if info =~ /^Revision: (\d+)$/ + last = $1 + else + raise "last revision not found" + end + if info =~ /^Last Changed Rev: (\d+)$/ + changed = $1 + else + raise "changed revision not found" + end + + return last, changed +end + +def raise_if_conflict + raise "you can specify only one of --changed, --revision.h and --doxygen" if $output +end + +parser = OptionParser.new {|opts| + opts.on("--changed", "changed rev") do + raise_if_conflict + $output = :changed + end + opts.on("--revision.h") do + raise_if_conflict + $output = :revision_h + end + opts.on("--doxygen") do + raise_if_conflict + $output = :doxygen + end + opts.on("-q", "--suppress_not_found") do + $suppress_not_found = true + end +} +parser.parse! + + +begin + last, changed = get_revisions(ARGV.shift) +rescue VCSNotFoundError + raise unless $suppress_not_found +end + +case $output +when :changed, nil + puts changed +when :revision_h + puts "#define RUBY_REVISION #{changed}" +when :doxygen + puts "r#{changed}/r#{last}" +else + raise "unknown output format `#{$output}'" +end |