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

Ignore files in diff with .gitattributes #16250

Closed
wants to merge 2 commits into from

Conversation

KN4CK3R
Copy link
Member

@KN4CK3R KN4CK3R commented Jun 25, 2021

fixes #12653
close #16262
first step for #14786, #14528

This PR adds a .gitattributes parser to Gitea. It works like on Gitlab and "caches" the .gitattribute file from the root of the default branch in repo.git/info/attributes. The diff supports now the linguist-generated keyword and hides these file in the output.
test

@KN4CK3R KN4CK3R added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Jun 25, 2021
@KN4CK3R KN4CK3R added this to the 1.16.0 milestone Jun 25, 2021
@kdumontnu
Copy link
Contributor

kdumontnu commented Jun 25, 2021

I still need to try this out, but does it also hide the text diff by default for linguist-generated, like in GitHub?
I think even better would be to collapse the diff (AND not run the diffing algo until it's needed).
image

Essentially, I have some users with a ton of generated project files that are cluttering up the diffs. I want to add these to .gitattributes to hide them.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jun 25, 2021
@zeripath
Copy link
Contributor

nope.

This is not the way.

git check-attr is the correct tool.

@KN4CK3R
Copy link
Member Author

KN4CK3R commented Jun 25, 2021

I still need to try this out, but does it also hide the text diff by default for linguist-generated, like in GitHub?
I think even better would be to collapse the diff (AND not run the diffing algo until it's needed).

The diff is initially hidden like on Github. The diff is not delayed because that's how Gitea works at the moment. See https://github.blog/2016-12-06-how-we-made-diff-pages-3x-faster/ how Github may do it.

@KN4CK3R
Copy link
Member Author

KN4CK3R commented Jun 25, 2021

git check-attr is the correct tool.

Yes, the correct tool but it does not work with bare repos. See https://gitlab.com/gitlab-org/gitlab-foss/-/issues/2315#note_3339982 and the following posts.

@zeripath
Copy link
Contributor

zeripath commented Jun 26, 2021

git check-attr is the correct tool.

Yes, the correct tool but it does not work with bare repos. See https://gitlab.com/gitlab-org/gitlab-foss/-/issues/2315#note_3339982 and the following posts.

False. We already use git check-attr in bare repositories and have done for 2 YEARS.

Please look at:

https://github.com/go-gitea/gitea/blob/main/modules/git/repo_attribute.go

There is already an aborted partial attempt at getting the language from the repo attributes in #14833 which is almost there and if I wasn't so busy fixing other things I'd have fixed it and had it already.

@KN4CK3R
Copy link
Member Author

KN4CK3R commented Jun 26, 2021

Cool, don't know why it didn't work for me yesterday 🤷‍♂️
I added a new version of this PR which uses check-attr. The copy of the .gitattributes skips the creation of a temporary index.

@lafriks
Copy link
Member

lafriks commented Aug 10, 2021

It should also check enry.IsGenerated

zeripath added a commit that referenced this pull request Sep 9, 2021
…guage stats and diffs (#16773)

Replaces #16262
Replaces #16250
Replaces #14833

This PR first implements a `git check-attr` pipe reader - using `git check-attr --stdin -z --cached` - taking account of the change in the output format in git 1.8.5 and creates a helper function to read a tree into a temporary index file for that pipe reader.

It then wires this in to the language stats helper and into the git diff generation.

Files which are marked generated will be folded by default.

Fixes #14786
Fixes #12653
@6543
Copy link
Member

6543 commented Sep 10, 2021

replaced by #16773

@6543 6543 closed this Sep 10, 2021
@KN4CK3R KN4CK3R deleted the feature-gitattributes branch September 12, 2021 15:46
@go-gitea go-gitea locked and limited conversation to collaborators Oct 19, 2021
@a1012112796 a1012112796 removed this from the 1.16.0 milestone Dec 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. 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.

[Feature] Ability to exclude files from diffs
7 participants