ruby-changes:55778
From: Nobuyoshi <ko1@a...>
Date: Thu, 23 May 2019 00:15:54 +0900 (JST)
Subject: [ruby-changes:55778] Nobuyoshi Nakada: a205e24747 (trunk): Make RUBY_REVISION full length
https://git.ruby-lang.org/ruby.git/commit/?id=a205e24747 From a205e24747497391390ef7c004293a8a7934dd96 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Wed, 22 May 2019 23:18:37 +0900 Subject: Make RUBY_REVISION full length diff --git a/tool/file2lastrev.rb b/tool/file2lastrev.rb index 58ff354..24fbaeb 100755 --- a/tool/file2lastrev.rb +++ b/tool/file2lastrev.rb @@ -45,6 +45,7 @@ parser = OptionParser.new {|opts| https://github.com/ruby/ruby/blob/trunk/tool/file2lastrev.rb#L45 } parser.parse! rescue abort "#{File.basename(Program)}: #{$!}\n#{parser}" +vcs = nil @output = case @output when :changed, nil @@ -54,7 +55,8 @@ parser.parse! rescue abort "#{File.basename(Program)}: #{$!}\n#{parser}" https://github.com/ruby/ruby/blob/trunk/tool/file2lastrev.rb#L55 when :revision_h Proc.new {|last, changed, modified, branch, title| [ - "#define RUBY_REVISION #{last.dump}", + "#define RUBY_REVISION #{vcs.short_revision(last).dump}", + "#define RUBY_FULL_REVISION #{last.dump}", if branch e = '..' limit = 16 diff --git a/tool/vcs.rb b/tool/vcs.rb index f251c96..34bafa7 100644 --- a/tool/vcs.rb +++ b/tool/vcs.rb @@ -224,6 +224,10 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L224 self.class.revision_name(rev) end + def short_revision(rev) + self.class.short_revision(rev) + end + class SVN < self register(".svn") COMMAND = ENV['SVN'] || 'svn' @@ -232,6 +236,10 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L236 "r#{rev}" end + def self.short_revision(rev) + rev + end + def self.get_revisions(path, srcdir = nil) if srcdir and local_path?(path) path = File.join(srcdir, path) @@ -392,10 +400,9 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L400 def self.get_revisions(path, srcdir = nil) gitcmd = [COMMAND] - last = cmd_read_at(srcdir, [[*gitcmd, 'rev-parse', '--short=10', 'HEAD']]).rstrip + last = cmd_read_at(srcdir, [[*gitcmd, 'rev-parse', 'HEAD']]).rstrip log = cmd_read_at(srcdir, [[*gitcmd, 'log', '-n1', '--date=iso', *path]]) changed = log[/\Acommit (\h+)/, 1] - changed = changed[0, last.size] modified = log[/^Date:\s+(.*)/, 1] branch = cmd_read_at(srcdir, [gitcmd + %W[symbolic-ref --short HEAD]]) if branch.empty? @@ -413,7 +420,11 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L420 end def self.revision_name(rev) - rev + short_revision(rev) + end + + def self.short_revision(rev) + rev[0, 10] end def initialize(*) @@ -533,6 +544,10 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L544 SVN.revision_name(rev) end + def self.short_revision(rev) + SVN.short_revision(rev) + end + def format_changelog(r, path) open(path, 'w') do |w| sep = "-"*72 diff --git a/version.c b/version.c index 6b96dee..660f671 100644 --- a/version.c +++ b/version.c @@ -33,7 +33,7 @@ const int ruby_api_version[] = { https://github.com/ruby/ruby/blob/trunk/version.c#L33 STRINGIZE(RUBY_VERSION_MINOR) "." \ STRINGIZE(RUBY_VERSION_TEENY) "" const char ruby_version[] = RUBY_VERSION; -const char ruby_revision[] = RUBY_REVISION; +const char ruby_revision[] = RUBY_FULL_REVISION; const char ruby_release_date[] = RUBY_RELEASE_DATE; const char ruby_platform[] = RUBY_PLATFORM; const int ruby_patchlevel = RUBY_PATCHLEVEL; -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/