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 support for hyper-blame? #413

Closed
banga opened this issue Jun 13, 2018 · 19 comments
Closed

Add support for hyper-blame? #413

banga opened this issue Jun 13, 2018 · 19 comments
Labels
feature New feature or request help wanted Want community input and/or pull request needs-champion Needs a community champion to move this forward

Comments

@banga
Copy link

banga commented Jun 13, 2018

Hello,

We have started using git hyper-blame (provided as part of Chrome's Depot Tools) at quip, which supports skipping over commits that are part of mass refactoring:
https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/git-hyper-blame.html.

Would there be interest in supporting a flag to switch to using hyper-blame instead of blame? This would make GitLens even more useful for large teams that have to do a lot of refactors.

Thanks!

@banga banga changed the title Add support for hyper-blame Add support for hyper-blame? Jun 13, 2018
@eamodio eamodio added the feature New feature or request label Jul 15, 2018
@eamodio eamodio added this to the Backlog milestone Jul 15, 2018
@eamodio eamodio added the help wanted Want community input and/or pull request label Jul 15, 2018
@eamodio
Copy link
Member

eamodio commented Dec 3, 2018

@banga @jyavenard Can you provide more details on to how adding hyper-blame support would be useful for GitLens?

@eamodio eamodio added the needs-more-info Needs further information, steps, details, etc. label Dec 3, 2018
@jyavenard
Copy link

Hyper-blame allows to define commits that must ignored. This is particularly useful for commits that were whitespace changes only, such as reformatting or code style change.

For the Mozilla gecko tree we have very recently started to move from the Mozilla coding style to Google's. Plain git blame would make every lines appear to be last modified by the coding style change commit. Making git blame absolutely useless.

@eamodio
Copy link
Member

eamodio commented Dec 3, 2018

@jyavenard Thanks. How do you define those commits? In a config file or something? Would GitLens need to know about that? I'm trying to both understand the benefit and the work involved.

@jyavenard
Copy link

There's a .git-blame-ignore-revs file like so
https://hg.mozilla.org/mozilla-central/file/tip/.git-blame-ignore-revs

Gitlens doesn't need to know about it, only the custom git blame command

@eamodio
Copy link
Member

eamodio commented Dec 3, 2018

@jyavenard Could you provide me the output of a blame vs hyper-blame?

Here is the command GitLens uses for blaming:
git blame --root --incremental -- <file-name-here>

@banga
Copy link
Author

banga commented Dec 3, 2018

@eamodio unfortunately hyper-blame doesn't support any other arguments than the file name.

There's an example here which illustrates the difference: https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/git-hyper-blame.html.

If you want to try it out, you can follow these steps: https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up.

@eamodio eamodio modified the milestones: Backlog, Soonish™ Dec 12, 2018
@eamodio eamodio added needs-champion Needs a community champion to move this forward and removed needs-more-info Needs further information, steps, details, etc. labels Jul 9, 2019
@jupp0r
Copy link

jupp0r commented Jul 29, 2019

Another option would be for gitlens to implement git blame in terms of more low-level git operations and take into account .git-blame-ignore-revs in the algorithm.

@eamodio eamodio modified the milestones: Soonish™, Backlog Jul 29, 2019
@patrick91
Copy link

Since git 2.23 this is supported by default, so no need for hyperblame!

https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-fileltfilegt

@banga
Copy link
Author

banga commented Aug 21, 2019

Just tried this and it works beautifully, thanks!

@eamodio
Copy link
Member

eamodio commented Aug 21, 2019

@banga Did you set this view the git config setting or did you use the gitlens.advanced.blame.customArguments setting (see here https://github.com/eamodio/vscode-gitlens#advanced-settings-)?

@banga
Copy link
Author

banga commented Aug 21, 2019

Yeah I added it to customArguments:
image

@jyavenard
Copy link

jyavenard commented Aug 21, 2019

Note: It must be entered in gitlens as two separate items, if you enter it as a single line it won't work.

Also, you can set this option by setting the file(s) you want to use as the value to the git configuration blame.ignoreRevsFile.

@eamodio
Copy link
Member

eamodio commented Aug 31, 2019

Since Git now natively supports this and can be used with GitLens I'm going to close this.

@eamodio eamodio closed this as completed Aug 31, 2019
@devinrhode2
Copy link

devinrhode2 commented Nov 17, 2019

I'm googling around trying to learn exactly how to use this new file, .git-blame-ignore-revs. Do we need to to add the "Custom Arguments" gitlens vscode setting?

@eamodio
Copy link
Member

eamodio commented Nov 17, 2019

Yes, see #413 (comment)

@Merlin2001
Copy link

Merlin2001 commented Apr 28, 2020

Yeah I added it to customArguments:
image

Thanks for hinting in the right direction, @banga ! 🚀

For some reason I can't get it to work, though, as ${workspaceRoot} seems to be undefined in my case. How would I correctly let GitLens know about an ignore file that is
a) simply located in the repository's root directory or
b) has an absolute path like C:\dev\client\.git-blame-ignore-revs?

Any help is greatly appreciated! 🙏🏻

Edit (solved)

I figured out that I should just have used Ctrl + Shift + P > Developer: Reload Window to reload the window and force the settings to take effect.

For case a) I simply added the file name without any folder specification:
2020-04-28_23h33_19

For case b) the following syntax worked:
2020-04-28_23h36_47

@devinrhode2
Copy link

devinrhode2 commented Sep 15, 2020

I noticed a few issues. I had --ignore-rev-file instead of the PLURAL --ignore-revs-file. Git 2.28.0 was failing with the non plural version. In my package.json I have this preinstall script:

"preinstall": "echo \"Including dev-scripts/.gitconfig\" && git config --local include.path ./.gitconfig",

My repo's .gitconfig file is:

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

my .vscode/settings.json file:

{
  "gitlens.advanced.blame.customArguments": [
    "--ignore-revs-file",
    ".git-blame-ignore-revs" // I had to remove "$(workspaceRoot}/" prefix in the path, otherwise gitlens was stripping the whole --ignore-revs-file arg.
    // if you open the GitLens (git) output pane (with this setting "gitlens.outputLevel": "debug" )
    // and then change --ignore-revs-file to something wrong like --ignor-r-fil
    // then you will see gitlens pass it through to this command:
    // git blame --root --incremental --ignore-revs-file .git-blame-ignore-revs -- .vscode/settings.json
    // You should see the git blame command has the --ignore-revs-file added to the `git blame` command
    // You probably don't need the .gitconfig setting AND the gitlens vscode custom blame arg, but I'd rather cover my bases
  ],
}

Other vscode settings people may be interested in:

  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "[javascript]": {
    "editor.formatOnSave": true,
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  // eslint autosave was having very poor performance for devin
  // "eslint.autoFixOnSave": true,
  // "editor.codeActionsOnSave": {
  //   "source.fixAll.eslint": true
  // },
  "editor.tabSize": 2,
  "search.exclude": {
    // "*.css": true,
    "*.svg": true,
    "yarn.lock": true,
    ".yarnrc.yml": true,
    ".yarnrc": true,
    ".yarn": true,
    ".gitignore": true,
    ".gitattributes": true,
    "package-lock.json": true,
    ".eslintignore": true,
    ".prettierignore": true,
    ".stylelintignore": true,
    ".editorconfig": true,
    "public": true,
    "public/index.html": false,
  },

@devinrhode2
Copy link

Despite including the .gitconfig file, I had to also get the vscode setting correct to get gitlens to use the .git-blame-ignore-revs file and ignore certain changes.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 25, 2020
@eamodio eamodio removed this from the Backlog milestone Dec 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature New feature or request help wanted Want community input and/or pull request needs-champion Needs a community champion to move this forward
Projects
None yet
Development

No branches or pull requests

7 participants