[前][次][番号順一覧][スレッド一覧]

ruby-changes:36753

From: nobu <ko1@a...>
Date: Sun, 14 Dec 2014 08:55:38 +0900 (JST)
Subject: [ruby-changes:36753] nobu:r48834 (trunk): vcs.rb: srcdir parameter

nobu	2014-12-14 08:55:33 +0900 (Sun, 14 Dec 2014)

  New Revision: 48834

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48834

  Log:
    vcs.rb: srcdir parameter
    
    * tool/vcs.rb (VCS#get_revisions): add srcdir optional parameter
      to SVN.get_revisions and GIT.get_revisions, instead of change
      working directory.

  Modified files:
    trunk/tool/vcs.rb
Index: tool/vcs.rb
===================================================================
--- tool/vcs.rb	(revision 48833)
+++ tool/vcs.rb	(revision 48834)
@@ -43,20 +43,20 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L43
   # +path+ was modified.
   def get_revisions(path)
     path = relative_to(path)
-    last, changed, modified, *rest = Dir.chdir(@srcdir) {
+    last, changed, modified, *rest = (
       begin
         if NullDevice
           save_stderr = STDERR.dup
           STDERR.reopen NullDevice, 'w'
         end
-        self.class.get_revisions(path)
+        self.class.get_revisions(path, @srcdir)
       ensure
         if save_stderr
           STDERR.reopen save_stderr
           save_stderr.close
         end
       end
-    }
+    )
     last or raise VCS::NotFoundError, "last revision not found"
     changed or raise VCS::NotFoundError, "changed revision not found"
     if modified
@@ -94,7 +94,10 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L94
   class SVN < self
     register(".svn")
 
-    def self.get_revisions(path)
+    def self.get_revisions(path, srcdir = nil)
+      if srcdir and %r'\A(?:[^/]+:|/)' !~ path
+        path = File.join(srcdir, path)
+      end
       info_xml = `svn info --xml "#{path}"`
       _, last, _, changed, _ = info_xml.split(/revision="(\d+)"/)
       modified = info_xml[/<date>([^<>]*)/, 1]
@@ -105,8 +108,8 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L108
   class GIT < self
     register(".git")
 
-    def self.get_revisions(path)
-      logcmd = %Q[git log -n1 --date=iso --grep="^ *git-svn-id: .*@[0-9][0-9]* "]
+    def self.get_revisions(path, srcdir = nil)
+      logcmd = %Q[git -C "#{srcdir || '.'}" log -n1 --date=iso --grep="^ *git-svn-id: .*@[0-9][0-9]* "]
       idpat = /git-svn-id: .*?@(\d+) \S+\Z/
       last = `#{logcmd}`[idpat, 1]
       if path

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]