Migrate RUBY_VERSION/RUBY_DESCRIPTION to Git

from Subversion.

This behavior is tentative and not discussed well. The point of
discussion will be just the length of commit hash, and I thought we
should include this kind of change in 2.7.0-preview1 release even before
the length is fixed yet.

Let's discuss that afterwards and fix it later as needed. Naruse
suggested that length=10 is very unlikely to cause conflict, and thus
it's used by email notification and rubyci now. This behavior is in
favor of that for now.
This commit is contained in:
Takashi Kokubun 2019-04-22 21:23:37 +09:00
Родитель dd0b516399
Коммит 5da52d1210
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 6FFC433B12EE23DD
5 изменённых файлов: 19 добавлений и 25 удалений

7
NEWS
Просмотреть файл

@ -134,4 +134,11 @@ GC::
=== Miscellaneous changes === Miscellaneous changes
* Require compilers to support C99 [Misc #15347] * Require compilers to support C99 [Misc #15347]
* Details of our dialect: https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/C99 * Details of our dialect: https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/C99
* Upstream repository is changed from Subversion to Git.
* RUBY_REVISION class is changed from Integer to String.
* RUBY_DESCRIPTION includes Git revision instead of Subversion's one.

Просмотреть файл

@ -54,7 +54,7 @@ parser.parse! rescue abort "#{File.basename(Program)}: #{$!}\n#{parser}"
when :revision_h when :revision_h
Proc.new {|last, changed, modified, branch, title| Proc.new {|last, changed, modified, branch, title|
[ [
"#define RUBY_REVISION #{changed || 0}", "#define RUBY_REVISION \"#{changed[0...10]}\"",
if branch if branch
e = '..' e = '..'
limit = 16 limit = 16

Просмотреть файл

@ -374,27 +374,16 @@ class VCS
def self.get_revisions(path, srcdir = nil) def self.get_revisions(path, srcdir = nil)
gitcmd = [COMMAND] gitcmd = [COMMAND]
desc = cmd_read_at(srcdir, [gitcmd + %w[describe --tags --match REV_*]]) last = cmd_read_at(srcdir, [[*gitcmd, 'rev-parse', 'HEAD']]).rstrip
if /\AREV_(\d+)(?:-(\d+)-g\h+)?\Z/ =~ desc
last = ($1.to_i + $2.to_i).to_s
end
logcmd = gitcmd + %W[log -n1 --date=iso]
logcmd << "--grep=^ *git-svn-id: .*@[0-9][0-9]*" unless last
idpat = /git-svn-id: .*?@(\d+) \S+\Z/
log = cmd_read_at(srcdir, [logcmd])
commit = log[/\Acommit (\w+)/, 1]
last ||= log[idpat, 1]
if path if path
cmd = logcmd log = cmd_read_at(srcdir, [[*gitcmd, 'log', '-n1', '--date=iso', path]])
cmd += [path] unless path == '.'
log = cmd_read_at(srcdir, [cmd])
changed = log[idpat, 1] || last
else else
changed = last log = cmd_read_at(srcdir, [[*gitcmd, 'log', '-n1', '--date=iso']])
end end
changed = log[/\Acommit (\h+)/, 1]
modified = log[/^Date:\s+(.*)/, 1] 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 HEAD]])[%r'\A(?:refs/heads/)?(.+)', 1]
title = cmd_read_at(srcdir, [gitcmd + %W[log --format=%s -n1 #{commit}..HEAD]]) title = cmd_read_at(srcdir, [gitcmd + %W[log --format=%s -n1 HEAD]])
title = nil if title.empty? title = nil if title.empty?
[last, changed, modified, branch, title] [last, changed, modified, branch, title]
end end

Просмотреть файл

@ -33,6 +33,7 @@ const int ruby_api_version[] = {
STRINGIZE(RUBY_VERSION_MINOR) "." \ STRINGIZE(RUBY_VERSION_MINOR) "." \
STRINGIZE(RUBY_VERSION_TEENY) "" STRINGIZE(RUBY_VERSION_TEENY) ""
const char ruby_version[] = RUBY_VERSION; const char ruby_version[] = RUBY_VERSION;
const char ruby_revision[] = RUBY_REVISION;
const char ruby_release_date[] = RUBY_RELEASE_DATE; const char ruby_release_date[] = RUBY_RELEASE_DATE;
const char ruby_platform[] = RUBY_PLATFORM; const char ruby_platform[] = RUBY_PLATFORM;
const int ruby_patchlevel = RUBY_PATCHLEVEL; const int ruby_patchlevel = RUBY_PATCHLEVEL;
@ -46,7 +47,6 @@ void
Init_version(void) Init_version(void)
{ {
enum {ruby_patchlevel = RUBY_PATCHLEVEL}; enum {ruby_patchlevel = RUBY_PATCHLEVEL};
enum {ruby_revision = RUBY_REVISION};
VALUE version; VALUE version;
VALUE ruby_engine_name; VALUE ruby_engine_name;
/* /*
@ -69,7 +69,7 @@ Init_version(void)
/* /*
* The SVN revision for this ruby. * The SVN revision for this ruby.
*/ */
rb_define_global_const("RUBY_REVISION", MKINT(revision)); rb_define_global_const("RUBY_REVISION", MKSTR(revision));
/* /*
* The copyright string for ruby * The copyright string for ruby
*/ */

Просмотреть файл

@ -45,20 +45,18 @@
#ifndef RUBY_REVISION #ifndef RUBY_REVISION
# include "revision.h" # include "revision.h"
#endif #endif
#ifndef RUBY_REVISION
# define RUBY_REVISION 0
#endif
#if RUBY_REVISION #ifdef RUBY_REVISION
# if RUBY_PATCHLEVEL == -1 # if RUBY_PATCHLEVEL == -1
# ifndef RUBY_BRANCH_NAME # ifndef RUBY_BRANCH_NAME
# define RUBY_BRANCH_NAME "trunk" # define RUBY_BRANCH_NAME "trunk"
# endif # endif
# define RUBY_REVISION_STR " "RUBY_BRANCH_NAME" "STRINGIZE(RUBY_REVISION) # define RUBY_REVISION_STR " "RUBY_BRANCH_NAME" "RUBY_REVISION
# else # else
# define RUBY_REVISION_STR " revision "STRINGIZE(RUBY_REVISION) # define RUBY_REVISION_STR " revision "RUBY_REVISION
# endif # endif
#else #else
# define RUBY_REVISION "HEAD"
# define RUBY_REVISION_STR "" # define RUBY_REVISION_STR ""
#endif #endif