diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-23 06:39:48 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-23 06:39:48 +0000 |
commit | ed732e7a35d5a88a7342166fa3c19c8404955172 (patch) | |
tree | b2d29180c3254a197f553e9f190568bc8a19afc0 /tool/file2lastrev.rb | |
parent | 013bbb94f31b8c1283164691c1db1851750eb455 (diff) | |
download | ruby-ed732e7a35d5a88a7342166fa3c19c8404955172.tar.gz ruby-ed732e7a35d5a88a7342166fa3c19c8404955172.tar.xz ruby-ed732e7a35d5a88a7342166fa3c19c8404955172.zip |
* tool/file2lastrev.rb: detects vcs directory properly on building
outside of srcdir. [ruby-dev:37555] [ruby-dev:37561]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@20936 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/file2lastrev.rb')
-rw-r--r-- | tool/file2lastrev.rb | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/tool/file2lastrev.rb b/tool/file2lastrev.rb index f8f147057..430aca673 100644 --- a/tool/file2lastrev.rb +++ b/tool/file2lastrev.rb @@ -3,17 +3,13 @@ require 'optparse' require 'pathname' +SRCDIR = Pathname(File.dirname($0)).parent.freeze 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 + path = SRCDIR + return :svn, path.relative_path_from(SRCDIR) if File.directory?("#{path}/.svn") + return :git, path.relative_path_from(SRCDIR) if File.directory?("#{path}/.git") raise VCSNotFoundError, "does not seem to be under a vcs" end @@ -23,9 +19,9 @@ def get_revisions(path) info = case vcs when :svn - `svn info #{path}` + `cd '#{SRCDIR}' && svn info '#{path}'` when :git - `git svn info #{path}` + `cd '#{SRCDIR}' && git svn info '#{path}'` end if info =~ /^Revision: (\d+)$/ |