ruby-changes:31538
From: nobu <ko1@a...>
Date: Sat, 9 Nov 2013 22:35:44 +0900 (JST)
Subject: [ruby-changes:31538] nobu:r43617 (trunk): rbinstall.rb: spec date from VCS
nobu 2013-11-09 22:35:39 +0900 (Sat, 09 Nov 2013) New Revision: 43617 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43617 Log: rbinstall.rb: spec date from VCS * tool/rbinstall.rb (Gem::Specification.load): obtain spec date from VCS for the case using git, RUBY_RELEASE_DATE is the last resort. probably fixes [Bug #9085]. Modified files: trunk/ChangeLog trunk/tool/file2lastrev.rb trunk/tool/rbinstall.rb trunk/tool/vcs.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 43616) +++ ChangeLog (revision 43617) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Nov 9 22:35:35 2013 Nobuyoshi Nakada <nobu@r...> + + * tool/rbinstall.rb (Gem::Specification.load): obtain spec date from + VCS for the case using git, RUBY_RELEASE_DATE is the last resort. + probably fixes [Bug #9085]. + Sat Nov 9 20:56:12 2013 Narihiro Nakamura <authornari@g...> * ext/objspace/object_tracing.c: use declarations in internal.h. Index: tool/rbinstall.rb =================================================================== --- tool/rbinstall.rb (revision 43616) +++ tool/rbinstall.rb (revision 43617) @@ -19,10 +19,17 @@ require 'optparse' https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L19 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 https://github.com/ruby/ruby/blob/trunk/tool/rbinstall.rb#L567 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 Index: tool/vcs.rb =================================================================== --- tool/vcs.rb (revision 43616) +++ tool/vcs.rb (revision 43617) @@ -1,5 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L1 # vcs +require 'time' + ENV.delete('PWD') unless File.respond_to? :realpath @@ -40,10 +42,11 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L42 # +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 https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L87 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 https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L99 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 Index: tool/file2lastrev.rb =================================================================== --- tool/file2lastrev.rb (revision 43616) +++ tool/file2lastrev.rb (revision 43617) @@ -1,6 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/tool/file2lastrev.rb#L1 #!/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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/