Skip to content
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

Add .git-blame-ignore-revs file #881

Merged
merged 2 commits into from
Sep 5, 2024
Merged

Conversation

smelc
Copy link
Contributor

@smelc smelc commented Sep 3, 2024

Changelog

- description: |
    Ignore reformatting changes (introduction of fourmolu) in calls to `git blame`
# uncomment types applicable to the change:
  type:
  # - feature        # introduces a new feature
  # - breaking       # the API has changed in a breaking way
  # - compatible     # the API has changed but is non-breaking
  # - optimisation   # measurable performance improvements
  # - refactoring    # QoL changes
  # - bugfix         # fixes a defect
  # - test           # fixes/modifies tests
  - maintenance    # not directly related to the code
  # - release        # related to a new release preparation
  # - documentation  # change in code docs, haddocks...

Context

#835 and in particular commit 9d1fd09 (#835) changed the formatting of all files, erasing the git blame history.

This PR uses .git-blame-ignore-revs to fix that in vscode. You can also set the blame.ignoreRevsFile option in your .git/config for terminal calls to git blame to use this file, like this:

[blame]
        ignoreRevsFile = .git-blame-ignore-revs

How to trust this PR

GitHub

GitHub honors the .git-blame-ignore-revs file, as visible here: https://github.com/IntersectMBO/cardano-cli/blame/ec2fd8de4e123ccb45afc866880171963b82cb5f/cardano-cli/src/Cardano/CLI/EraBased/Run/Query.hs

image

gitlens

Compare the behavior of gitlens in vscode before and after this PR:

blame-before

blame-after

I could not find a reference that gitlens honors the .git-blame-igonre-revs file (I could only find references of people requesting it, and explanations how to setup the corresponding option), but it actually does, as the screenshots above show.

CONTRIBUTING.MD

Please see the rendered version: https://github.com/IntersectMBO/cardano-cli/blob/smelc/git-blame-ignore-reformatting/CONTRIBUTING.md#improving-git-blame

@smelc smelc marked this pull request as ready for review September 3, 2024 10:43
Copy link
Contributor

@carbolymer carbolymer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Setting it globally in the git config is problematic though: https://stackoverflow.com/questions/70435937/git-blame-with-optional-ignorerevsfile

CONTRIBUTING.md Outdated

## Improving `git blame`

You can have `git blame` ignore the reformatting done when [introducting fourmolu](https://github.com/IntersectMBO/cardano-cli/pull/835/commits/9d1fd093071278be77428dba189d958d5b7a7aeb) by setting this in your `.git/config` file:
Copy link
Contributor

@carbolymer carbolymer Sep 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be set on a per repo basis instead of globally - not every repo has .git-blame-ignore-revs and if it doesn't, it breaks git blame:

$ git blame flake.nix
fatal: could not open object name list: .git-blame-ignore-revs

I think it would be better to recommend this command git config --local blame.ignoreRevsFile .git-blame-ignore-revs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carbolymer> yep I meant the repository's local git config file (i.e. .git/config, as opposed to the global .gitconfig), but anyway, it's better to give the command than the snippet; so I changed 👍

@smelc smelc force-pushed the smelc/git-blame-ignore-reformatting branch from c1c0b94 to fcdadf7 Compare September 5, 2024 10:02
@smelc smelc enabled auto-merge September 5, 2024 10:03
@smelc smelc added this pull request to the merge queue Sep 5, 2024
Merged via the queue into main with commit a8e11ff Sep 5, 2024
25 checks passed
@smelc smelc deleted the smelc/git-blame-ignore-reformatting branch September 5, 2024 11:33
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