Penultimate round of db.DefaultContext
refactor (#27414)
Part of #27065 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
@ -83,7 +83,7 @@ func parseScope(ctx *context.PrivateContext, scope string) (ownerID, repoID int6
|
||||
return ownerID, repoID, nil
|
||||
}
|
||||
|
||||
r, err := repo_model.GetRepositoryByName(u.ID, repoName)
|
||||
r, err := repo_model.GetRepositoryByName(ctx, u.ID, repoName)
|
||||
if err != nil {
|
||||
return ownerID, repoID, err
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
|
||||
}
|
||||
|
||||
results = append(results, private.HookPostReceiveBranchResult{
|
||||
Message: setting.Git.PullRequestPushMessage && repo.AllowsPulls(),
|
||||
Message: setting.Git.PullRequestPushMessage && repo.AllowsPulls(ctx),
|
||||
Create: false,
|
||||
Branch: "",
|
||||
URL: fmt.Sprintf("%s/pulls/%d", repo.HTMLURL(), pr.Index),
|
||||
@ -179,12 +179,12 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
|
||||
})
|
||||
return
|
||||
}
|
||||
if repo.BaseRepo.AllowsPulls() {
|
||||
if repo.BaseRepo.AllowsPulls(ctx) {
|
||||
baseRepo = repo.BaseRepo
|
||||
}
|
||||
}
|
||||
|
||||
if !baseRepo.AllowsPulls() {
|
||||
if !baseRepo.AllowsPulls(ctx) {
|
||||
// We can stop there's no need to go any further
|
||||
ctx.JSON(http.StatusOK, private.HookPostReceiveResult{
|
||||
RepoWasEmpty: wasEmpty,
|
||||
@ -217,14 +217,14 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
|
||||
branch = fmt.Sprintf("%s:%s", repo.OwnerName, branch)
|
||||
}
|
||||
results = append(results, private.HookPostReceiveBranchResult{
|
||||
Message: setting.Git.PullRequestPushMessage && baseRepo.AllowsPulls(),
|
||||
Message: setting.Git.PullRequestPushMessage && baseRepo.AllowsPulls(ctx),
|
||||
Create: true,
|
||||
Branch: branch,
|
||||
URL: fmt.Sprintf("%s/compare/%s...%s", baseRepo.HTMLURL(), util.PathEscapeSegments(baseRepo.DefaultBranch), util.PathEscapeSegments(branch)),
|
||||
})
|
||||
} else {
|
||||
results = append(results, private.HookPostReceiveBranchResult{
|
||||
Message: setting.Git.PullRequestPushMessage && baseRepo.AllowsPulls(),
|
||||
Message: setting.Git.PullRequestPushMessage && baseRepo.AllowsPulls(ctx),
|
||||
Create: false,
|
||||
Branch: branch,
|
||||
URL: fmt.Sprintf("%s/pulls/%d", baseRepo.HTMLURL(), pr.Index),
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
func UpdatePublicKeyInRepo(ctx *context.PrivateContext) {
|
||||
keyID := ctx.ParamsInt64(":id")
|
||||
repoID := ctx.ParamsInt64(":repoid")
|
||||
if err := asymkey_model.UpdatePublicKeyUpdated(keyID); err != nil {
|
||||
if err := asymkey_model.UpdatePublicKeyUpdated(ctx, keyID); err != nil {
|
||||
ctx.JSON(http.StatusInternalServerError, private.Response{
|
||||
Err: err.Error(),
|
||||
})
|
||||
|
@ -33,7 +33,7 @@ func ServNoCommand(ctx *context.PrivateContext) {
|
||||
}
|
||||
results := private.KeyAndOwner{}
|
||||
|
||||
key, err := asymkey_model.GetPublicKeyByID(keyID)
|
||||
key, err := asymkey_model.GetPublicKeyByID(ctx, keyID)
|
||||
if err != nil {
|
||||
if asymkey_model.IsErrKeyNotExist(err) {
|
||||
ctx.JSON(http.StatusUnauthorized, private.Response{
|
||||
@ -132,7 +132,7 @@ func ServCommand(ctx *context.PrivateContext) {
|
||||
|
||||
// Now get the Repository and set the results section
|
||||
repoExist := true
|
||||
repo, err := repo_model.GetRepositoryByName(owner.ID, results.RepoName)
|
||||
repo, err := repo_model.GetRepositoryByName(ctx, owner.ID, results.RepoName)
|
||||
if err != nil {
|
||||
if repo_model.IsErrRepoNotExist(err) {
|
||||
repoExist = false
|
||||
@ -184,7 +184,7 @@ func ServCommand(ctx *context.PrivateContext) {
|
||||
}
|
||||
|
||||
// Get the Public Key represented by the keyID
|
||||
key, err := asymkey_model.GetPublicKeyByID(keyID)
|
||||
key, err := asymkey_model.GetPublicKeyByID(ctx, keyID)
|
||||
if err != nil {
|
||||
if asymkey_model.IsErrKeyNotExist(err) {
|
||||
ctx.JSON(http.StatusNotFound, private.Response{
|
||||
|
Reference in New Issue
Block a user