mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Support git tags
This commit is contained in:
parent
04c3e34456
commit
ff7c95dfd9
1 changed files with 8 additions and 4 deletions
|
@ -457,8 +457,9 @@ class VCS
|
||||||
end
|
end
|
||||||
|
|
||||||
def _get_revisions(path, srcdir = nil)
|
def _get_revisions(path, srcdir = nil)
|
||||||
|
ref = Branch === path ? path.to_str : 'HEAD'
|
||||||
gitcmd = [COMMAND]
|
gitcmd = [COMMAND]
|
||||||
last = cmd_read_at(srcdir, [[*gitcmd, 'rev-parse', 'HEAD']]).rstrip
|
last = cmd_read_at(srcdir, [[*gitcmd, 'rev-parse', ref]]).rstrip
|
||||||
log = cmd_read_at(srcdir, [[*gitcmd, 'log', '-n1', '--date=iso', '--pretty=fuller', *path]])
|
log = cmd_read_at(srcdir, [[*gitcmd, 'log', '-n1', '--date=iso', '--pretty=fuller', *path]])
|
||||||
changed = log[/\Acommit (\h+)/, 1]
|
changed = log[/\Acommit (\h+)/, 1]
|
||||||
modified = log[/^CommitDate:\s+(.*)/, 1]
|
modified = log[/^CommitDate:\s+(.*)/, 1]
|
||||||
|
@ -470,9 +471,12 @@ class VCS
|
||||||
end
|
end
|
||||||
changed = rev
|
changed = rev
|
||||||
end
|
end
|
||||||
branch = cmd_read_at(srcdir, [gitcmd + %W[symbolic-ref --short HEAD]])
|
branch = cmd_read_at(srcdir, [gitcmd + %W[symbolic-ref --short #{ref}]])
|
||||||
if branch.empty?
|
if branch.empty?
|
||||||
branch_list = cmd_read_at(srcdir, [gitcmd + %W[branch --list --contains HEAD]]).lines.to_a
|
branch = cmd_read_at(srcdir, [gitcmd + %W[tag --list #{ref}]]).strip
|
||||||
|
end
|
||||||
|
if branch.empty?
|
||||||
|
branch_list = cmd_read_at(srcdir, [gitcmd + %W[branch --list --contains #{ref}]]).lines.to_a
|
||||||
branch, = branch_list.grep(/\A\*/)
|
branch, = branch_list.grep(/\A\*/)
|
||||||
case branch
|
case branch
|
||||||
when /\A\* *\(\S+ detached at (.*)\)\Z/
|
when /\A\* *\(\S+ detached at (.*)\)\Z/
|
||||||
|
@ -493,7 +497,7 @@ class VCS
|
||||||
branch = ":detached:" if branch.empty?
|
branch = ":detached:" if branch.empty?
|
||||||
upstream = cmd_read_at(srcdir, [gitcmd + %W[branch --list --format=%(upstream:short) #{branch}]])
|
upstream = cmd_read_at(srcdir, [gitcmd + %W[branch --list --format=%(upstream:short) #{branch}]])
|
||||||
upstream.chomp!
|
upstream.chomp!
|
||||||
title = cmd_read_at(srcdir, [gitcmd + %W[log --format=%s -n1 #{upstream}..HEAD]])
|
title = cmd_read_at(srcdir, [gitcmd + %W[log --format=%s -n1 #{upstream}..#{ref}]])
|
||||||
title = nil if title.empty?
|
title = nil if title.empty?
|
||||||
[last, changed, modified, branch, title]
|
[last, changed, modified, branch, title]
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue