Skip to content

Commit

Permalink
Restore setting of ctx.Repo.Mirror (go-gitea#18205)
Browse files Browse the repository at this point in the history
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 <art27@cantab.net>

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
  • Loading branch information
2 people authored and Stelios Malathouras committed Mar 28, 2022
1 parent 352d733 commit c071b6c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions modules/context/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,14 +366,14 @@ func repoAssignment(ctx *Context, repo *repo_model.Repository) {

if repo.IsMirror {
var err error
mirror, err := repo_model.GetMirrorByRepoID(repo.ID)
ctx.Repo.Mirror, err = repo_model.GetMirrorByRepoID(repo.ID)
if err != nil {
ctx.ServerError("GetMirrorByRepoID", err)
return
}
ctx.Data["MirrorEnablePrune"] = mirror.EnablePrune
ctx.Data["MirrorInterval"] = mirror.Interval
ctx.Data["Mirror"] = mirror
ctx.Data["MirrorEnablePrune"] = ctx.Repo.Mirror.EnablePrune
ctx.Data["MirrorInterval"] = ctx.Repo.Mirror.Interval
ctx.Data["Mirror"] = ctx.Repo.Mirror
}

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

0 comments on commit c071b6c

Please sign in to comment.