aboutsummaryrefslogtreecommitdiffstats
path: root/tool/vcs.rb
diff options
context:
space:
mode:
Diffstat (limited to 'tool/vcs.rb')
-rw-r--r--tool/vcs.rb12
1 files changed, 4 insertions, 8 deletions
diff --git a/tool/vcs.rb b/tool/vcs.rb
index 4d8936cb54..0f20c6e35a 100644
--- a/tool/vcs.rb
+++ b/tool/vcs.rb
@@ -73,15 +73,11 @@ class VCS
def self.detect(path)
@@dirs.each do |dir, klass, pred|
- if pred ? pred[path, dir] : File.directory?(File.join(path, dir))
- return klass.new(path)
- end
- prev = path
+ curr = path
loop {
- curr = File.realpath(File.join(prev, '..'))
- break if curr == prev # stop at the root directory
- return klass.new(path) if File.directory?(File.join(curr, dir))
- prev = curr
+ 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
raise VCS::NotFoundError, "does not seem to be under a vcs: #{path}"