Bug #12239 ยป 0001-improve-git-repository-detection.patch
| configure.in | ||
|---|---|---|
|
:
|
||
|
elif svn info "$srcdir" > /dev/null 2>&1; then
|
||
|
VCS='svn'
|
||
|
elif test -d "$srcdir/.git/svn"; then
|
||
|
VCS='git svn'
|
||
|
elif test -d "$srcdir/.git"; then
|
||
|
VCS='git'
|
||
|
elif git_dir=`git --work-tree="$srcdir" --git-dir="$srcdir/.git" rev-parse --git-dir 2>/dev/null`; then
|
||
|
if test -d "$git_dir/svn"; then
|
||
|
VCS='git svn'
|
||
|
else
|
||
|
VCS='git'
|
||
|
fi
|
||
|
else
|
||
|
VCS='echo cannot'
|
||
|
fi
|
||
| tool/change_maker.rb | ||
|---|---|---|
|
#! ./miniruby
|
||
|
$:.unshift(File.expand_path("../../lib", __FILE__))
|
||
|
require File.expand_path("../vcs", __FILE__)
|
||
|
def diff2index(cmd, *argv)
|
||
|
lines = []
|
||
|
path = nil
|
||
| ... | ... | |
|
lines.empty? ? nil : lines
|
||
|
end
|
||
|
if `svnversion` =~ /^\d+/
|
||
|
vcs = begin
|
||
|
VCS.detect(".")
|
||
|
rescue VCS::NotFoundError
|
||
|
nil
|
||
|
end
|
||
|
case vcs
|
||
|
when VCS::SVN
|
||
|
cmd = "svn diff --diff-cmd=diff -x-pU0"
|
||
|
change = diff2index(cmd, ARGV)
|
||
|
elsif File.directory?(".git")
|
||
|
when VCS::GIT
|
||
|
cmd = "git diff -U0"
|
||
|
change = diff2index(cmd, ARGV) || diff2index(cmd, "--cached", ARGV)
|
||
|
else
|
||
| tool/vcs.rb | ||
|---|---|---|
|
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}"
|
||