reuse-tool icon indicating copy to clipboard operation
reuse-tool copied to clipboard

Fix the helper script to find the year of first commit of a file to show the right year

Open silverhook opened this issue 3 years ago • 4 comments

I am looking at the helper scripts – https://reuse.readthedocs.io/en/stable/scripts.html#year-of-first-commit – and see an issue.

Namely, if you run that on a file, it can find the wrong year. I just hit that bug myself!

As such I would suggest we change the helper script to the much more reliable:

git log --follow --format=%as $file | tail -n1 | cut -c-4

We could also mention --find-renames as an option some might want to make use of.

Further (short) reading: https://kgrz.io/use-git-log-follow-for-file-history.html

silverhook avatar Oct 27 '22 18:10 silverhook

Should we add --follow to more commands?

nicorikken avatar Dec 04 '22 20:12 nicorikken

The --reverse option with head should be faster if I recall correctly. But perhaps less readable.

nicorikken avatar Dec 04 '22 21:12 nicorikken

I’m not a Git expert by any means, but from what I understand --reverse … | head should be faster, but --follow should be more exact.

silverhook avatar Dec 06 '22 15:12 silverhook

Thank you for your time and contributions! Unfortunately, this issue has been inactive for quite a while which means we probably can't manage the time to deal with it. That's why we're marking it as stale. We want to keep things tidy and focus on active discussions, but we’re always happy to revisit if this is still relevant!

If you’d like to keep this open, please add a comment to let us know and remove the label stale. Otherwise, this issue will most likely be automatically closed soon.

github-actions[bot] avatar Jun 17 '25 03:06 github-actions[bot]

This issue is still relevant.

silverhook avatar Jul 02 '25 14:07 silverhook

Hi! This repository is being migrated away from GitHub towards Codeberg. More context can be found in #865. This issue can henceforth be found at https://codeberg.org/fsfe/reuse-tool/issues/618. Any comments subsequent to this comment will not be migrated.

carmenbianca avatar Nov 24 '25 14:11 carmenbianca