-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Conversation
modules/git/blame.go
Outdated
ignoreRevsFile = tryCreateBlameIgnoreRevsFile(commit) | ||
if ignoreRevsFile != nil { | ||
cmd.AddOptionValues("--ignore-revs-file", ignoreRevsFile.Name()) | ||
} |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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
Outdated
ignoreRevsFile = tryCreateBlameIgnoreRevsFile(commit) | ||
if ignoreRevsFile != nil { | ||
cmd.AddOptionValues("--ignore-revs-file", ignoreRevsFile.Name()) | ||
} |
There was a problem hiding this comment.
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…
.git-blame-ignore-revs
file
Oh, by the way, this feature needs documentation. |
You talk about the bypass parameter? The other functionality is identical to Github. |
Yes. |
Forgot that documentation is still missing. Once it is present LGTM.
…-blame-ignore-revs
…-blame-ignore-revs
modules/git/blame.go
Outdated
output io.WriteCloser | ||
reader io.ReadCloser | ||
bufferedReader *bufio.Reader | ||
done chan error | ||
lastSha *string | ||
ignoreRevsFile *os.File |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 }
templates/repo/blame.tmpl
Outdated
{{$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> |
There was a problem hiding this comment.
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?
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
…-blame-ignore-revs
…R/gitea into feature-blame-ignore-revs
* 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 ...
* 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 ...
Closes #26329
This PR adds the ability to ignore revisions specified in the
.git-blame-ignore-revs
file in the root of the repository.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.