mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Separate format_changelog
VCS::GITSVN#format_changelog generates previous format, similar to svn-log, and VCS::GIT#format_changelog stores just git-log as-is for now.
This commit is contained in:
parent
7875c42f64
commit
2a4625115a
1 changed files with 34 additions and 24 deletions
58
tool/vcs.rb
58
tool/vcs.rb
|
@ -454,37 +454,23 @@ class VCS
|
||||||
def export_changelog(url, from, to, path)
|
def export_changelog(url, from, to, path)
|
||||||
range = [from, to].map do |rev|
|
range = [from, to].map do |rev|
|
||||||
rev or next
|
rev or next
|
||||||
rev = cmd_read({'LANG' => 'C', 'LC_ALL' => 'C'},
|
if Integer === rev
|
||||||
%W"#{COMMAND} log -n1 --format=format:%H" <<
|
rev = cmd_read({'LANG' => 'C', 'LC_ALL' => 'C'},
|
||||||
"--grep=^ *git-svn-id: .*@#{rev} ")
|
%W"#{COMMAND} log -n1 --format=format:%H" <<
|
||||||
|
"--grep=^ *git-svn-id: .*@#{rev} ")
|
||||||
|
end
|
||||||
rev unless rev.empty?
|
rev unless rev.empty?
|
||||||
end.join('^..')
|
end.join('^..')
|
||||||
cmd_pipe({'TZ' => 'JST-9', 'LANG' => 'C', 'LC_ALL' => 'C'},
|
cmd_pipe({'TZ' => 'JST-9', 'LANG' => 'C', 'LC_ALL' => 'C'},
|
||||||
%W"#{COMMAND} log --format=medium --no-notes --date=iso-local --topo-order #{range}", "rb") do |r|
|
%W"#{COMMAND} log --format=medium --no-notes --date=iso-local --topo-order #{range}", "rb") do |r|
|
||||||
open(path, 'w') do |w|
|
format_changelog(r, path)
|
||||||
sep = "-"*72
|
|
||||||
w.puts sep
|
|
||||||
while s = r.gets('')
|
|
||||||
author = s[/^Author:\s*(\S+)/, 1]
|
|
||||||
time = s[/^Date:\s*(.+)/, 1]
|
|
||||||
s = r.gets('')
|
|
||||||
s.gsub!(/^ {4}/, '')
|
|
||||||
s.sub!(/^git-svn-id: .*@(\d+) .*\n+\z/, '')
|
|
||||||
rev = $1
|
|
||||||
s.gsub!(/^ {8}/, '') if /^(?! {8}|$)/ !~ s
|
|
||||||
s.sub!(/\n\n\z/, "\n")
|
|
||||||
if /\A(\d+)-(\d+)-(\d+)/ =~ time
|
|
||||||
date = Time.new($1.to_i, $2.to_i, $3.to_i).strftime("%a, %d %b %Y")
|
|
||||||
end
|
|
||||||
lines = s.count("\n")
|
|
||||||
lines = "#{lines} line#{lines == 1 ? '' : 's'}"
|
|
||||||
w.puts "r#{rev} | #{author} | #{time} (#{date}) | #{lines}\n\n"
|
|
||||||
w.puts s, sep
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def format_changelog(r, path)
|
||||||
|
IO.copy_stream(r, path)
|
||||||
|
end
|
||||||
|
|
||||||
def commit(opts = {})
|
def commit(opts = {})
|
||||||
dryrun = opts.fetch(:dryrun) {$DEBUG} if opts
|
dryrun = opts.fetch(:dryrun) {$DEBUG} if opts
|
||||||
args = [COMMAND]
|
args = [COMMAND]
|
||||||
|
@ -496,6 +482,30 @@ class VCS
|
||||||
end
|
end
|
||||||
|
|
||||||
class GITSVN < GIT
|
class GITSVN < GIT
|
||||||
|
def format_changelog(r, path)
|
||||||
|
open(path, 'w') do |w|
|
||||||
|
sep = "-"*72
|
||||||
|
w.puts sep
|
||||||
|
while s = r.gets('')
|
||||||
|
author = s[/^Author:\s*(\S+)/, 1]
|
||||||
|
time = s[/^Date:\s*(.+)/, 1]
|
||||||
|
s = r.gets('')
|
||||||
|
s.gsub!(/^ {4}/, '')
|
||||||
|
s.sub!(/^git-svn-id: .*@(\d+) .*\n+\z/, '')
|
||||||
|
rev = $1
|
||||||
|
s.gsub!(/^ {8}/, '') if /^(?! {8}|$)/ !~ s
|
||||||
|
s.sub!(/\n\n\z/, "\n")
|
||||||
|
if /\A(\d+)-(\d+)-(\d+)/ =~ time
|
||||||
|
date = Time.new($1.to_i, $2.to_i, $3.to_i).strftime("%a, %d %b %Y")
|
||||||
|
end
|
||||||
|
lines = s.count("\n")
|
||||||
|
lines = "#{lines} line#{lines == 1 ? '' : 's'}"
|
||||||
|
w.puts "r#{rev} | #{author} | #{time} (#{date}) | #{lines}\n\n"
|
||||||
|
w.puts s, sep
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def last_changed_revision
|
def last_changed_revision
|
||||||
rev = cmd_read(%W"#{COMMAND} svn info"+[STDERR=>[:child, :out]])[/^Last Changed Rev: (\d+)/, 1]
|
rev = cmd_read(%W"#{COMMAND} svn info"+[STDERR=>[:child, :out]])[/^Last Changed Rev: (\d+)/, 1]
|
||||||
com = cmd_read(%W"#{COMMAND} svn find-rev r#{rev}").chomp
|
com = cmd_read(%W"#{COMMAND} svn find-rev r#{rev}").chomp
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue