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

Support .git-blame-ignore-revs file #26395

Merged
merged 14 commits into from
Sep 16, 2023

Conversation

KN4CK3R
Copy link
Member

@KN4CK3R KN4CK3R commented Aug 8, 2023

Closes #26329

This PR adds the ability to ignore revisions specified in the .git-blame-ignore-revs file in the root of the repository.

grafik

The banner is displayed in this case. I intentionally did not add a UI way to bypass the ignore file (same behaviour as Github) but you can add ?bypass-blame-ignore=true to the url manually.

@KN4CK3R KN4CK3R added type/feature Completely new functionality. Can only be merged if feature freeze is not active. pr/wip This PR is not ready for review labels Aug 8, 2023
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 8, 2023
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 8, 2023
@KN4CK3R KN4CK3R marked this pull request as draft August 8, 2023 12:24
Comment on lines 120 to 123
ignoreRevsFile = tryCreateBlameIgnoreRevsFile(commit)
if ignoreRevsFile != nil {
cmd.AddOptionValues("--ignore-revs-file", ignoreRevsFile.Name())
}
Copy link
Member Author

Choose a reason for hiding this comment

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

It would be better to use --ignore-revs-file /dev/stdin and pass the content of the .git-blame-ignore-revs file but there is no Windows equivalent for /dev/stdin.

Copy link
Member

Choose a reason for hiding this comment

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

We could think about creating a unix and windows variant where the windows variant uses an actual file while the UNIX variant uses stdin…

@KN4CK3R KN4CK3R changed the title [WIP] Support git-blame-ignore-revs file Support git-blame-ignore-revs file Aug 10, 2023
@KN4CK3R KN4CK3R removed the pr/wip This PR is not ready for review label Aug 10, 2023
@KN4CK3R KN4CK3R marked this pull request as ready for review August 10, 2023 14:54
options/locale/locale_en-US.ini Outdated Show resolved Hide resolved
routers/web/repo/blame.go Outdated Show resolved Hide resolved
modules/git/blame.go Outdated Show resolved Hide resolved
Comment on lines 120 to 123
ignoreRevsFile = tryCreateBlameIgnoreRevsFile(commit)
if ignoreRevsFile != nil {
cmd.AddOptionValues("--ignore-revs-file", ignoreRevsFile.Name())
}
Copy link
Member

Choose a reason for hiding this comment

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

We could think about creating a unix and windows variant where the windows variant uses an actual file while the UNIX variant uses stdin…

modules/git/blame.go Show resolved Hide resolved
@delvh delvh changed the title Support git-blame-ignore-revs file Support .git-blame-ignore-revs file Aug 13, 2023
@delvh
Copy link
Member

delvh commented Aug 13, 2023

Oh, by the way, this feature needs documentation.
Especially since we deviate from GitHub.

@KN4CK3R
Copy link
Member Author

KN4CK3R commented Aug 13, 2023

Especially since we deviate from GitHub.

You talk about the bypass parameter? The other functionality is identical to Github.

@delvh
Copy link
Member

delvh commented Aug 13, 2023

Yes.

delvh
delvh previously approved these changes Aug 13, 2023
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Aug 13, 2023
@delvh delvh dismissed their stale review August 13, 2023 17:58

Forgot that documentation is still missing. Once it is present LGTM.

@GiteaBot GiteaBot added lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Aug 13, 2023
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Aug 30, 2023
output io.WriteCloser
reader io.ReadCloser
bufferedReader *bufio.Reader
done chan error
lastSha *string
ignoreRevsFile *os.File
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems strange to store a closed File here. Maybe using ignoreRevsFileName string is good enough?

Otherwise it's not easy to understand when the file should be closed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I used os.File here to have an explicit nil check. Sure a != "" check works too but my intent was to have a real file linked to the object. How about changing this member to os.FileInfo? That should be the best of both worlds.

Copy link
Contributor

Choose a reason for hiding this comment

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

but my intent was to have a real file linked to the object.

But the file has been closed, the object itself can't do other things except accessing the f.Name(), which is simply { return f.name }

modules/git/blame.go Outdated Show resolved Hide resolved
modules/git/blame.go Outdated Show resolved Hide resolved
{{$revsFileLink := URLJoin .RepoLink "src" .BranchNameSubURL "/.git-blame-ignore-revs"}}
{{if .UsesIgnoreRevs}}
<div class="ui info message">
<p>{{.locale.Tr "repo.blame.ignore_revs" $revsFileLink | Str2html}}</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it could add ?bypass-blame-ignore=true link here, than no need to write the document, and it's more friendly to end users?

@github-actions github-actions bot added the type/docs This PR mainly updates/creates documentation label Sep 15, 2023
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Sep 16, 2023
@KN4CK3R KN4CK3R enabled auto-merge (squash) September 16, 2023 17:16
@KN4CK3R KN4CK3R merged commit ed64f1c into go-gitea:main Sep 16, 2023
26 checks passed
@GiteaBot GiteaBot added this to the 1.22.0 milestone Sep 16, 2023
@delvh delvh modified the milestones: 1.22.0, 1.21.0 Sep 16, 2023
zjjhot added a commit to zjjhot/gitea that referenced this pull request Sep 17, 2023
* giteaoffical/main: (23 commits)
  Search branches (go-gitea#27055)
  Fix wrong migration for email address (go-gitea#27106)
  [skip ci] Updated translations via Crowdin
  Support `.git-blame-ignore-revs` file (go-gitea#26395)
  Add `RemoteAddress` to mirrors (go-gitea#26952)
  Upgrading the actions/checkout@4 (go-gitea#27096)
  Next round of `db.DefaultContext` refactor (go-gitea#27089)
  Ui correction in mobile view nav bar left aligned items. (go-gitea#27046)
  Add missing deps to files-changed (go-gitea#27100)
  Use db.WithTx for AddTeamMember to avoid ctx abuse (go-gitea#27095)
  Drop Node.js 16 and update js dependencies (go-gitea#27094)
  Fix NPE when editing OAuth2 applications (go-gitea#27078)
  Use `print` instead of `printf` (go-gitea#27093)
  Add tests for db indexer in indexer_test.go (go-gitea#27087)
  [skip ci] Updated translations via Crowdin
  Allow empty Conan files (go-gitea#27092)
  Actions are no longer experimental, so enable them by default (go-gitea#27054)
  Update brew installation documentation since gitea moved to brew core package (go-gitea#27070)
  More refactoring of `db.DefaultContext` (go-gitea#27083)
  [skip ci] Updated translations via Crowdin
  ...
silverwind added a commit to silverwind/gitea that referenced this pull request Sep 17, 2023
* origin/main: (53 commits)
  Search branches (go-gitea#27055)
  Fix wrong migration for email address (go-gitea#27106)
  [skip ci] Updated translations via Crowdin
  Support `.git-blame-ignore-revs` file (go-gitea#26395)
  Add `RemoteAddress` to mirrors (go-gitea#26952)
  Upgrading the actions/checkout@4 (go-gitea#27096)
  Next round of `db.DefaultContext` refactor (go-gitea#27089)
  Ui correction in mobile view nav bar left aligned items. (go-gitea#27046)
  Add missing deps to files-changed (go-gitea#27100)
  Use db.WithTx for AddTeamMember to avoid ctx abuse (go-gitea#27095)
  Drop Node.js 16 and update js dependencies (go-gitea#27094)
  Fix NPE when editing OAuth2 applications (go-gitea#27078)
  Use `print` instead of `printf` (go-gitea#27093)
  Add tests for db indexer in indexer_test.go (go-gitea#27087)
  [skip ci] Updated translations via Crowdin
  Allow empty Conan files (go-gitea#27092)
  Actions are no longer experimental, so enable them by default (go-gitea#27054)
  Update brew installation documentation since gitea moved to brew core package (go-gitea#27070)
  More refactoring of `db.DefaultContext` (go-gitea#27083)
  [skip ci] Updated translations via Crowdin
  ...
@KN4CK3R KN4CK3R deleted the feature-blame-ignore-revs branch September 18, 2023 10:10
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Dec 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/docs This PR mainly updates/creates documentation type/feature Completely new functionality. Can only be merged if feature freeze is not active.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support git-blame-ignore-revs file
4 participants