ruby-changes:9398
From: yugui <ko1@a...>
Date: Tue, 23 Dec 2008 15:40:00 +0900 (JST)
Subject: [ruby-changes:9398] Ruby:r20936 (trunk): * tool/file2lastrev.rb: detects vcs directory properly on building
yugui 2008-12-23 15:39:48 +0900 (Tue, 23 Dec 2008) New Revision: 20936 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20936 Log: * tool/file2lastrev.rb: detects vcs directory properly on building outside of srcdir. [ruby-dev:37555] [ruby-dev:37561] Modified files: trunk/ChangeLog trunk/tool/file2lastrev.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 20935) +++ ChangeLog (revision 20936) @@ -1,3 +1,8 @@ +Tue Dec 23 15:36:58 2008 Yuki Sonoda (Yugui) <yugui@y...> + + * tool/file2lastrev.rb: detects vcs directory properly on building + outside of srcdir. [ruby-dev:37555] [ruby-dev:37561] + Tue Dec 23 15:30:02 2008 NAKAMURA Usaku <usa@r...> * io.c (pipe_open): need to initialize args. Index: tool/file2lastrev.rb =================================================================== --- tool/file2lastrev.rb (revision 20935) +++ tool/file2lastrev.rb (revision 20936) @@ -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 @@ 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+)$/ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/