mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-10 09:09:02 +00:00
Mirror: Update DB on Address-Update too (#12964)
* Mirror: Update DB on Address-Update too * new name for function to better describe
This commit is contained in:
parent
14e718695a
commit
4a654a8d44
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue