mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Move almost all functions' parameter db.Engine to context.Context (#19748)
* Move almost all functions' parameter db.Engine to context.Context * remove some unnecessary wrap functions
This commit is contained in:
		| @@ -16,6 +16,7 @@ import ( | ||||
| 	"strings" | ||||
|  | ||||
| 	"code.gitea.io/gitea/models" | ||||
| 	"code.gitea.io/gitea/models/db" | ||||
| 	access_model "code.gitea.io/gitea/models/perm/access" | ||||
| 	repo_model "code.gitea.io/gitea/models/repo" | ||||
| 	unit_model "code.gitea.io/gitea/models/unit" | ||||
| @@ -116,7 +117,7 @@ type CanCommitToBranchResults struct { | ||||
| // CanCommitToBranch returns true if repository is editable and user has proper access level | ||||
| //   and branch is not protected for push | ||||
| func (r *Repository) CanCommitToBranch(ctx context.Context, doer *user_model.User) (CanCommitToBranchResults, error) { | ||||
| 	protectedBranch, err := models.GetProtectedBranchBy(r.Repository.ID, r.BranchName) | ||||
| 	protectedBranch, err := models.GetProtectedBranchBy(ctx, r.Repository.ID, r.BranchName) | ||||
| 	if err != nil { | ||||
| 		return CanCommitToBranchResults{}, err | ||||
| 	} | ||||
| @@ -159,7 +160,7 @@ func (r *Repository) CanUseTimetracker(issue *models.Issue, user *user_model.Use | ||||
| 	// Checking for following: | ||||
| 	// 1. Is timetracker enabled | ||||
| 	// 2. Is the user a contributor, admin, poster or assignee and do the repository policies require this? | ||||
| 	isAssigned, _ := models.IsUserAssignedToIssue(issue, user) | ||||
| 	isAssigned, _ := models.IsUserAssignedToIssue(db.DefaultContext, issue, user) | ||||
| 	return r.Repository.IsTimetrackerEnabled() && (!r.Repository.AllowOnlyContributorsToTrackTime() || | ||||
| 		r.Permission.CanWriteIssuesOrPulls(issue.IsPull) || issue.IsPoster(user.ID) || isAssigned) | ||||
| } | ||||
| @@ -278,7 +279,7 @@ func RetrieveBaseRepo(ctx *Context, repo *repo_model.Repository) { | ||||
| // RetrieveTemplateRepo retrieves template repository used to generate this repository | ||||
| func RetrieveTemplateRepo(ctx *Context, repo *repo_model.Repository) { | ||||
| 	// Non-generated repository will not return error in this method. | ||||
| 	templateRepo, err := repo_model.GetTemplateRepo(repo) | ||||
| 	templateRepo, err := repo_model.GetTemplateRepo(ctx, repo) | ||||
| 	if err != nil { | ||||
| 		if repo_model.IsErrRepoNotExist(err) { | ||||
| 			repo.TemplateID = 0 | ||||
| @@ -385,11 +386,12 @@ func repoAssignment(ctx *Context, repo *repo_model.Repository) { | ||||
| 			return | ||||
| 		} | ||||
| 		if finishedMigrating { | ||||
| 			ctx.Repo.Mirror, err = repo_model.GetMirrorByRepoID(repo.ID) | ||||
| 			ctx.Repo.Mirror, err = repo_model.GetMirrorByRepoID(ctx, repo.ID) | ||||
| 			if err != nil { | ||||
| 				ctx.ServerError("GetMirrorByRepoID", err) | ||||
| 				return | ||||
| 			} | ||||
| 			ctx.Repo.Mirror.Repo = ctx.Repo.Repository | ||||
| 			ctx.Data["MirrorEnablePrune"] = ctx.Repo.Mirror.EnablePrune | ||||
| 			ctx.Data["MirrorInterval"] = ctx.Repo.Mirror.Interval | ||||
| 			ctx.Data["Mirror"] = ctx.Repo.Mirror | ||||
| @@ -451,7 +453,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) { | ||||
| 	if ctx.IsSigned && ctx.Doer.LowerName == strings.ToLower(userName) { | ||||
| 		owner = ctx.Doer | ||||
| 	} else { | ||||
| 		owner, err = user_model.GetUserByName(userName) | ||||
| 		owner, err = user_model.GetUserByName(ctx, userName) | ||||
| 		if err != nil { | ||||
| 			if user_model.IsErrUserNotExist(err) { | ||||
| 				if ctx.FormString("go-get") == "1" { | ||||
| @@ -587,7 +589,7 @@ func RepoAssignment(ctx *Context) (cancel context.CancelFunc) { | ||||
|  | ||||
| 	if ctx.IsSigned { | ||||
| 		ctx.Data["IsWatchingRepo"] = repo_model.IsWatching(ctx.Doer.ID, repo.ID) | ||||
| 		ctx.Data["IsStaringRepo"] = repo_model.IsStaring(ctx.Doer.ID, repo.ID) | ||||
| 		ctx.Data["IsStaringRepo"] = repo_model.IsStaring(ctx, ctx.Doer.ID, repo.ID) | ||||
| 	} | ||||
|  | ||||
| 	if repo.IsFork { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user