ruby-changes:55569
From: Nobuyoshi <ko1@a...>
Date: Sun, 28 Apr 2019 10:00:18 +0900 (JST)
Subject: [ruby-changes:55569] Nobuyoshi Nakada:7790b610b8 (trunk): Shorten git revision name without "r" prefix in snapshot
https://git.ruby-lang.org/ruby.git/commit/?id=7790b610b8 From 7790b610b8c11ae987e0f9a936418a7a34a8af0b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sun, 28 Apr 2019 02:00:39 +0900 Subject: Shorten git revision name without "r" prefix in snapshot diff --git a/tool/make-snapshot b/tool/make-snapshot index 4ba1da5..4cd47cf 100755 --- a/tool/make-snapshot +++ b/tool/make-snapshot @@ -301,14 +301,14 @@ def package(vcs, rev, destdir, tmp = nil) https://github.com/ruby/ruby/blob/trunk/tool/make-snapshot#L301 unless tag.empty? versionhdr ||= IO.read("#{v}/version.h") patchlevel = versionhdr[/^\#define\s+RUBY_PATCHLEVEL\s+(\d+)/, 1] - tag = (patchlevel ? "p#{patchlevel}" : "r#{revision}") + tag = (patchlevel ? "p#{patchlevel}" : vcs.revision_name(revision)) end elsif prerelease versionhdr ||= IO.read("#{v}/version.h") versionhdr.sub!(/^\#define\s+RUBY_PATCHLEVEL_STR\s+"\K.+?(?=")/, tag) IO.write("#{v}/version.h", versionhdr) else - tag ||= "r#{revision}" + tag ||= vcs.revision_name(revision) end unless v == $exported if $archname diff --git a/tool/vcs.rb b/tool/vcs.rb index 6078f1a..cf8a710 100644 --- a/tool/vcs.rb +++ b/tool/vcs.rb @@ -220,10 +220,18 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L220 def after_export(dir) end + def revision_name(rev) + self.class.revision_name(rev) + end + class SVN < self register(".svn") COMMAND = ENV['SVN'] || 'svn' + def self.revision_name(rev) + "r#{rev}" + end + def self.get_revisions(path, srcdir = nil) if srcdir and local_path?(path) path = File.join(srcdir, path) @@ -374,20 +382,25 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L382 def self.get_revisions(path, srcdir = nil) gitcmd = [COMMAND] - last = cmd_read_at(srcdir, [[*gitcmd, 'rev-parse', 'HEAD']]).rstrip + last = cmd_read_at(srcdir, [[*gitcmd, 'rev-parse', '--short', 'HEAD']]).rstrip if path log = cmd_read_at(srcdir, [[*gitcmd, 'log', '-n1', '--date=iso', path]]) else log = cmd_read_at(srcdir, [[*gitcmd, 'log', '-n1', '--date=iso']]) end changed = log[/\Acommit (\h+)/, 1] + changed = changed[0, last.size] modified = log[/^Date:\s+(.*)/, 1] - branch = cmd_read_at(srcdir, [gitcmd + %W[symbolic-ref HEAD]])[%r'\A(?:refs/heads/)?(.+)', 1] + branch = cmd_read_at(srcdir, [gitcmd + %W[symbolic-ref --short HEAD]]) title = cmd_read_at(srcdir, [gitcmd + %W[log --format=%s -n1 FETCH_HEAD..HEAD]]) title = nil if title.empty? [last, changed, modified, branch, title] end + def self.revision_name(rev) + rev + end + def initialize(*) super if srcdir = @srcdir and self.class.local_path?(srcdir) @@ -488,6 +501,10 @@ class VCS https://github.com/ruby/ruby/blob/trunk/tool/vcs.rb#L501 end class GITSVN < GIT + def self.revision_name(rev) + SVN.short_revision(rev) + end + def format_changelog(r, path) open(path, 'w') do |w| sep = "-"*72 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/