aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/repo/search.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/web/repo/search.go')
-rw-r--r--routers/web/repo/search.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/routers/web/repo/search.go b/routers/web/repo/search.go
index d589586dad..bbbe5c1081 100644
--- a/routers/web/repo/search.go
+++ b/routers/web/repo/search.go
@@ -67,10 +67,11 @@ func Search(ctx *context.Context) {
ctx.Data["CodeIndexerUnavailable"] = !code_indexer.IsAvailable(ctx)
}
} else {
+ searchRefName := git.RefNameFromBranch(ctx.Repo.Repository.DefaultBranch) // BranchName should be default branch or the first existing branch
res, err := git.GrepSearch(ctx, ctx.Repo.GitRepo, prepareSearch.Keyword, git.GrepOptions{
ContextLineNumber: 1,
IsFuzzy: prepareSearch.IsFuzzy,
- RefName: git.RefNameFromBranch(ctx.Repo.Repository.DefaultBranch).String(), // BranchName should be default branch or the first existing branch
+ RefName: searchRefName.String(),
PathspecList: indexSettingToGitGrepPathspecList(),
})
if err != nil {
@@ -78,6 +79,11 @@ func Search(ctx *context.Context) {
ctx.ServerError("GrepSearch", err)
return
}
+ commitID, err := ctx.Repo.GitRepo.GetRefCommitID(searchRefName.String())
+ if err != nil {
+ ctx.ServerError("GetRefCommitID", err)
+ return
+ }
total = len(res)
pageStart := min((page-1)*setting.UI.RepoSearchPagingNum, len(res))
pageEnd := min(page*setting.UI.RepoSearchPagingNum, len(res))
@@ -86,7 +92,7 @@ func Search(ctx *context.Context) {
searchResults = append(searchResults, &code_indexer.Result{
RepoID: ctx.Repo.Repository.ID,
Filename: r.Filename,
- CommitID: ctx.Repo.CommitID,
+ CommitID: commitID,
// UpdatedUnix: not supported yet
// Language: not supported yet
// Color: not supported yet