aboutsummaryrefslogtreecommitdiffstats
path: root/models/repo.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-06-02 13:03:59 +0100
committerGitHub <noreply@github.com>2021-06-02 13:03:59 +0100
commit9fdda9008534c53e399adc36fe1a880bbe41ce56 (patch)
tree9f18db9ee4b53ef7c6af22337b17c456d97abf7f /models/repo.go
parent894742278154781ba4cb347ac4c7efd7d6dcd1c8 (diff)
downloadgitea-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 'models/repo.go')
-rw-r--r--models/repo.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/models/repo.go b/models/repo.go
index daa94c0d50..58a393ae70 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -1350,6 +1350,26 @@ func UpdateRepository(repo *Repository, visibilityChanged bool) (err error) {
return sess.Commit()
}
+// UpdateRepositoryOwnerNames updates repository owner_names (this should only be used when the ownerName has changed case)
+func UpdateRepositoryOwnerNames(ownerID int64, ownerName string) error {
+ if ownerID == 0 {
+ return nil
+ }
+ sess := x.NewSession()
+ defer sess.Close()
+ if err := sess.Begin(); err != nil {
+ return err
+ }
+
+ if _, err := sess.Where("owner_id = ?", ownerID).Cols("owner_name").Update(&Repository{
+ OwnerName: ownerName,
+ }); err != nil {
+ return err
+ }
+
+ return sess.Commit()
+}
+
// UpdateRepositoryUpdatedTime updates a repository's updated time
func UpdateRepositoryUpdatedTime(repoID int64, updateTime time.Time) error {
_, err := x.Exec("UPDATE repository SET updated_unix = ? WHERE id = ?", updateTime.Unix(), repoID)