diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-03-17 18:30:02 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-04-01 01:20:10 +0900 |
commit | 4124dc8714f0d6e8f9b19cc138d630291292a846 (patch) | |
tree | e4f994ce284c7922ea6061e445b4dd005677858f /tool/vcs.rb | |
parent | f0060b81c672e5f80ffed1b3a979d218b49e1021 (diff) | |
download | ruby-4124dc8714f0d6e8f9b19cc138d630291292a846.tar.gz |
improve git repository detectionfix/git-worktree-detection
* configure.in (AC_CONFIG_FILES): $srcdir/.git can be a file pointing
the real git_dir, such as when the git working tree is a "linked
working tree" (a working tree created by git-worktree). So use
git-rev-parse --git-dir to check if $srcdir is the top-level of a git
repository, not just checking if the $srcdir/.git directory does exist
or not.
* tool/change_maker.rb: use tool/vcs.rb to detect VCS. This used to have
its own VCS detection code, while we have tool/vcs.rb.
* tool/vcs.rb (detect): remove code duplication
Diffstat (limited to 'tool/vcs.rb')
-rw-r--r-- | tool/vcs.rb | 12 |
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}" |