From: James Moger Date: Wed, 10 Oct 2012 21:05:00 +0000 (-0400) Subject: Fixed bug where repository ownership was not updated on rename user X-Git-Tag: v1.2.0~169 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=17363c3957dab02bf8a5ab3a89dcace147c4f20e;p=gitblit.git Fixed bug where repository ownership was not updated on rename user --- diff --git a/docs/04_releases.mkd b/docs/04_releases.mkd index 416aebed..aad6463f 100644 --- a/docs/04_releases.mkd +++ b/docs/04_releases.mkd @@ -11,6 +11,7 @@ If you are updating from an earlier release AND you have indexed branches with t #### fixes +- Fixed bug where repository ownership was not updated on rename user - Fixed bug in create/rename repository if you explicitly specified the alias for the root group (e.g. main/myrepo) (issue 143) - Wrapped Markdown parser with improved exception handler (issue 142) - Fixed duplicate entries in repository cache (issue 140) diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java index 8c6d9eba..bf9b1ed1 100644 --- a/src/com/gitblit/GitBlit.java +++ b/src/com/gitblit/GitBlit.java @@ -642,6 +642,22 @@ public class GitBlit implements ServletContextListener { "Failed to rename ''{0}'' because ''{1}'' already exists.", username, user.username)); } + + // rename repositories and owner fields for all repositories + for (RepositoryModel model : getRepositoryModels(user)) { + if (model.isUsersPersonalRepository(username)) { + // personal repository + model.owner = user.username; + String oldRepositoryName = model.name; + model.name = "~" + user.username + model.name.substring(model.projectPath.length()); + model.projectPath = "~" + user.username; + updateRepositoryModel(oldRepositoryName, model, false); + } else if (model.isOwner(username)) { + // common/shared repo + model.owner = user.username; + updateRepositoryModel(model.name, model, false); + } + } } if (!userService.updateUserModel(username, user)) { throw new GitBlitException(isCreate ? "Failed to add user!" : "Failed to update user!");