mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
vcs.rb: git worktree
* tool/vcs.rb (VCS.detect, VCS::GIT): support working directory created by `git worktree`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
131f699d98
commit
1bdc2d5150
1 changed files with 7 additions and 5 deletions
12
tool/vcs.rb
12
tool/vcs.rb
|
@ -67,13 +67,15 @@ class VCS
|
|||
class NotFoundError < RuntimeError; end
|
||||
|
||||
@@dirs = []
|
||||
def self.register(dir)
|
||||
@@dirs << [dir, self]
|
||||
def self.register(dir, &pred)
|
||||
@@dirs << [dir, self, pred]
|
||||
end
|
||||
|
||||
def self.detect(path)
|
||||
@@dirs.each do |dir, klass|
|
||||
return klass.new(path) if File.directory?(File.join(path, dir))
|
||||
@@dirs.each do |dir, klass, pred|
|
||||
if pred ? pred[path, dir] : File.directory?(File.join(path, dir))
|
||||
return klass.new(path)
|
||||
end
|
||||
prev = path
|
||||
loop {
|
||||
curr = File.realpath(File.join(prev, '..'))
|
||||
|
@ -282,7 +284,7 @@ class VCS
|
|||
end
|
||||
|
||||
class GIT < self
|
||||
register(".git")
|
||||
register(".git") {|path, dir| File.exist?(File.join(path, dir))}
|
||||
|
||||
def self.get_revisions(path, srcdir = nil)
|
||||
gitcmd = %W[git]
|
||||
|
|
Loading…
Reference in a new issue