diff options
author | zeripath <art27@cantab.net> | 2021-06-02 13:03:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-02 13:03:59 +0100 |
commit | 9fdda9008534c53e399adc36fe1a880bbe41ce56 (patch) | |
tree | 9f18db9ee4b53ef7c6af22337b17c456d97abf7f /routers/org | |
parent | 894742278154781ba4cb347ac4c7efd7d6dcd1c8 (diff) | |
download | gitea-9fdda9008534c53e399adc36fe1a880bbe41ce56.tar.gz gitea-9fdda9008534c53e399adc36fe1a880bbe41ce56.zip |
Fix case change in ownernames (#16045)
If you change the case of a username the change needs to be propagated to their
repositories.
Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'routers/org')
-rw-r--r-- | routers/org/setting.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/routers/org/setting.go b/routers/org/setting.go index e7995fe8fa..0e28a93ace 100644 --- a/routers/org/setting.go +++ b/routers/org/setting.go @@ -52,6 +52,7 @@ func SettingsPost(ctx *context.Context) { } org := ctx.Org.Organization + nameChanged := org.Name != form.Name // Check if organization name has been changed. if org.LowerName != strings.ToLower(form.Name) { @@ -75,7 +76,9 @@ func SettingsPost(ctx *context.Context) { // reset ctx.org.OrgLink with new name ctx.Org.OrgLink = setting.AppSubURL + "/org/" + form.Name log.Trace("Organization name changed: %s -> %s", org.Name, form.Name) + nameChanged = false } + // In case it's just a case change. org.Name = form.Name org.LowerName = strings.ToLower(form.Name) @@ -105,11 +108,17 @@ func SettingsPost(ctx *context.Context) { return } for _, repo := range org.Repos { + repo.OwnerName = org.Name if err := models.UpdateRepository(repo, true); err != nil { ctx.ServerError("UpdateRepository", err) return } } + } else if nameChanged { + if err := models.UpdateRepositoryOwnerNames(org.ID, org.Name); err != nil { + ctx.ServerError("UpdateRepository", err) + return + } } log.Trace("Organization setting updated: %s", org.Name) |