Support revision in git-svn log
This commit is contained in:
parent
1191049436
commit
55f496c89b
@ -252,12 +252,16 @@ class VCS
|
|||||||
def after_export(dir)
|
def after_export(dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def revision_handler(rev)
|
||||||
|
self.class
|
||||||
|
end
|
||||||
|
|
||||||
def revision_name(rev)
|
def revision_name(rev)
|
||||||
self.class.revision_name(rev)
|
revision_handler(rev).revision_name(rev)
|
||||||
end
|
end
|
||||||
|
|
||||||
def short_revision(rev)
|
def short_revision(rev)
|
||||||
self.class.short_revision(rev)
|
revision_handler(rev).short_revision(rev)
|
||||||
end
|
end
|
||||||
|
|
||||||
class SVN < self
|
class SVN < self
|
||||||
@ -446,12 +450,26 @@ class VCS
|
|||||||
cmd_read_at(@srcdir, cmds)
|
cmd_read_at(@srcdir, cmds)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def svn_revision(log)
|
||||||
|
if /^ *git-svn-id: .*@(\d+) .*\n+\z/ =~ log
|
||||||
|
$1.to_i
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def _get_revisions(path, srcdir = nil)
|
def _get_revisions(path, srcdir = nil)
|
||||||
gitcmd = [COMMAND]
|
gitcmd = [COMMAND]
|
||||||
last = cmd_read_at(srcdir, [[*gitcmd, 'rev-parse', 'HEAD']]).rstrip
|
last = cmd_read_at(srcdir, [[*gitcmd, 'rev-parse', 'HEAD']]).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]
|
||||||
|
if rev = svn_revision(log)
|
||||||
|
if changed == last
|
||||||
|
last = rev
|
||||||
|
else
|
||||||
|
last = svn_revision(cmd_read_at(srcdir, [[*gitcmd, 'log', '-n1', '--format=%B', last]]))
|
||||||
|
end
|
||||||
|
changed = rev
|
||||||
|
end
|
||||||
branch = cmd_read_at(srcdir, [gitcmd + %W[symbolic-ref --short HEAD]])
|
branch = cmd_read_at(srcdir, [gitcmd + %W[symbolic-ref --short HEAD]])
|
||||||
if branch.empty?
|
if branch.empty?
|
||||||
branch_list = cmd_read_at(srcdir, [gitcmd + %W[branch --list --contains HEAD]]).lines.to_a
|
branch_list = cmd_read_at(srcdir, [gitcmd + %W[branch --list --contains HEAD]]).lines.to_a
|
||||||
@ -488,6 +506,15 @@ class VCS
|
|||||||
rev[0, 10]
|
rev[0, 10]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def revision_handler(rev)
|
||||||
|
case rev
|
||||||
|
when Integer
|
||||||
|
SVN
|
||||||
|
else
|
||||||
|
super
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def without_gitconfig
|
def without_gitconfig
|
||||||
home = ENV.delete('HOME')
|
home = ENV.delete('HOME')
|
||||||
yield
|
yield
|
||||||
@ -627,10 +654,6 @@ class VCS
|
|||||||
SVN.revision_name(rev)
|
SVN.revision_name(rev)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.short_revision(rev)
|
|
||||||
SVN.short_revision(rev)
|
|
||||||
end
|
|
||||||
|
|
||||||
def format_changelog(r, path)
|
def format_changelog(r, path)
|
||||||
open(path, 'w') do |w|
|
open(path, 'w') do |w|
|
||||||
sep = "-"*72
|
sep = "-"*72
|
||||||
|
Loading…
x
Reference in New Issue
Block a user