diff options
author | Takashi Kokubun <[email protected]> | 2019-04-22 21:23:37 +0900 |
---|---|---|
committer | Takashi Kokubun <[email protected]> | 2019-04-22 21:27:34 +0900 |
commit | 5da52d1210625fb00acd573b3f32281b4bde1730 (patch) | |
tree | b21d24b02dfc1da995bc280142e2aaffcedf30ba | |
parent | dd0b516399f1e009667a99e815bf86c6a1245ee5 (diff) |
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.
-rw-r--r-- | NEWS | 7 | ||||
-rwxr-xr-x | tool/file2lastrev.rb | 2 | ||||
-rw-r--r-- | tool/vcs.rb | 21 | ||||
-rw-r--r-- | version.c | 4 | ||||
-rw-r--r-- | version.h | 10 |
5 files changed, 19 insertions, 25 deletions
@@ -134,4 +134,11 @@ GC:: === Miscellaneous changes * Require compilers to support C99 [Misc #15347] + * 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. diff --git a/tool/file2lastrev.rb b/tool/file2lastrev.rb index 8d68da9f88..0ee22da712 100755 --- a/tool/file2lastrev.rb +++ b/tool/file2lastrev.rb @@ -54,7 +54,7 @@ parser.parse! rescue abort "#{File.basename(Program)}: #{$!}\n#{parser}" when :revision_h Proc.new {|last, changed, modified, branch, title| [ - "#define RUBY_REVISION #{changed || 0}", + "#define RUBY_REVISION \"#{changed[0...10]}\"", if branch e = '..' limit = 16 diff --git a/tool/vcs.rb b/tool/vcs.rb index b97334ecfb..d63336ae60 100644 --- a/tool/vcs.rb +++ b/tool/vcs.rb @@ -374,27 +374,16 @@ class VCS def self.get_revisions(path, srcdir = nil) gitcmd = [COMMAND] - desc = cmd_read_at(srcdir, [gitcmd + %w[describe --tags --match REV_*]]) - 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] + last = cmd_read_at(srcdir, [[*gitcmd, 'rev-parse', 'HEAD']]).rstrip if path - cmd = logcmd - cmd += [path] unless path == '.' - log = cmd_read_at(srcdir, [cmd]) - changed = log[idpat, 1] || last + log = cmd_read_at(srcdir, [[*gitcmd, 'log', '-n1', '--date=iso', path]]) else - changed = last + log = cmd_read_at(srcdir, [[*gitcmd, 'log', '-n1', '--date=iso']]) end + changed = log[/\Acommit (\h+)/, 1] modified = log[/^Date:\s+(.*)/, 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? [last, changed, modified, branch, title] end @@ -33,6 +33,7 @@ const int ruby_api_version[] = { STRINGIZE(RUBY_VERSION_MINOR) "." \ STRINGIZE(RUBY_VERSION_TEENY) "" const char ruby_version[] = RUBY_VERSION; +const char ruby_revision[] = RUBY_REVISION; const char ruby_release_date[] = RUBY_RELEASE_DATE; const char ruby_platform[] = RUBY_PLATFORM; const int ruby_patchlevel = RUBY_PATCHLEVEL; @@ -46,7 +47,6 @@ void Init_version(void) { enum {ruby_patchlevel = RUBY_PATCHLEVEL}; - enum {ruby_revision = RUBY_REVISION}; VALUE version; VALUE ruby_engine_name; /* @@ -69,7 +69,7 @@ Init_version(void) /* * 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 */ @@ -45,20 +45,18 @@ #ifndef RUBY_REVISION # include "revision.h" #endif -#ifndef RUBY_REVISION -# define RUBY_REVISION 0 -#endif -#if RUBY_REVISION +#ifdef RUBY_REVISION # if RUBY_PATCHLEVEL == -1 # ifndef RUBY_BRANCH_NAME # define RUBY_BRANCH_NAME "trunk" # endif -# define RUBY_REVISION_STR " "RUBY_BRANCH_NAME" "STRINGIZE(RUBY_REVISION) +# define RUBY_REVISION_STR " "RUBY_BRANCH_NAME" "RUBY_REVISION # else -# define RUBY_REVISION_STR " revision "STRINGIZE(RUBY_REVISION) +# define RUBY_REVISION_STR " revision "RUBY_REVISION # endif #else +# define RUBY_REVISION "HEAD" # define RUBY_REVISION_STR "" #endif |