timvink / mkdocs-git-revision-date-localized-plugin

MkDocs plugin to add a last updated date to your site pages
https://timvink.github.io/mkdocs-git-revision-date-localized-plugin/index.html
MIT License
202 stars 43 forks source link

Option to ignore commits about move operations #147

Open skywarth opened 5 days ago

skywarth commented 5 days ago

Hi there,

I just got started with using this plugin but ran into something which might be worth considering as a future. So recently I moved all my md files into a singular folder, and committed like so, hence the last change date of all my notes are pointing to that date, which is sub optimal because it is not an actual change, just a move operation. So how about an option to disregards last commit if it is a move operation, and doesn't contain any actual changes in the file itself?

Here's an example scenario:

Just a thought: move operations can be determined if file contents are identical per hash.

This feature could come in handy, what do you think?

If it is a considerable feature, I might try to take a crack at it.

Thank you

timvink commented 5 days ago

Hee, that's a good one!

I think we can add that by adding a diff filter "r". See
https://stackoverflow.com/questions/15130597/git-log-exclude-renames

It should be added here:

https://github.com/timvink/mkdocs-git-revision-date-localized-plugin/blob/3f39e6558213de330b4fbb5e6473aaf95a07713c/src/mkdocs_git_revision_date_localized_plugin/util.py#L96

And here's an example of how to add the diff filter argument, as we already use it for the creation date.

https://github.com/timvink/mkdocs-git-revision-date-localized-plugin/blob/3f39e6558213de330b4fbb5e6473aaf95a07713c/src/mkdocs_git_revision_date_localized_plugin/util.py#L86

Would appreciate a PR!

skywarth commented 4 days ago

Hee, that's a good one!

I think we can add that by adding a diff filter "r". See https://stackoverflow.com/questions/15130597/git-log-exclude-renames

It should be added here:

https://github.com/timvink/mkdocs-git-revision-date-localized-plugin/blob/3f39e6558213de330b4fbb5e6473aaf95a07713c/src/mkdocs_git_revision_date_localized_plugin/util.py#L96

And here's an example of how to add the diff filter argument, as we already use it for the creation date.

https://github.com/timvink/mkdocs-git-revision-date-localized-plugin/blob/3f39e6558213de330b4fbb5e6473aaf95a07713c/src/mkdocs_git_revision_date_localized_plugin/util.py#L86

Would appreciate a PR!

Thank you for the leads, I'll try to open up a PR for this feature. Though I'm not really proficient with Python or pip package development environment, I'll try my best :smile:

I suppose Contributing guide is where I gotta start from? Any other tips for setting it up for dev environment?

Thank you

timvink commented 4 days ago

Brave venturing into python.

Two tips: 1) editable installs (pip install -e .) 2) you can add breakpoint() anywhere in the code, then run of the test examples with mkdocs serve -f path-to-mkdocs.yml (or add a new one, or use your own project)

Perhaps you could setup two repos locally, where one had a rename in the commit history and the other doesn't. The you can verify it works.

Good luck, and no worries if you get stuck. Oh and remember open source is supposed to be fun, no pressure or rush at all!