casperdcl / git-fame

:star: Pretty-print `git` repository collaborators sorted by contributions
Other
617 stars 34 forks source link

ignore "maintenance" user #94

Open KrisThielemans opened 5 months ago

KrisThielemans commented 5 months ago

In our repository, we had some commits made by automatic processing (e.g. clang-tidy, clang-format), where we used the --author "maintainer" switch to make clear that this commit isn't really "mine". It'd be nice to be able to tell git fame to ignore this author (i.e. use the author of the previous commit), as now we have a lot of slocs for this maintainer. Presumably this would also happen with pre-commit.ci, although I don't know.

I have no idea if this is possible.

casperdcl commented 4 months ago

I think you're talking about https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view :)

PS I tend to use --author "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"

KrisThielemans commented 1 month ago

Sorry @casperdcl can you be more explicit?

The git blame doc refers to fsck.skipList for the format, which says

The path to a list of object names (i.e. one unabbreviated SHA-1 per line) that are known to be broken in a non-fatal way and should be ignored.

I've optimistically tried to add --author="stir_maintenance <noreply@github.com>" to .git-blame-ignore-revs and do

 git blame --ignore-revs-file .git-blame-ignore-revs some_filename

That gives

fatal: invalid object name: --author="stir_maintenance <noreply@github.com>"

I could imagine creating a script that uses git log to find all hashes from this user to update this file, but that could easily become quite large if we'd run a bot that changes code.

Even if I manage that, I don't know how to pass this to git fame. Maybe by setting blame.ignoreRevsFile?

thanks!

casperdcl commented 1 month ago

Sorry for the confusion - I was referring to two different things.

I haven't seen any elegant solutions for cases like pre-commit.ci[bot] autofixing lots of external PRs on very active projects.