aboutsummaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-06-02 17:56:32 +0100
committerGitHub <noreply@github.com>2022-06-02 12:56:32 -0400
commite32ab429ffd863f26d2ea884307bcf2c7064d209 (patch)
treef1b52fc46b6e6bab0cbf59b7056d3783d20851c0 /services
parent6171ea7d318c0ca8714bc6efd6a97ea4b495eb6d (diff)
downloadgitea-e32ab429ffd863f26d2ea884307bcf2c7064d209.tar.gz
gitea-e32ab429ffd863f26d2ea884307bcf2c7064d209.zip
Prevent NPE on update mirror settings (#19864)
A `repo_model.Mirror` repository field (`.Repo`) will not automatically be set, but is used without checking in mirror_pull.go:UpdateAddress. This will cause an NPE. This PR changes UpdateAddress to use the helper function GetRepository() helping prevent future NPEs but also changes modules/context/repo.go to ensure that the Mirror.Repo is set. Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'services')
-rw-r--r--services/mirror/mirror_pull.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/services/mirror/mirror_pull.go b/services/mirror/mirror_pull.go
index c51483821b..a93aee76cf 100644
--- a/services/mirror/mirror_pull.go
+++ b/services/mirror/mirror_pull.go
@@ -32,7 +32,7 @@ const gitShortEmptySha = "0000000"
// UpdateAddress writes new address to Git repository and database
func UpdateAddress(ctx context.Context, m *repo_model.Mirror, addr string) error {
remoteName := m.GetRemoteName()
- repoPath := m.Repo.RepoPath()
+ repoPath := m.GetRepository().RepoPath()
// Remove old remote
_, _, err := git.NewCommand(ctx, "remote", "rm", remoteName).RunStdString(&git.RunOpts{Dir: repoPath})
if err != nil && !strings.HasPrefix(err.Error(), "exit status 128 - fatal: No such remote ") {