mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-17 10:46:10 +02:00
refactor: decouple git.Repository(ctx) from git.Commit & git.Tree (#38464)
1. Storing "ctx" in a long-living object is wrong 2. Make the commit & tree cacheable (for the future performance optimization) 3. Also fix some bad designs like `// FIXME: bad design, this field can be nil if the commit is from "last commit cache"` ref: * #33893
This commit is contained in:
@@ -20,7 +20,7 @@ type SubmoduleDiffInfo struct {
|
||||
PreviousRefID string
|
||||
}
|
||||
|
||||
func (si *SubmoduleDiffInfo) PopulateURL(repoLink string, diffFile *DiffFile, leftCommit, rightCommit *git.Commit) {
|
||||
func (si *SubmoduleDiffInfo) PopulateURL(ctx context.Context, repoLink string, gitRepo *git.Repository, diffFile *DiffFile, leftCommit, rightCommit *git.Commit) {
|
||||
si.SubmoduleName = diffFile.Name
|
||||
submoduleCommit := rightCommit // If the submodule is added or updated, check at the right commit
|
||||
if diffFile.IsDeleted {
|
||||
@@ -31,7 +31,7 @@ func (si *SubmoduleDiffInfo) PopulateURL(repoLink string, diffFile *DiffFile, le
|
||||
}
|
||||
|
||||
submoduleFullPath := diffFile.GetDiffFileName()
|
||||
submodule, err := submoduleCommit.GetSubModule(submoduleFullPath)
|
||||
submodule, err := submoduleCommit.GetSubModule(ctx, gitRepo, submoduleFullPath)
|
||||
if err != nil {
|
||||
log.Error("Unable to PopulateURL for submodule %q: GetSubModule: %v", submoduleFullPath, err)
|
||||
return // ignore the error, do not cause 500 errors for end users
|
||||
|
||||
Reference in New Issue
Block a user