Skip to content

Commit c56c25a

Browse files
committed
Restore setting of ctx.Repo.Mirror
In go-gitea#17933 repoAssignment no longer sets the ctx.Repo.Mirror field meaning that attempting change mirror settings results in an NPE. This PR simply restores this. Either we should remove this field or, we should set it. At present it seems simplest to set it instead of going looking in the Data for the value although converting the context to a bag of things may be the correct approach in the future. Fix go-gitea#18204 Signed-off-by: Andrew Thornton <[email protected]>
1 parent 3dbdf36 commit c56c25a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

modules/context/repo.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,14 +366,14 @@ func repoAssignment(ctx *Context, repo *repo_model.Repository) {
366366

367367
if repo.IsMirror {
368368
var err error
369-
mirror, err := repo_model.GetMirrorByRepoID(repo.ID)
369+
ctx.Repo.Mirror, err = repo_model.GetMirrorByRepoID(repo.ID)
370370
if err != nil {
371371
ctx.ServerError("GetMirrorByRepoID", err)
372372
return
373373
}
374-
ctx.Data["MirrorEnablePrune"] = mirror.EnablePrune
375-
ctx.Data["MirrorInterval"] = mirror.Interval
376-
ctx.Data["Mirror"] = mirror
374+
ctx.Data["MirrorEnablePrune"] = ctx.Repo.Mirror.EnablePrune
375+
ctx.Data["MirrorInterval"] = ctx.Repo.Mirror.Interval
376+
ctx.Data["Mirror"] = ctx.Repo.Mirror
377377
}
378378

379379
pushMirrors, err := repo_model.GetPushMirrorsByRepoID(repo.ID)

0 commit comments

Comments
 (0)