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

ruby-changes:54084

From: nobu <ko1@a...>
Date: Mon, 10 Dec 2018 10:58:34 +0900 (JST)
Subject: [ruby-changes:54084] nobu:r66305 (trunk): Limit uplevel travarsing

nobu	2018-12-10 10:58:28 +0900 (Mon, 10 Dec 2018)

  New Revision: 66305

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

  Log:
    Limit uplevel travarsing
    
    * tool/vcs.rb (VCS.detect): limit level of travarsing parent
      directories, 0 by the default.  curretly always detecting at the
      source directory itself.

  Modified files:
    trunk/tool/vcs.rb
Index: tool/vcs.rb
===================================================================
--- tool/vcs.rb	(revision 66304)
+++ tool/vcs.rb	(revision 66305)
@@ -124,12 +124,16 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L124
     @@dirs << [dir, self, pred]
   end
 
-  def self.detect(path)
+  def self.detect(path, uplevel_limit: 0)
     curr = path
     begin
       @@dirs.each do |dir, klass, pred|
         return klass.new(curr) if pred ? pred[curr, dir] : File.directory?(File.join(curr, dir))
       end
+      if uplevel_limit
+        break if uplevel_limit.zero?
+        uplevel_limit -= 1
+      end
       prev, curr = curr, File.realpath(File.join(curr, '..'))
     end until curr == prev # stop at the root directory
     raise VCS::NotFoundError, "does not seem to be under a vcs: #{path}"

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

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