aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-09-28 21:00:52 +0200
committerGitHub <noreply@github.com>2020-09-28 15:00:52 -0400
commit4a654a8d44bf4b0dc9ab1bf850be68f73b25e5cd (patch)
tree275810fd57012920f583eaadb2281283683576bd
parent14e718695a999be199b61b57d60e9760d70ef439 (diff)
downloadgitea-4a654a8d44bf4b0dc9ab1bf850be68f73b25e5cd.tar.gz
gitea-4a654a8d44bf4b0dc9ab1bf850be68f73b25e5cd.zip
Mirror: Update DB on Address-Update too (#12964)
* Mirror: Update DB on Address-Update too * new name for function to better describe
-rw-r--r--routers/repo/setting.go4
-rw-r--r--services/mirror/mirror.go8
2 files changed, 7 insertions, 5 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index 865dea9bca..ca222375fb 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -202,8 +202,8 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
address = u.String()
- if err := mirror_service.SaveAddress(ctx.Repo.Mirror, address); err != nil {
- ctx.ServerError("SaveAddress", err)
+ if err := mirror_service.UpdateAddress(ctx.Repo.Mirror, address); err != nil {
+ ctx.ServerError("UpdateAddress", err)
return
}
diff --git a/services/mirror/mirror.go b/services/mirror/mirror.go
index da794ea585..5eafdab38d 100644
--- a/services/mirror/mirror.go
+++ b/services/mirror/mirror.go
@@ -89,8 +89,8 @@ func AddressNoCredentials(m *models.Mirror) string {
return u.String()
}
-// SaveAddress writes new address to Git repository config.
-func SaveAddress(m *models.Mirror, addr string) error {
+// UpdateAddress writes new address to Git repository and database
+func UpdateAddress(m *models.Mirror, addr string) error {
repoPath := m.Repo.RepoPath()
// Remove old origin
_, err := git.NewCommand("remote", "rm", "origin").RunInDir(repoPath)
@@ -117,7 +117,9 @@ func SaveAddress(m *models.Mirror, addr string) error {
return err
}
}
- return nil
+
+ m.Repo.OriginalURL = addr
+ return models.UpdateRepositoryCols(m.Repo, "original_url")
}
// gitShortEmptySha Git short empty SHA