forked from forgejo/forgejo
Even more db.DefaultContext
refactor (#27352)
Part of #27065 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: delvh <dev.lh@web.de>
This commit is contained in:
parent
08507e2760
commit
cc5df26680
97 changed files with 298 additions and 294 deletions
|
@ -54,7 +54,7 @@ func Update(ctx context.Context, pullLimit, pushLimit int) error {
|
|||
mirrorType = PullMirrorType
|
||||
referenceID = m.RepoID
|
||||
} else if m, ok := bean.(*repo_model.PushMirror); ok {
|
||||
if m.GetRepository() == nil {
|
||||
if m.GetRepository(ctx) == nil {
|
||||
log.Error("Disconnected push-mirror found: %d", m.ID)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
repo_model "code.gitea.io/gitea/models/repo"
|
||||
system_model "code.gitea.io/gitea/models/system"
|
||||
"code.gitea.io/gitea/modules/cache"
|
||||
|
@ -461,7 +460,7 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool {
|
|||
}
|
||||
defer gitRepo.Close()
|
||||
|
||||
if ok := checkAndUpdateEmptyRepository(m, gitRepo, results); !ok {
|
||||
if ok := checkAndUpdateEmptyRepository(ctx, m, gitRepo, results); !ok {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -550,7 +549,7 @@ func SyncPullMirror(ctx context.Context, repoID int64) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func checkAndUpdateEmptyRepository(m *repo_model.Mirror, gitRepo *git.Repository, results []*mirrorSyncResult) bool {
|
||||
func checkAndUpdateEmptyRepository(ctx context.Context, m *repo_model.Mirror, gitRepo *git.Repository, results []*mirrorSyncResult) bool {
|
||||
if !m.Repo.IsEmpty {
|
||||
return true
|
||||
}
|
||||
|
@ -601,7 +600,7 @@ func checkAndUpdateEmptyRepository(m *repo_model.Mirror, gitRepo *git.Repository
|
|||
}
|
||||
m.Repo.IsEmpty = false
|
||||
// Update the is empty and default_branch columns
|
||||
if err := repo_model.UpdateRepositoryCols(db.DefaultContext, m.Repo, "default_branch", "is_empty"); err != nil {
|
||||
if err := repo_model.UpdateRepositoryCols(ctx, m.Repo, "default_branch", "is_empty"); err != nil {
|
||||
log.Error("Failed to update default branch of repository %-v. Error: %v", m.Repo, err)
|
||||
desc := fmt.Sprintf("Failed to update default branch of repository '%s': %v", m.Repo.RepoPath(), err)
|
||||
if err = system_model.CreateRepositoryNotice(desc); err != nil {
|
||||
|
|
|
@ -65,7 +65,7 @@ func AddPushMirrorRemote(ctx context.Context, m *repo_model.PushMirror, addr str
|
|||
// RemovePushMirrorRemote removes the push mirror remote.
|
||||
func RemovePushMirrorRemote(ctx context.Context, m *repo_model.PushMirror) error {
|
||||
cmd := git.NewCommand(ctx, "remote", "rm").AddDynamicArguments(m.RemoteName)
|
||||
_ = m.GetRepository()
|
||||
_ = m.GetRepository(ctx)
|
||||
|
||||
if _, _, err := cmd.RunStdString(&git.RunOpts{Dir: m.Repo.RepoPath()}); err != nil {
|
||||
return err
|
||||
|
@ -99,7 +99,7 @@ func SyncPushMirror(ctx context.Context, mirrorID int64) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
_ = m.GetRepository()
|
||||
_ = m.GetRepository(ctx)
|
||||
|
||||
m.LastError = ""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue