aboutsummaryrefslogtreecommitdiffstats
path: root/tool/vcs.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-13 23:55:33 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-12-13 23:55:33 +0000
commitdb4e9d5eb331cfbb5c9d9a1abbb87955ae63a99b (patch)
tree2f7c3bb4f9dd8f191f1af084059920d4346ddef6 /tool/vcs.rb
parent7c8164395336a0bb270bb611ca77c2f68e97e50d (diff)
downloadruby-db4e9d5eb331cfbb5c9d9a1abbb87955ae63a99b.tar.gz
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
Diffstat (limited to 'tool/vcs.rb')
-rw-r--r--tool/vcs.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/tool/vcs.rb b/tool/vcs.rb
index 49c70648fd..590eaad479 100644
--- a/tool/vcs.rb
+++ b/tool/vcs.rb
@@ -43,20 +43,20 @@ class VCS
# +path+ was modified.
def get_revisions(path)
path = relative_to(path)
- last, changed, modified, *rest = Dir.chdir(@srcdir) {
+ last, changed, modified, *rest = (
begin
if NullDevice
save_stderr = STDERR.dup
STDERR.reopen NullDevice, 'w'
end
- self.class.get_revisions(path)
+ self.class.get_revisions(path, @srcdir)
ensure
if save_stderr
STDERR.reopen save_stderr
save_stderr.close
end
end
- }
+ )
last or raise VCS::NotFoundError, "last revision not found"
changed or raise VCS::NotFoundError, "changed revision not found"
if modified
@@ -94,7 +94,10 @@ class VCS
class SVN < self
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}"`
_, last, _, changed, _ = info_xml.split(/revision="(\d+)"/)
modified = info_xml[/<date>([^<>]*)/, 1]
@@ -105,8 +108,8 @@ class VCS
class GIT < self
register(".git")
- def self.get_revisions(path)
- logcmd = %Q[git log -n1 --date=iso --grep="^ *git-svn-id: .*@[0-9][0-9]* "]
+ def self.get_revisions(path, srcdir = nil)
+ logcmd = %Q[git -C "#{srcdir || '.'}" log -n1 --date=iso --grep="^ *git-svn-id: .*@[0-9][0-9]* "]
idpat = /git-svn-id: .*?@(\d+) \S+\Z/
last = `#{logcmd}`[idpat, 1]
if path