summaryrefslogtreecommitdiff
path: root/tool/file2lastrev.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-30 04:01:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-30 04:01:17 +0000
commit0c6fb8ccaaa5ad94003ac0883c709948bce1cd69 (patch)
tree0fb4729efbe99f66a7848c7b0c6fa047d17988c2 /tool/file2lastrev.rb
parent6c7edcb00aefd40539bc60b29dd9e3cf23d31984 (diff)
downloadruby-0c6fb8ccaaa5ad94003ac0883c709948bce1cd69.tar.gz
* tool/file2lastrev.rb (VCS#get_revisions): particular commands do
not depend on instance. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/file2lastrev.rb')
-rwxr-xr-xtool/file2lastrev.rb34
1 files changed, 15 insertions, 19 deletions
diff --git a/tool/file2lastrev.rb b/tool/file2lastrev.rb
index 057ea80fdd..7ab0fb7bc5 100755
--- a/tool/file2lastrev.rb
+++ b/tool/file2lastrev.rb
@@ -24,16 +24,17 @@ class VCS
def initialize(path)
@srcdir = path
+ super()
end
# return a pair of strings, the last revision and the last revision in which
# +path+ was modified.
def get_revisions(path)
path = relative_to(path)
- last, changed = Dir.chdir(@srcdir) {yield path}
+ last, changed, *rest = Dir.chdir(@srcdir) {self.class.get_revisions(path)}
last or raise "last revision not found"
changed or raise "changed revision not found"
- return last, changed
+ return last, changed, *rest
end
def relative_to(path)
@@ -43,37 +44,32 @@ class VCS
class SVN < self
register(".svn")
- def get_revisions(*)
- super do |path|
- info_xml = `svn info --xml "#{path}"`
- _, last, _, changed, _ = info_xml.split(/revision="(\d+)"/)
- [last, changed]
- end
+ def self.get_revisions(path)
+ info_xml = `svn info --xml "#{path}"`
+ _, last, _, changed, _ = info_xml.split(/revision="(\d+)"/)
+ [last, changed]
end
end
class GIT_SVN < self
register(".git/svn")
- def get_revisions(*)
- super do |path|
- info = `git svn info "#{path}"`
- [info[/^Revision: (\d+)/, 1], info[/^Last Changed Rev: (\d+)/, 1]]
- end
+ def self.get_revisions(path)
+ lastlog = `git log -n1`
+ info = `git svn info "#{path}"`
+ [info[/^Revision: (\d+)/, 1], info[/^Last Changed Rev: (\d+)/, 1]]
end
end
class GIT < self
register(".git")
- def get_revisions(*)
+ def self.get_revisions(path)
logcmd = %Q[git log -n1 --grep="^ *git-svn-id: .*@[0-9][0-9]* "]
idpat = /git-svn-id: .*?@(\d+) \S+\Z/
- super do |path|
- last = `#{logcmd}`[idpat, 1]
- changed = path ? `#{logcmd} "#{path}"`[idpat, 1] : last
- [last, changed]
- end
+ last = `#{logcmd}`[idpat, 1]
+ changed = path ? `#{logcmd} "#{path}"`[idpat, 1] : last
+ [last, changed]
end
end
end