summaryrefslogtreecommitdiff
path: root/tool/vcs.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-10 01:58:27 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-10 01:58:27 +0000
commitfec4b2225eb9764c4de260562806e76a1264c530 (patch)
tree4601c4d05f8b1706683dc254c899dc6607bbd9bb /tool/vcs.rb
parent93cb2b3563896a10e1f01b567faa1da8323db96a (diff)
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
Diffstat (limited to 'tool/vcs.rb')
-rw-r--r--tool/vcs.rb13
1 files changed, 6 insertions, 7 deletions
diff --git a/tool/vcs.rb b/tool/vcs.rb
index ca9c8964b5..db3e5cf4bc 100644
--- a/tool/vcs.rb
+++ b/tool/vcs.rb
@@ -125,14 +125,13 @@ class VCS
end
def self.detect(path)
- @@dirs.each do |dir, klass, pred|
- curr = path
- loop {
+ curr = path
+ begin
+ @@dirs.each do |dir, klass, pred|
return klass.new(curr) if pred ? pred[curr, dir] : File.directory?(File.join(curr, dir))
- prev, curr = curr, File.realpath(File.join(curr, '..'))
- break if curr == prev # stop at the root directory
- }
- end
+ 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}"
end