summaryrefslogtreecommitdiff
path: root/tool/vcs.rb
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2019-04-22 21:23:37 +0900
committerTakashi Kokubun <takashikkbn@gmail.com>2019-04-22 21:27:34 +0900
commit5da52d1210625fb00acd573b3f32281b4bde1730 (patch)
treeb21d24b02dfc1da995bc280142e2aaffcedf30ba /tool/vcs.rb
parentdd0b516399f1e009667a99e815bf86c6a1245ee5 (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.
Diffstat (limited to 'tool/vcs.rb')
-rw-r--r--tool/vcs.rb21
1 files changed, 5 insertions, 16 deletions
diff --git a/tool/vcs.rb b/tool/vcs.rb
index b97334e..d63336a 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