Skip to content

Support retrieve first commit timestamp with follow mode #90

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

Merged
merged 2 commits into from
Jul 2, 2022

Conversation

blueswen
Copy link
Contributor

Add a creation_date_with_follow option to enable retrieve first commit timestamp with follow mode.
Since markdown files may be moved for reorganizing MkDocs directory, showing the creation date it actually created would be very useful.

@timvink
Copy link
Owner

timvink commented Jun 25, 2022

Hi @blueswen! Late reply, as I recently became a father and have been quite busy :)

I really like this addition! Make a lot of sense. I am a bit hesistant to add more options.. I'd like to keep it easy to use for the majority of users.

Do you see any use-case for not using the follow mode by default? We could remove the option, always use follow mode for the creation date, and create a new major release (because the change is not backwards compatible, it might effect existing creation dates).

Do you know if the--follow option is supported by older versions of git also? We don't want to break any builds.

@blueswen
Copy link
Contributor Author

Congrats 🎊! Family is always first.

The --follow option works fine in most cases. However if add and commit a new file with same content which another old file already in git, the new file will inherent the old file commit log in follow mode. Sine empty is a kind of content, if there is an empty file already in git long time ago, any file add and commit with empty content will be considered be created long time ago too.

# first empty file long time ago
touch a.txt
git add a.txt
git commit -m "01"

# some others commits
echo test > b.txt
git add b.txt
git commit -m "02"

# new empty file
touch c.txt
git add c.txt
git commit -m "03"

# with 01 and 03 commit
git log --follow c.txt

# with 03 commit
git log c.txt

I am not sure how many people would commit an empty file, if not, using the follow mode by default would be great!

After some digging, I found the --follow option was supported since v1.5.3 about 15 years ago. I think maybe it's okay for the majority of users.

@timvink
Copy link
Owner

timvink commented Jun 27, 2022

Thanks for looking into this.

In the case of new empty files, you would still see a recent revision date, but potentially a much older creation date. An edge case that I'm happy to accept over adding an extra option.

You've also confirmed --follow is not anything new, so it should be well supported by a range of git clients. You also wrote a unit test (kudos) that passed in 12 different environments. Another potential downside of --follow is that it might slightly increase build times, but users looking for speed can already disable creation_date via the options or even use enabled option to switch the plugin on & off depending on the build environment.

So I feel confident we should make follow mode default. Would you be willing to update the PR?

@blueswen
Copy link
Contributor Author

Making follow mode default is great! I removed the creation_date_with_follow option and modify unit test for follow mode as default. Glad to help!

@timvink timvink merged commit cf562a9 into timvink:master Jul 2, 2022
@timvink
Copy link
Owner

timvink commented Jul 2, 2022

Just released in v1.1.0 🎉 !

Thanks for the work & the research !

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.

2 participants