mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Detection order
* tool/vcs.rb (VCS.detect): detect each VCS while travarsing parent directories. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
93cb2b3563
commit
fec4b2225e
1 changed files with 6 additions and 7 deletions
13
tool/vcs.rb
13
tool/vcs.rb
|
@ -125,14 +125,13 @@ class VCS
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.detect(path)
|
def self.detect(path)
|
||||||
@@dirs.each do |dir, klass, pred|
|
curr = path
|
||||||
curr = path
|
begin
|
||||||
loop {
|
@@dirs.each do |dir, klass, pred|
|
||||||
return klass.new(curr) if pred ? pred[curr, dir] : File.directory?(File.join(curr, dir))
|
return klass.new(curr) if pred ? pred[curr, dir] : File.directory?(File.join(curr, dir))
|
||||||
prev, curr = curr, File.realpath(File.join(curr, '..'))
|
end
|
||||||
break if curr == prev # stop at the root directory
|
prev, curr = curr, File.realpath(File.join(curr, '..'))
|
||||||
}
|
end until curr == prev # stop at the root directory
|
||||||
end
|
|
||||||
raise VCS::NotFoundError, "does not seem to be under a vcs: #{path}"
|
raise VCS::NotFoundError, "does not seem to be under a vcs: #{path}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue