summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
Diffstat (limited to 'tool')
-rwxr-xr-xtool/file2lastrev.rb3
-rwxr-xr-xtool/rbinstall.rb18
-rw-r--r--tool/vcs.rb20
3 files changed, 34 insertions, 7 deletions
diff --git a/tool/file2lastrev.rb b/tool/file2lastrev.rb
index 8ead4961e7..56e1b9f512 100755
--- a/tool/file2lastrev.rb
+++ b/tool/file2lastrev.rb
@@ -1,6 +1,9 @@
#!/usr/bin/env ruby
require 'optparse'
+
+# this file run with BASERUBY, which may be older than 1.9, so no
+# require_relative
require File.expand_path('../vcs', __FILE__)
Program = $0
diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb
index 13bf274d88..1f2a6aebc0 100755
--- a/tool/rbinstall.rb
+++ b/tool/rbinstall.rb
@@ -19,10 +19,17 @@ require 'optparse'
require 'optparse/shellwords'
require 'ostruct'
require 'rubygems'
+require_relative 'vcs'
STDOUT.sync = true
File.umask(0)
+begin
+ $vcs = VCS.detect(File.expand_path('../..', __FILE__))
+rescue VCS::NotFoundError
+ $vcs = nil
+end
+
def parse_args(argv = ARGV)
$mantype = 'doc'
$destdir = nil
@@ -560,13 +567,20 @@ module Gem
super
yield(self) if defined?(yield)
self.executables ||= []
- self.date ||= RUBY_RELEASE_DATE
end
def self.load(path)
src = File.open(path, "rb") {|f| f.read}
src.sub!(/\A#.*/, '')
- eval(src, nil, path)
+ spec = eval(src, nil, path)
+ spec.date ||= last_date(path) || RUBY_RELEASE_DATE
+ spec
+ end
+
+ def self.last_date(path)
+ return unless $vcs
+ return unless time = $vcs.get_revisions(path)[2]
+ time.strftime("%Y-%m-%d")
end
def to_ruby
diff --git a/tool/vcs.rb b/tool/vcs.rb
index e7cb610767..6e86cfb07e 100644
--- a/tool/vcs.rb
+++ b/tool/vcs.rb
@@ -1,5 +1,7 @@
# vcs
+require 'time'
+
ENV.delete('PWD')
unless File.respond_to? :realpath
@@ -40,10 +42,11 @@ class VCS
# +path+ was modified.
def get_revisions(path)
path = relative_to(path)
- last, changed, *rest = Dir.chdir(@srcdir) {self.class.get_revisions(path)}
+ last, changed, modified, *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, *rest
+ modified &&= Time.parse(modified)
+ return last, changed, modified, *rest
end
def relative_to(path)
@@ -84,7 +87,8 @@ class VCS
end
end
_, last, _, changed, _ = info_xml.split(/revision="(\d+)"/)
- [last, changed]
+ modified = info_xml[/<date>([^<>]*)/, 1]
+ [last, changed, modified]
end
end
@@ -95,8 +99,14 @@ class VCS
logcmd = %Q[git log -n1 --grep="^ *git-svn-id: .*@[0-9][0-9]* "]
idpat = /git-svn-id: .*?@(\d+) \S+\Z/
last = `#{logcmd}`[idpat, 1]
- changed = path ? `#{logcmd} "#{path}"`[idpat, 1] : last
- [last, changed]
+ if path
+ log = `#{logcmd} "#{path}"`
+ changed = log[idpat, 1]
+ modified = `git log --format=%ai -- #{path}`
+ else
+ changed = last
+ end
+ [last, changed, modified]
end
end
end