]> source.dussan.org Git - gitblit.git/commitdiff
Fixed bug where repository ownership was not updated on rename user
authorJames Moger <james.moger@gitblit.com>
Wed, 10 Oct 2012 21:05:00 +0000 (17:05 -0400)
committerJames Moger <james.moger@gitblit.com>
Wed, 10 Oct 2012 21:05:00 +0000 (17:05 -0400)
docs/04_releases.mkd
src/com/gitblit/GitBlit.java

index 416aebedc3f59dd6ae736ad7dd3ddbe16c7ab88f..aad6463f5faddd5d168ac7a29e06bc135f7c56a4 100644 (file)
@@ -11,6 +11,7 @@ If you are updating from an earlier release AND you have indexed branches with t
 \r
 #### fixes\r
 \r
+- Fixed bug where repository ownership was not updated on rename user\r
 - Fixed bug in create/rename repository if you explicitly specified the alias for the root group (e.g. main/myrepo) (issue 143)\r
 - Wrapped Markdown parser with improved exception handler (issue 142)\r
 - Fixed duplicate entries in repository cache (issue 140)\r
index 8c6d9ebaed4d979420b4f856a31cc0cfa8e74f39..bf9b1ed1ce21420f1a9776cbfd1b6b63e33e1d02 100644 (file)
@@ -642,6 +642,22 @@ public class GitBlit implements ServletContextListener {
                                                "Failed to rename ''{0}'' because ''{1}'' already exists.", username,\r
                                                user.username));\r
                        }\r
+                       \r
+                       // rename repositories and owner fields for all repositories\r
+                       for (RepositoryModel model : getRepositoryModels(user)) {\r
+                               if (model.isUsersPersonalRepository(username)) {\r
+                                       // personal repository\r
+                                       model.owner = user.username;\r
+                                       String oldRepositoryName = model.name;\r
+                                       model.name = "~" + user.username + model.name.substring(model.projectPath.length());\r
+                                       model.projectPath = "~" + user.username;\r
+                                       updateRepositoryModel(oldRepositoryName, model, false);\r
+                               } else if (model.isOwner(username)) {\r
+                                       // common/shared repo\r
+                                       model.owner = user.username;\r
+                                       updateRepositoryModel(model.name, model, false);\r
+                               }\r
+                       }\r
                }\r
                if (!userService.updateUserModel(username, user)) {\r
                        throw new GitBlitException(isCreate ? "Failed to add user!" : "Failed to update user!");\r