Closed PegasisForever closed 3 years ago
When I run tests (using pytest
), a lot of them fails even without my changes. Any ideas?
mkdocs version 1.1.2
When I run tests (using pytest), a lot of them fails even without my changes. Any ideas?
I created a fresh python 3.9
env, I'm using same mkdocs version. Tests succeed on master
branch, but fail on PegasisForever:git_creation_date_localized
branch with same error.
The error suggests it probably has to do with this line:
I fixed the tests and added a new one to test creation dates.
Really nice work! Thanks for the PR!
My only doubt is if we can remove enable_creation_date
as a parameter, and make it available by default. I will also do some work on the documentation.
Plan to release this later this week!
I was going through the existing code base and cleaning things up a bit. The trick of using diff_filter="A"
is that it only selects the commit that created the file, correct?
commit_timestamp = git.log(
realpath, date="short", format="%at", diff_filter="A"
)
OK, I opened https://github.com/squidfunk/mkdocs-material/issues/2551 to discuss adding native support for the creation date in the material theme.
My only doubt is if we can remove enable_creation_date as a parameter
The reason I didn't enable enable_creation_date
as default is I don't want to change the behaviour of old websites.
The trick of using diff_filter="A" is that it only selects the commit that created the file, correct?
Yes, see https://git-scm.com/docs/git-diff#Documentation/git-diff.txt---diff-filterACDMRTUXB82308203
The reason I didn't enable enable_creation_date as default is I don't want to change the behaviour of old websites.
Yes, it's the right decision. My doubt was 1) what is you only want to have the creation date, and not the last updated? and 2) what we if add more git date related fields. It's a fine solution for now.
FYI, I also opened this PR for native mkdocs-material support: https://github.com/squidfunk/mkdocs-material/pull/2579
relating issue: #49
This pr adds
{{git_creation_date_localized}}
I improved performance of getting the creation date by using
git.log(realpath, date="short", format="%at", diff_filter="A")
. The reverse option mentioned in the issue doesn't work because it reverse the output after limiting the lines.