mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Shorten git revision name without "r" prefix in snapshot
This commit is contained in:
parent
2c283655a6
commit
7790b610b8
2 changed files with 21 additions and 4 deletions
|
@ -301,14 +301,14 @@ def package(vcs, rev, destdir, tmp = nil)
|
|||
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
|
||||
|
|
21
tool/vcs.rb
21
tool/vcs.rb
|
@ -220,10 +220,18 @@ class VCS
|
|||
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
|
|||
|
||||
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
|
|||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue