Skip to content

Commit 4a654a8

Browse files
authored
Mirror: Update DB on Address-Update too (#12964)
* Mirror: Update DB on Address-Update too * new name for function to better describe
1 parent 14e7186 commit 4a654a8

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

routers/repo/setting.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
202202

203203
address = u.String()
204204

205-
if err := mirror_service.SaveAddress(ctx.Repo.Mirror, address); err != nil {
206-
ctx.ServerError("SaveAddress", err)
205+
if err := mirror_service.UpdateAddress(ctx.Repo.Mirror, address); err != nil {
206+
ctx.ServerError("UpdateAddress", err)
207207
return
208208
}
209209

services/mirror/mirror.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ func AddressNoCredentials(m *models.Mirror) string {
8989
return u.String()
9090
}
9191

92-
// SaveAddress writes new address to Git repository config.
93-
func SaveAddress(m *models.Mirror, addr string) error {
92+
// UpdateAddress writes new address to Git repository and database
93+
func UpdateAddress(m *models.Mirror, addr string) error {
9494
repoPath := m.Repo.RepoPath()
9595
// Remove old origin
9696
_, err := git.NewCommand("remote", "rm", "origin").RunInDir(repoPath)
@@ -117,7 +117,9 @@ func SaveAddress(m *models.Mirror, addr string) error {
117117
return err
118118
}
119119
}
120-
return nil
120+
121+
m.Repo.OriginalURL = addr
122+
return models.UpdateRepositoryCols(m.Repo, "original_url")
121123
}
122124

123125
// gitShortEmptySha Git short empty SHA

0 commit comments

Comments
 (0)