loading up the forgejo repo on tangled to test page performance
at forgejo 46 lines 1.2 kB view raw
1// Copyright 2024 The Gitea Authors. All rights reserved. 2// SPDX-License-Identifier: MIT 3 4package git 5 6import ( 7 "bufio" 8 "context" 9) 10 11type Batch struct { 12 cancel context.CancelFunc 13 Reader *bufio.Reader 14 Writer WriteCloserError 15} 16 17func (repo *Repository) NewBatch(ctx context.Context) (*Batch, error) { 18 // Now because of some insanity with git cat-file not immediately failing if not run in a valid git directory we need to run git rev-parse first! 19 if err := ensureValidGitRepository(ctx, repo.Path); err != nil { 20 return nil, err 21 } 22 23 var batch Batch 24 batch.Writer, batch.Reader, batch.cancel = catFileBatch(ctx, repo.Path) 25 return &batch, nil 26} 27 28func (repo *Repository) NewBatchCheck(ctx context.Context) (*Batch, error) { 29 // Now because of some insanity with git cat-file not immediately failing if not run in a valid git directory we need to run git rev-parse first! 30 if err := ensureValidGitRepository(ctx, repo.Path); err != nil { 31 return nil, err 32 } 33 34 var check Batch 35 check.Writer, check.Reader, check.cancel = catFileBatchCheck(ctx, repo.Path) 36 return &check, nil 37} 38 39func (b *Batch) Close() { 40 if b.cancel != nil { 41 b.cancel() 42 b.Reader = nil 43 b.Writer = nil 44 b.cancel = nil 45 } 46}