mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
improve git repository 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. [ruby-core:74759] [Bug #12239] * 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 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
34c0c84086
commit
69d6e315b5
4 changed files with 36 additions and 14 deletions
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
Fri Apr 1 14:55:28 2016 Kazuki Yamaguchi <k@rhe.jp>
|
||||||
|
|
||||||
|
* 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. [ruby-core:74759] [Bug #12239]
|
||||||
|
|
||||||
|
* 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
|
||||||
|
|
||||||
Fri Apr 1 04:50:44 2016 Eric Wong <e@80x24.org>
|
Fri Apr 1 04:50:44 2016 Eric Wong <e@80x24.org>
|
||||||
|
|
||||||
* ext/openssl/ossl_ssl.c (ossl_sslctx_s_alloc):
|
* ext/openssl/ossl_ssl.c (ossl_sslctx_s_alloc):
|
||||||
|
|
10
configure.in
10
configure.in
|
@ -4464,10 +4464,12 @@ AC_CONFIG_FILES(Makefile, [
|
||||||
:
|
:
|
||||||
elif svn info "$srcdir" > /dev/null 2>&1; then
|
elif svn info "$srcdir" > /dev/null 2>&1; then
|
||||||
VCS='svn'
|
VCS='svn'
|
||||||
elif test -d "$srcdir/.git/svn"; then
|
elif git_dir=`git --work-tree="$srcdir" --git-dir="$srcdir/.git" rev-parse --git-dir 2>/dev/null`; then
|
||||||
VCS='git svn'
|
if test -d "$git_dir/svn"; then
|
||||||
elif test -d "$srcdir/.git"; then
|
VCS='git svn'
|
||||||
VCS='git'
|
else
|
||||||
|
VCS='git'
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
VCS='echo cannot'
|
VCS='echo cannot'
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
#! ./miniruby
|
#! ./miniruby
|
||||||
|
|
||||||
|
$:.unshift(File.expand_path("../../lib", __FILE__))
|
||||||
|
require File.expand_path("../vcs", __FILE__)
|
||||||
|
|
||||||
def diff2index(cmd, *argv)
|
def diff2index(cmd, *argv)
|
||||||
lines = []
|
lines = []
|
||||||
path = nil
|
path = nil
|
||||||
|
@ -22,10 +25,17 @@ def diff2index(cmd, *argv)
|
||||||
lines.empty? ? nil : lines
|
lines.empty? ? nil : lines
|
||||||
end
|
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"
|
cmd = "svn diff --diff-cmd=diff -x-pU0"
|
||||||
change = diff2index(cmd, ARGV)
|
change = diff2index(cmd, ARGV)
|
||||||
elsif File.directory?(".git")
|
when VCS::GIT
|
||||||
cmd = "git diff -U0"
|
cmd = "git diff -U0"
|
||||||
change = diff2index(cmd, ARGV) || diff2index(cmd, "--cached", ARGV)
|
change = diff2index(cmd, ARGV) || diff2index(cmd, "--cached", ARGV)
|
||||||
else
|
else
|
||||||
|
|
12
tool/vcs.rb
12
tool/vcs.rb
|
@ -73,15 +73,11 @@ class VCS
|
||||||
|
|
||||||
def self.detect(path)
|
def self.detect(path)
|
||||||
@@dirs.each do |dir, klass, pred|
|
@@dirs.each do |dir, klass, pred|
|
||||||
if pred ? pred[path, dir] : File.directory?(File.join(path, dir))
|
curr = path
|
||||||
return klass.new(path)
|
|
||||||
end
|
|
||||||
prev = path
|
|
||||||
loop {
|
loop {
|
||||||
curr = File.realpath(File.join(prev, '..'))
|
return klass.new(curr) if pred ? pred[curr, dir] : File.directory?(File.join(curr, dir))
|
||||||
break if curr == prev # stop at the root directory
|
prev, curr = curr, File.realpath(File.join(curr, '..'))
|
||||||
return klass.new(path) if File.directory?(File.join(curr, dir))
|
break if curr == prev # stop at the root directory
|
||||||
prev = curr
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
raise VCS::NotFoundError, "does not seem to be under a vcs: #{path}"
|
raise VCS::NotFoundError, "does not seem to be under a vcs: #{path}"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue