[FEAT] support searching non default branches/tags when using git-grep (#3654)
resolves https://codeberg.org/forgejo/forgejo/pulls/3639#issuecomment-1806676 and https://codeberg.org/forgejo/forgejo/pulls/3513#issuecomment-1794990 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3654 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Shiny Nematoda <snematoda.751k2@aleeas.com> Co-committed-by: Shiny Nematoda <snematoda.751k2@aleeas.com>
This commit is contained in:
parent
9b4452fd7b
commit
b6ca8abcfd
9 changed files with 101 additions and 26 deletions
|
@ -64,7 +64,11 @@ func Search(ctx *context.Context) {
|
|||
ctx.Data["CodeIndexerUnavailable"] = !code_indexer.IsAvailable(ctx)
|
||||
}
|
||||
} else {
|
||||
res, err := git.GrepSearch(ctx, ctx.Repo.GitRepo, keyword, git.GrepOptions{ContextLineNumber: 3, IsFuzzy: isFuzzy})
|
||||
res, err := git.GrepSearch(ctx, ctx.Repo.GitRepo, keyword, git.GrepOptions{
|
||||
ContextLineNumber: 1,
|
||||
IsFuzzy: isFuzzy,
|
||||
RefName: ctx.Repo.RefName,
|
||||
})
|
||||
if err != nil {
|
||||
ctx.ServerError("GrepSearch", err)
|
||||
return
|
||||
|
|
|
@ -1140,6 +1140,7 @@ PostRecentBranchCheck:
|
|||
ctx.Data["TreeLink"] = treeLink
|
||||
ctx.Data["TreeNames"] = treeNames
|
||||
ctx.Data["BranchLink"] = branchLink
|
||||
ctx.Data["CodeIndexerDisabled"] = !setting.Indexer.RepoIndexerEnabled
|
||||
ctx.HTML(http.StatusOK, tplRepoHome)
|
||||
}
|
||||
|
||||
|
|
|
@ -1570,11 +1570,17 @@ func registerRoutes(m *web.Route) {
|
|||
|
||||
m.Group("/{username}/{reponame}", func() {
|
||||
if !setting.Repository.DisableStars {
|
||||
m.Get("/stars", repo.Stars)
|
||||
m.Get("/stars", context.RepoRef(), repo.Stars)
|
||||
}
|
||||
m.Get("/watchers", repo.Watchers)
|
||||
m.Get("/search", reqRepoCodeReader, repo.Search)
|
||||
}, ignSignIn, context.RepoAssignment, context.RepoRef(), context.UnitTypes())
|
||||
m.Get("/watchers", context.RepoRef(), repo.Watchers)
|
||||
m.Group("/search", func() {
|
||||
m.Get("", context.RepoRef(), repo.Search)
|
||||
if !setting.Indexer.RepoIndexerEnabled {
|
||||
m.Get("/branch/*", context.RepoRefByType(context.RepoRefBranch), repo.Search)
|
||||
m.Get("/tag/*", context.RepoRefByType(context.RepoRefTag), repo.Search)
|
||||
}
|
||||
}, reqRepoCodeReader)
|
||||
}, ignSignIn, context.RepoAssignment, context.UnitTypes())
|
||||
|
||||
m.Group("/{username}", func() {
|
||||
m.Group("/{reponame}", func() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue