Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add {{git_creation_date_localized}} #50

Merged
merged 8 commits into from Apr 12, 2021

Conversation

PegasisForever
Copy link
Contributor

@PegasisForever PegasisForever commented Mar 26, 2021

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.

@PegasisForever
Copy link
Contributor Author

When I run tests (using pytest), a lot of them fails even without my changes. Any ideas?

mkdocs version 1.1.2

image

@timvink
Copy link
Owner

timvink commented Mar 27, 2021

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:

https://github.com/timvink/mkdocs-git-revision-date-localized-plugin/pull/50/files#diff-00b1f736d69bb089d8eafceeb52bc04b19ebecf339a8b33ccc3404a21ebd32cbR158

@PegasisForever
Copy link
Contributor Author

I fixed the tests and added a new one to test creation dates.

@PegasisForever PegasisForever changed the title [WIP] add {{git_creation_date_localized}} Add {{git_creation_date_localized}} Mar 27, 2021
@timvink
Copy link
Owner

timvink commented Apr 12, 2021

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!

@timvink timvink merged commit 2ddde87 into timvink:master Apr 12, 2021
@timvink
Copy link
Owner

timvink commented Apr 12, 2021

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"
                )

@timvink
Copy link
Owner

timvink commented Apr 12, 2021

OK, I opened squidfunk/mkdocs-material#2551 to discuss adding native support for the creation date in the material theme.

@PegasisForever
Copy link
Contributor Author

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

@timvink
Copy link
Owner

timvink commented Apr 19, 2021

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: squidfunk/mkdocs-material#2579

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants