mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-12 15:18:14 +00:00
refactor: make git package handle all git operations (#38543)
before: gitrepo vs git packages after: git package fully handle all git operations by the way, use `WithRepo(repo)` instead of `WithDir(repo.Path)` to hide path details. benefits: 1. remove all unnecessary wrappers, developers no need to struggle with "which package should be used" 2. simplify code, RepositoryFacade can (will) be used everywhere, all "path" details are (will be) hidden
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
git_model "gitea.dev/models/git"
|
||||
issues_model "gitea.dev/models/issues"
|
||||
"gitea.dev/modules/git"
|
||||
"gitea.dev/modules/git/gitcmd"
|
||||
"gitea.dev/modules/git/pipeline"
|
||||
"gitea.dev/modules/lfs"
|
||||
@@ -23,8 +24,8 @@ import (
|
||||
)
|
||||
|
||||
// LFSPush pushes lfs objects referred to in new commits in the head repository from the base repository
|
||||
func LFSPush(ctx context.Context, tmpBasePath, mergeHeadSHA, mergeBaseSHA string, pr *issues_model.PullRequest) error {
|
||||
// Now we have to implement git lfs push
|
||||
func LFSPush(ctx context.Context, tmpBasePath string, tmpRepo git.RepositoryFacade, mergeHeadSHA, mergeBaseSHA string, pr *issues_model.PullRequest) error {
|
||||
// Now we have to implement git-lfs push
|
||||
// git rev-list --objects --filter=blob:limit=1k HEAD --not base
|
||||
// pass blob shas in to git cat-file --batch-check (possibly unnecessary)
|
||||
// ensure only blobs and <=1k size then pass in to git cat-file --batch
|
||||
@@ -53,7 +54,7 @@ func LFSPush(ctx context.Context, tmpBasePath, mergeHeadSHA, mergeBaseSHA string
|
||||
|
||||
// 5. Take the shas of the blobs and batch read them
|
||||
wg.Go(func() error {
|
||||
return pipeline.CatFileBatch(ctx, cmd5BatchContent, tmpBasePath)
|
||||
return pipeline.CatFileBatch(ctx, cmd5BatchContent, tmpRepo)
|
||||
})
|
||||
|
||||
// 4. From the provided objects restrict to blobs <=1k
|
||||
|
||||
Reference in New Issue
Block a user