Make RUBY_REVISION full length

This commit is contained in:
Nobuyoshi Nakada 2019-05-22 23:18:37 +09:00
parent d819d97cf0
commit a205e24747
No known key found for this signature in database
GPG Key ID: 4BC7D6DF58D8DF60
3 changed files with 22 additions and 5 deletions

View File

@ -45,6 +45,7 @@ parser = OptionParser.new {|opts|
}
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}"
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

View File

@ -224,6 +224,10 @@ class VCS
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
"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
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
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
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

View File

@ -33,7 +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_revision[] = RUBY_FULL_REVISION;
const char ruby_release_date[] = RUBY_RELEASE_DATE;
const char ruby_platform[] = RUBY_PLATFORM;
const int ruby_patchlevel = RUBY_PATCHLEVEL;