Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/rdoc/parser/changelog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ def group_entries entries

def parse_date(date)
case date
when /\A\s*(\d+)-(\d+)-(\d+)(?: (\d+):(\d+):(\d+) *([-+]\d\d)(\d\d))?\b/
when /\A\s*(\d+)-(\d+)-(\d+)(?:[ T](\d+):(\d+):(\d+) *([-+]\d\d):?(\d\d))?\b/
Time.new($1, $2, $3, $4, $5, $6, ("#{$7}:#{$8}" if $7))
when /\A\s*\w{3}, +(\d+) (\w{3}) (\d+) (\d+):(\d+):(\d+) *(?:([-+]\d\d)(\d\d))\b/
when /\A\s*\w{3}, +(\d+) (\w{3}) (\d+) (\d+):(\d+):(\d+) *(?:([-+]\d\d):?(\d\d))\b/
Time.new($3, $2, $1, $4, $5, $6, ("#{$7}:#{$8}" if $7))
when /\A\s*\w{3} (\w{3}) +(\d+) (\d+) (\d+):(\d+):(\d+) *(?:([-+]\d\d)(\d\d))\b/
when /\A\s*\w{3} (\w{3}) +(\d+) (\d+) (\d+):(\d+):(\d+) *(?:([-+]\d\d):?(\d\d))\b/
Time.new($3, $1, $2, $4, $5, $6, ("#{$7}:#{$8}" if $7))
when /\A\s*\w{3} (\w{3}) +(\d+) (\d+):(\d+):(\d+) (\d+)\b/
Time.new($6, $1, $2, $3, $4, $5)
Expand Down Expand Up @@ -231,13 +231,13 @@ def parse_entries
# 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

Expand Down
33 changes: 33 additions & 0 deletions test/rdoc/test_rdoc_parser_changelog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,24 @@ def test_scan

def test_scan_git
parser = util_parser <<-ChangeLog
commit\ 38816887962ec167ee46acf500f68df5c3013163
Author: git <[email protected]>
Date: Sun Jan 24 14:35:51 2021 +0900

* 2021-01-24 [ci skip]

commit\ db7d0b89f6eca66cc7eb155c95f9123133da1ffc
Author: git <[email protected]>
Date: Sat, 23 Jan 2021 06:01:39 +0900

* 2021-01-23 [ci skip]

commit\ a3efbda7128ef20b55505b32d1608ea48f80af4a
Author: git <[email protected]>
Date: 2021-01-22T02:49:39+09:00

* 2021-01-22 [ci skip]

commit\ 709bed2afaee50e2ce803f87bf1ee8291bea41e3
Author: git <[email protected]>
Date: 2021-01-21 01:03:52 +0900
Expand Down Expand Up @@ -372,6 +390,21 @@ def test_scan_git
expected = doc(
head(1, File.basename(@tempfile.path)),
blank_line,
head(2, '2021-01-24'),
blank_line,
log_entry(nil, '38816887962ec167ee46',
'git', '[email protected]', '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', '[email protected]', 'Sat, 23 Jan 2021 06:01:39 +0900',
[list(:BULLET, item(nil, para('2021-01-23 [ci skip]')))]),
head(2, '2021-01-22'),
blank_line,
log_entry(nil, 'a3efbda7128ef20b5550',
'git', '[email protected]', '2021-01-22T02:49:39+09:00',
[list(:BULLET, item(nil, para('2021-01-22 [ci skip]')))]),
head(2, '2021-01-21'),
blank_line,
log_entry(nil, '709bed2afaee50e2ce80',
Expand Down