aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git/log_name_status.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-10-08 14:08:22 +0100
committerGitHub <noreply@github.com>2021-10-08 15:08:22 +0200
commit001dbf100de40f19c7ade5b8f013fbcccbe09ec3 (patch)
tree0b1a57f8efbb2e941fe4c344005a70ec76ad57d1 /modules/git/log_name_status.go
parent88fa9f3fb168bc6c9c2bdc6341b83bc048b38846 (diff)
downloadgitea-001dbf100de40f19c7ade5b8f013fbcccbe09ec3.tar.gz
gitea-001dbf100de40f19c7ade5b8f013fbcccbe09ec3.zip
Defer Last Commit Info (#16467)
One of the biggest reasons for slow repository browsing is that we wait until last commit information has been generated for all files in the repository. This PR proposes deferring this generation to a new POST endpoint that does the look up outside of the main page request. Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/git/log_name_status.go')
-rw-r--r--modules/git/log_name_status.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/modules/git/log_name_status.go b/modules/git/log_name_status.go
index 7d83ac7270..e792b02a5d 100644
--- a/modules/git/log_name_status.go
+++ b/modules/git/log_name_status.go
@@ -275,7 +275,9 @@ func (g *LogNameStatusRepoParser) Close() {
}
// WalkGitLog walks the git log --name-status for the head commit in the provided treepath and files
-func WalkGitLog(ctx context.Context, repo *Repository, head *Commit, treepath string, paths ...string) (map[string]string, error) {
+func WalkGitLog(ctx context.Context, cache *LastCommitCache, repo *Repository, head *Commit, treepath string, paths ...string) (map[string]string, error) {
+ headRef := head.ID.String()
+
tree, err := head.SubTree(treepath)
if err != nil {
return nil, err
@@ -339,6 +341,9 @@ heaploop:
for {
select {
case <-ctx.Done():
+ if ctx.Err() == context.DeadlineExceeded {
+ break heaploop
+ }
g.Close()
return nil, ctx.Err()
default:
@@ -360,10 +365,16 @@ heaploop:
changed[i] = false
if results[i] == "" {
results[i] = current.CommitID
+ if err := cache.Put(headRef, path.Join(treepath, paths[i]), current.CommitID); err != nil {
+ return nil, err
+ }
delete(path2idx, paths[i])
remaining--
if results[0] == "" {
results[0] = current.CommitID
+ if err := cache.Put(headRef, treepath, current.CommitID); err != nil {
+ return nil, err
+ }
delete(path2idx, "")
remaining--
}