summaryrefslogtreecommitdiff
path: root/tool/vcs.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2019-04-28 02:00:39 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-04-28 09:56:56 +0900
commit7790b610b8c11ae987e0f9a936418a7a34a8af0b (patch)
tree4e878de99f70f05aead644ddac857b6d154aa451 /tool/vcs.rb
parent2c283655a650a7e97aaf36992d1d60c314403b7a (diff)
Shorten git revision name without "r" prefix in snapshot
Diffstat (limited to 'tool/vcs.rb')
-rw-r--r--tool/vcs.rb21
1 files changed, 19 insertions, 2 deletions
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
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