aboutsummaryrefslogtreecommitdiffstats
path: root/models/repo/repo.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-05-21 23:13:47 +0800
committerGitHub <noreply@github.com>2023-05-21 23:13:47 +0800
commitc59a057297c782f44a81a3e630b5094a58099edb (patch)
tree58c3020b0da9755fa769619bb3ad80e656f25cd9 /models/repo/repo.go
parent64f6a5d113da0d5d187752c9398d6e8d22d24b79 (diff)
downloadgitea-c59a057297c782f44a81a3e630b5094a58099edb.tar.gz
gitea-c59a057297c782f44a81a3e630b5094a58099edb.zip
Refactor rename user and rename organization (#24052)
This PR is a refactor at the beginning. And now it did 4 things. - [x] Move renaming organizaiton and user logics into services layer and merged as one function - [x] Support rename a user capitalization only. For example, rename the user from `Lunny` to `lunny`. We just need to change one table `user` and others should not be touched. - [x] Before this PR, some renaming were missed like `agit` - [x] Fix bug the API reutrned from `http.StatusNoContent` to `http.StatusOK`
Diffstat (limited to 'models/repo/repo.go')
-rw-r--r--models/repo/repo.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/models/repo/repo.go b/models/repo/repo.go
index 00e875407c..bcf8e5bbe8 100644
--- a/models/repo/repo.go
+++ b/models/repo/repo.go
@@ -832,3 +832,11 @@ func FixNullArchivedRepository(ctx context.Context) (int64, error) {
IsArchived: false,
})
}
+
+// UpdateRepositoryOwnerName updates the owner name of all repositories owned by the user
+func UpdateRepositoryOwnerName(ctx context.Context, oldUserName, newUserName string) error {
+ if _, err := db.GetEngine(ctx).Exec("UPDATE `repository` SET owner_name=? WHERE owner_name=?", newUserName, oldUserName); err != nil {
+ return fmt.Errorf("change repo owner name: %w", err)
+ }
+ return nil
+}