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

Feature: Find files in repo #15028

Merged
merged 36 commits into from
Jun 9, 2022
Merged

Feature: Find files in repo #15028

merged 36 commits into from
Jun 9, 2022

Conversation

rogerluo410
Copy link
Contributor

Find files for the specified branch in repo.

Issue for the feature:
#766

find-files

@jolheiser jolheiser added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Mar 18, 2021
@jolheiser jolheiser added this to the 1.15.0 milestone Mar 18, 2021
web_src/js/index.js Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 18, 2021
web_src/js/index.js Outdated Show resolved Hide resolved
web_src/js/index.js Outdated Show resolved Hide resolved
@lafriks
Copy link
Member

lafriks commented Mar 19, 2021

Imho it will be quite performance killer for large repositories, imho filtering should be done server side using ui something like github

@KN4CK3R
Copy link
Member

KN4CK3R commented Mar 19, 2021

Imho it will be quite performance killer for large repositories, imho filtering should be done server side using ui something like github

Github doesn't filter server side. On pageload there is a JSON request which returns all files of the repository. I noticed that the vendor directory is missing from the list but it doesn't look like they are using the .ignore file for this.

@silverwind
Copy link
Member

I noticed that the vendor directory is missing from the list but it doesn't look like they are using the .ignore file for this.

It's probably the linguist attributes:

gitea/.gitattributes

Lines 2 to 3 in 54d7b0f

/vendor/** -text -eol linguist-vendored
/public/vendor/** -text -eol linguist-vendored

Not sure how far we are for Gitea for the .gitattributes parsing but it'd certainly be nice if both it and maybe also .ignore could be applied in this search. But probably not worth to add it now if the infrastructure to parse such files is not present yet.

@KN4CK3R
Copy link
Member

KN4CK3R commented Mar 19, 2021

In https://github.com/go-gitea/lgtm the vendor directory is stripped too without .gitattributes or something. Maybe they have just a list of common excludes. I have created a vendor directory in a test repo and that was stripped too.

Edit: https://docs.github.com/en/github/searching-for-information-on-github/finding-files-on-github

@silverwind
Copy link
Member

Ugh, yeah if it's a hardcoded list, that's not going to be obvious. I suggest that if we do filtering based on files, either use .gitattributes or .ignore, ideally both.

@lafriks
Copy link
Member

lafriks commented Mar 19, 2021

we can easily use go-enry there is method enry.IsVendor("path/to/filename") to filter out them

@lafriks
Copy link
Member

lafriks commented Mar 19, 2021

Imho it will be quite performance killer for large repositories, imho filtering should be done server side using ui something like github

Github doesn't filter server side. On pageload there is a JSON request which returns all files of the repository. I noticed that the vendor directory is missing from the list but it doesn't look like they are using the .ignore file for this.

That's sounds more reasonable, as rendering all file list in html will be quite an overkill

routers/repo/find.go Outdated Show resolved Hide resolved
@lunny
Copy link
Member

lunny commented Mar 19, 2021

I think maybe the solution may have better performance.

On find file page, when loading, we can get all entries of currently tree via ajax and filter on frontend.

When input a /, we can load all entires below this trees and filter on frontend.

All entries will be cached on this page, so that if you delete a /, then no data loading is necessary.

@rogerluo410
Copy link
Contributor Author

In https://github.com/go-gitea/lgtm the vendor directory is stripped too without .gitattributes or something. Maybe they have just a list of common excludes. I have created a vendor directory in a test repo and that was stripped too.

Edit: https://docs.github.com/en/github/searching-for-information-on-github/finding-files-on-github

I noticed that the vendor directory is missing from the list but it doesn't look like they are using the .ignore file for this.

It's probably the linguist attributes:

gitea/.gitattributes

Lines 2 to 3 in 54d7b0f

/vendor/** -text -eol linguist-vendored
/public/vendor/** -text -eol linguist-vendored

Not sure how far we are for Gitea for the .gitattributes parsing but it'd certainly be nice if both it and maybe also .ignore could be applied in this search. But probably not worth to add it now if the infrastructure to parse such files is not present yet.

I didn't think much about excluded directories. That is really a problem.

So, what is the best solution of it?

If repo has .gitattributes or .ignore exists, we use them to exclude directories, otherwise, use hardcoded list to exclude instead ??

@silverwind
Copy link
Member

silverwind commented Mar 19, 2021

If repo has .gitattributes or .ignore exists, we use them to exclude directories, otherwise, use hardcoded list to exclude instead ??

I think just supporting .gitattributes via go-enry should be good enough for a start. Maybe it could be a feature request to go-enry to support .ignore as well for search ignores, e.g. enry.IsSearchIgnored("path/to/filename").

@rogerluo410
Copy link
Contributor Author

If repo has .gitattributes or .ignore exists, we use them to exclude directories, otherwise, use hardcoded list to exclude instead ??

I think just supporting .gitattributes via go-enry should be good enough for a start. Maybe it could be a feature request to go-enry to support .ignore as well for search ignores, e.g. enry.IsSearchIgnored("path/to/filename").

Ok, I will solve it, thank you.

@wxiaoguang wxiaoguang removed their assignment Jun 7, 2022
@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 Jun 8, 2022
@lunny
Copy link
Member

lunny commented Jun 8, 2022

@lafriks needs your review again.

routers/web/repo/treelist.go Outdated Show resolved Hide resolved
routers/web/repo/treelist.go Outdated Show resolved Hide resolved
routers/web/repo/treelist.go Show resolved Hide resolved
templates/repo/home.tmpl Show resolved Hide resolved
templates/repo/find/files.tmpl Outdated Show resolved Hide resolved
routers/web/repo/find.go Show resolved Hide resolved
web_src/js/features/repo-findfile.js Show resolved Hide resolved
web_src/js/utils.js Outdated Show resolved Hide resolved
templates/repo/find/files.tmpl Show resolved Hide resolved
web_src/js/features/repo-findfile.js Outdated Show resolved Hide resolved
@lafriks lafriks added the type/changelog Adds the changelog for a new Gitea version label Jun 9, 2022
@lafriks lafriks merged commit 2ae45ce into go-gitea:main Jun 9, 2022
zjjhot added a commit to zjjhot/gitea that referenced this pull request Jun 9, 2022
* giteaoffical/main:
  Feature: Find files in repo (go-gitea#15028)
@rempas
Copy link

rempas commented Jun 9, 2022

Finally, it is merged!!!! Personally thanks everyone that worked in the feature!!! You people are awesome!!! ❤️

AbdulrhmnGhanem pushed a commit to kitspace/gitea that referenced this pull request Aug 24, 2022
* Create finding files page ui in repo page

* Get tree entries for find repo files.

* Move find files JS to individual file.

* gen swagger.

* Add enry.IsVendor to exclude entries

Co-authored-by: delvh <[email protected]>
Co-authored-by: wxiaoguang <[email protected]>
Co-authored-by: Lunny Xiao <[email protected]>
6543 pushed a commit that referenced this pull request Sep 27, 2022
This (short) PR builds upon #15028 and makes the file search
case-insensitive.

Previously, having a file named `TestFile.cs` would not be shown if
`test` was typed in the search box.
This now changes the matching function to be case-insensitive (without
affecting the UI).

The matching function, `strSubMatch`, is only used for this feature (it
has been introduced by #15028), meaning that this PR does not affect the
behaviour of any unrelated functionality of Gitea.
@go-gitea go-gitea locked and limited conversation to collaborators May 3, 2023
@delvh delvh removed the type/changelog Adds the changelog for a new Gitea version label Oct 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/confirmed Issue has been reviewed and confirmed to be present or accepted to be implemented lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. 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.

Go to file functionality