1
1
mirror of https://github.com/go-gitea/gitea synced 2025-08-03 08:08:36 +00:00

Use gitrepo.GetTreePathLatestCommit to get file lastest commit instead from latest commit cache (#32987) (#33046)

This commit is contained in:
Giteabot
2024-12-30 13:17:07 +08:00
committed by GitHub
parent 0858a36016
commit 610b2fb88d
4 changed files with 35 additions and 21 deletions

View File

@@ -11,7 +11,6 @@ import (
"fmt"
"io"
"net/http"
"path"
"strings"
"time"
@@ -242,19 +241,14 @@ func getBlobForEntry(ctx *context.APIContext) (blob *git.Blob, entry *git.TreeEn
return nil, nil, nil
}
info, _, err := git.Entries([]*git.TreeEntry{entry}).GetCommitsInfo(ctx, ctx.Repo.Commit, path.Dir("/" + ctx.Repo.TreePath)[1:])
latestCommit, err := ctx.Repo.GitRepo.GetTreePathLatestCommit(ctx.Repo.Commit.ID.String(), ctx.Repo.TreePath)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetCommitsInfo", err)
ctx.Error(http.StatusInternalServerError, "GetTreePathLatestCommit", err)
return nil, nil, nil
}
when := &latestCommit.Committer.When
if len(info) == 1 {
// Not Modified
lastModified = &info[0].Commit.Committer.When
}
blob = entry.Blob()
return blob, entry, lastModified
return entry.Blob(), entry, when
}
// GetArchive get archive of a repository