[ruby/rdoc] Support other date formats in git-log

https://github.com/ruby/rdoc/commit/ad8cf37d72
This commit is contained in:
Nobuyoshi Nakada 2021-01-24 16:16:47 +09:00
Родитель 5411fb8cff
Коммит 7fe22152fc
2 изменённых файлов: 25 добавлений и 3 удалений

Просмотреть файл

@ -231,13 +231,13 @@ class RDoc::Parser::ChangeLog < RDoc::Parser
# 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}")
begin
time = parse_date(header[/^ *CommitDate: +(.*)/, 1] || date)
@time_cache[entry_name] = time
author.sub!(/\s*<(.*)>/, '')
email = $1
entries << [entry_name, [author, email, date, entry_body]]
rescue ArgumentError
end
end

Просмотреть файл

@ -331,6 +331,18 @@ Mon Dec 3 20:37:22 2012 Koichi Sasada <ko1@atdot.net>
def test_scan_git
parser = util_parser <<-ChangeLog
commit\ 38816887962ec167ee46acf500f68df5c3013163
Author: git <svn-admin@ruby-lang.org>
Date: Sun Jan 24 14:35:51 2021 +0900
* 2021-01-24 [ci skip]
commit\ db7d0b89f6eca66cc7eb155c95f9123133da1ffc
Author: git <svn-admin@ruby-lang.org>
Date: Sat, 23 Jan 2021 06:01:39 +0900
* 2021-01-23 [ci skip]
commit\ 709bed2afaee50e2ce803f87bf1ee8291bea41e3
Author: git <svn-admin@ruby-lang.org>
Date: 2021-01-21 01:03:52 +0900
@ -372,6 +384,16 @@ ChangeLog
expected = doc(
head(1, File.basename(@tempfile.path)),
blank_line,
head(2, '2021-01-24'),
blank_line,
log_entry(nil, '38816887962ec167ee46',
'git', 'svn-admin@ruby-lang.org', 'Sun Jan 24 14:35:51 2021 +0900',
[list(:BULLET, item(nil, para('2021-01-24 [ci skip]')))]),
head(2, '2021-01-23'),
blank_line,
log_entry(nil, 'db7d0b89f6eca66cc7eb',
'git', 'svn-admin@ruby-lang.org', 'Sat, 23 Jan 2021 06:01:39 +0900',
[list(:BULLET, item(nil, para('2021-01-23 [ci skip]')))]),
head(2, '2021-01-21'),
blank_line,
log_entry(nil, '709bed2afaee50e2ce80',