mkdocs-rss-plugin icon indicating copy to clipboard operation
mkdocs-rss-plugin copied to clipboard

Attempt to extract date from only the last line of git log output

Open yuha0 opened this issue 3 years ago • 8 comments

Previously, the code assumes the output of git log --format="%at" only contains commit timestamp. But this is not true.

--format only controls a portion of the output. git log command can output additional information thats not controlled by format. e.g.: When showSignature is set, it will always display commit signature info.

This commit attempts to locate timestamps only from the very last line of git log output.

Fixes #124

yuha0 avatar Jun 24 '22 00:06 yuha0

I am not super familiar with all the possible options in git that may affect the output of git log. There could have been other cases I haven't thought about. However, limiting the timestamp extraction to only the last line of git log output fixed the issue for me at least. Please let me know if you have suggestions!

yuha0 avatar Jun 24 '22 00:06 yuha0

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 81.21%. Comparing base (3dabb2c) to head (293a902).

:exclamation: Current head 293a902 differs from pull request most recent head e950034

Please upload reports for the commit e950034 to get more accurate results.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #125      +/-   ##
==========================================
- Coverage   85.04%   81.21%   -3.84%     
==========================================
  Files          10        5       -5     
  Lines         555      330     -225     
  Branches      117       76      -41     
==========================================
- Hits          472      268     -204     
+ Misses         53       40      -13     
+ Partials       30       22       -8     
Flag Coverage Δ
unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
mkdocs_rss_plugin/util.py 71.42% <ø> (-3.78%) :arrow_down:

... and 10 files with indirect coverage changes

codecov[bot] avatar Jun 24 '22 17:06 codecov[bot]

It looks good to me but maybe an unit test would be better, to compare result between with/out the --show-signature option. What do you think?

Guts avatar Jun 30 '22 19:06 Guts

@Guts Thanks for the suggestion. I think that's a great idea. Looks like the lines I touched are part of a very long method, get_file_dates, which attempts to extract dates in various ways. What do you think if we refactor it a bit and move the git log extraction logic into a dedicated string parsing method? Then I can mock some git log outputs to test just that method.

yuha0 avatar Jul 06 '22 00:07 yuha0

What do you think if we refactor it a bit and move the git log extraction logic into a dedicated string parsing method? Then I can mock some git log outputs to test just that method.

Good idea! Please, make yourself comfortable, go ahead!

Guts avatar Jul 06 '22 07:07 Guts

Hi @yuha0!

Do you need some help or review to achieve this?

Guts avatar Aug 29 '22 21:08 Guts

@Guts Sorry about the delay, It's been busy at work. Also, for some reason I cannot reproduce it on my personal device... I will need to investigate a bit more

yuha0 avatar Oct 03 '22 18:10 yuha0

@yuha0 no worries, take the time you have. I just needed to know if it's still an active work here or if it's stale.

Can you set this PR to draft status in the meanwhile?

Guts avatar Oct 04 '22 13:10 Guts

Hey @yuha0,

Any chance to see this work achieved?
I close here since it's has been 2 years without any push (except rebase), but don't hesitate to reopen.

Guts avatar Jun 10 '24 11:06 Guts