1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

vcs.rb: srcdir parameter

* tool/vcs.rb (VCS#get_revisions): add srcdir optional parameter
  to SVN.get_revisions and GIT.get_revisions, instead of change
  working directory.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-12-13 23:55:33 +00:00
parent 7c81643953
commit db4e9d5eb3

View file

@ -43,20 +43,20 @@ class VCS
# +path+ was modified. # +path+ was modified.
def get_revisions(path) def get_revisions(path)
path = relative_to(path) path = relative_to(path)
last, changed, modified, *rest = Dir.chdir(@srcdir) { last, changed, modified, *rest = (
begin begin
if NullDevice if NullDevice
save_stderr = STDERR.dup save_stderr = STDERR.dup
STDERR.reopen NullDevice, 'w' STDERR.reopen NullDevice, 'w'
end end
self.class.get_revisions(path) self.class.get_revisions(path, @srcdir)
ensure ensure
if save_stderr if save_stderr
STDERR.reopen save_stderr STDERR.reopen save_stderr
save_stderr.close save_stderr.close
end end
end end
} )
last or raise VCS::NotFoundError, "last revision not found" last or raise VCS::NotFoundError, "last revision not found"
changed or raise VCS::NotFoundError, "changed revision not found" changed or raise VCS::NotFoundError, "changed revision not found"
if modified if modified
@ -94,7 +94,10 @@ class VCS
class SVN < self class SVN < self
register(".svn") register(".svn")
def self.get_revisions(path) def self.get_revisions(path, srcdir = nil)
if srcdir and %r'\A(?:[^/]+:|/)' !~ path
path = File.join(srcdir, path)
end
info_xml = `svn info --xml "#{path}"` info_xml = `svn info --xml "#{path}"`
_, last, _, changed, _ = info_xml.split(/revision="(\d+)"/) _, last, _, changed, _ = info_xml.split(/revision="(\d+)"/)
modified = info_xml[/<date>([^<>]*)/, 1] modified = info_xml[/<date>([^<>]*)/, 1]
@ -105,8 +108,8 @@ class VCS
class GIT < self class GIT < self
register(".git") register(".git")
def self.get_revisions(path) def self.get_revisions(path, srcdir = nil)
logcmd = %Q[git log -n1 --date=iso --grep="^ *git-svn-id: .*@[0-9][0-9]* "] logcmd = %Q[git -C "#{srcdir || '.'}" log -n1 --date=iso --grep="^ *git-svn-id: .*@[0-9][0-9]* "]
idpat = /git-svn-id: .*?@(\d+) \S+\Z/ idpat = /git-svn-id: .*?@(\d+) \S+\Z/
last = `#{logcmd}`[idpat, 1] last = `#{logcmd}`[idpat, 1]
if path if path