1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/rdoc] Sort by CommitDate if available

https://github.com/ruby/rdoc/commit/455715e930
This commit is contained in:
Nobuyoshi Nakada 2021-01-23 00:20:53 +09:00
parent fa048a0f85
commit d5d1c41728
2 changed files with 48 additions and 3 deletions

View file

@ -217,9 +217,14 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
def parse_entries
entries = []
@content.scan(/^commit\s+(\h{20})\h*\n *Author: *(.+)\n *Date: *(.+)\n\n((?: {4}.*\n+)*)/) do
entry_name, author, date, entry_body = $1, $2, $3, $4.gsub(/^ {4}/, '')
if /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+) *([-+]\d\d)(\d\d)/ =~ date
@content.scan(/^commit\s+(\h{20})\h*\n((?:.+\n)*)\n((?: {4}.*\n+)*)/) do
entry_name, header, entry_body = $1, $2, $3.gsub(/^ {4}/, '')
# header = header.scan(/^ *(\S+?): +(.*)/).to_h
# date = header["CommitDate"] || header["Date"]
date = header[/^ *(?:Author)?Date: +(.*)/, 1]
author = header[/^ *Author: +(.*)/, 1]
if /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+) *([-+]\d\d)(\d\d)/ =~
(header[/^ *CommitDate: +(.*)/, 1] || date)
time = Time.new($1, $2, $3, $4, $5, $6, "#{$7}:#{$8}")
@time_cache[entry_name] = time
author.sub!(/\s*<(.*)>/, '')

View file

@ -398,6 +398,46 @@ ChangeLog
assert_equal expected, @top_level.comment
end
def test_scan_git_commit_date
parser = util_parser <<-ChangeLog
commit\ ee1e690a2df901adb279d7a63fbd92c64e0a5ae6
Author: Igor Zubkov <igor.zubkov@gmail.com>
AuthorDate: 2016-10-25 03:56:11 +0900
Commit: Nobuyoshi Nakada <nobu@ruby-lang.org>
CommitDate: 2021-01-07 13:40:42 +0900
We don't need "require 'uri'" after "require 'net/http'".
commit\ 4d0985a7bd8f591dff4b430e288bfd83af782e51
Author: git <svn-admin@ruby-lang.org>
AuthorDate: 2021-01-07 10:21:34 +0900
Commit: git <svn-admin@ruby-lang.org>
CommitDate: 2021-01-07 10:21:34 +0900
* 2021-01-07 [ci skip]
ChangeLog
parser.scan
expected = doc(
head(1, File.basename(@tempfile.path)),
blank_line,
head(2, "2021-01-07"),
blank_line,
log_entry(nil, 'ee1e690a2df901adb279',
'Igor Zubkov', 'igor.zubkov@gmail.com',
'2016-10-25 03:56:11 +0900',
[head(4, %[We don't need "require 'uri'" after "require 'net/http'".])]),
log_entry(nil, '4d0985a7bd8f591dff4b',
'git', 'svn-admin@ruby-lang.org',
'2021-01-07 10:21:34 +0900',
[list(:BULLET, item(nil, para("2021-01-07 [ci skip]")))]))
expected.file = @top_level
assert_equal expected, @top_level.comment
end
def util_parser content = ''
RDoc::Parser::ChangeLog.new \
@top_level, @tempfile.path, content, @options, @stats