Skip to content

WIP : Chore: Setup Ruff formatter with git blame ignore#17

Draft
alexandremgo wants to merge 3 commits into
masterfrom
perso/chore/formatter-with-git-blame-ignore
Draft

WIP : Chore: Setup Ruff formatter with git blame ignore#17
alexandremgo wants to merge 3 commits into
masterfrom
perso/chore/formatter-with-git-blame-ignore

Conversation

@alexandremgo

@alexandremgo alexandremgo commented Sep 25, 2024

Copy link
Copy Markdown

Goal

Just a demo of having a commit formatting several/all the files of a project (with Ruff), and managing to ignore it to display the previous git history.

The idea is to have a .git-blame-ignore-revs file that will contains the hashes of commits that ONLY contain formatting changes.
As you can see in github docs this specific file name .git-blame-ignore-revs is recognized by github.

Also you can setup your local git with:

git config blame.ignoreRevsFile .git-blame-ignore-revs

so it ignores automatically those commits. If you use a git blame tool in your IDE this should work too (tested quickly on VSCode, Intellij and neovim).

Demo

VSCode ex

After the changes, BEFORE setting up .git-blame-ignore-revs:

Screenshot 2024-09-25 at 17 46 43

After the changes, AFTER setting up .git-blame-ignore-revs:

Screenshot 2024-09-25 at 17 47 34

Github ex

You can also see the Github blame of a file: here for ex, and see that the .git-blame-ignore-revs is taken into account

image

Warning

Careful to NOT squash and merge as the final commit will not have the same hash. Same for a rebase (but you can just update the .git-blame-ignore-revs after the rebase).

Note

The default Ruff formatting rules or the presence of a requirements-dev.txt are not final and should be discussed. This is mainly a demo of .git-blame-ignore-revs

Only formatting changes
And ignores commit containing only formatting changes
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.

1 participant