]> source.dussan.org Git - gitblit.git/commitdiff
Ensure the repository model ref list is refreshed on ref creation or deletion 54/54/1
authorJames Moger <james.moger@gitblit.com>
Wed, 7 May 2014 14:27:14 +0000 (10:27 -0400)
committerJames Moger <james.moger@gitblit.com>
Wed, 7 May 2014 14:27:14 +0000 (10:27 -0400)
releases.moxie
src/main/java/com/gitblit/git/GitblitReceivePack.java
src/main/java/com/gitblit/manager/GitblitManager.java
src/main/java/com/gitblit/manager/IRepositoryManager.java
src/main/java/com/gitblit/manager/RepositoryManager.java

index 7fbfbcc5e670f0e3c31444b54270399483e2466c..fdf0b440583ed275c5a6594424a887316a743273 100644 (file)
@@ -16,6 +16,7 @@ r23: {
     - Fix forcing default locale to en or LANG_CC for web ui (ticket-51)
     - Fix inconsistency with repository ownership permission checking (ticket-52)
     - Prevent submission from New|Edit ticket page with empty titles (ticket-53)
+    - Ensure the repository model ref list is refreshed on ref creation or deletion (ticket-54)
     - Fix case-sensitivity error in determining fork network (issue-420, ticket-62)
     - Fix transport determination for SSH urls served on port 22 (issue-421, ticket-63)
     changes:
index 61f2d67d4e30c42a7a51b8ccee95062690732aaf..b4449f06f00c8e664683f6a97d9281f27e6b8dca 100644 (file)
@@ -331,6 +331,8 @@ public class GitblitReceivePack extends ReceivePack implements PreReceiveHook, P
                        return;\r
                }\r
 \r
+               boolean isRefCreationOrDeletion = false;\r
+\r
                // log ref changes\r
                for (ReceiveCommand cmd : commands) {\r
 \r
@@ -339,9 +341,11 @@ public class GitblitReceivePack extends ReceivePack implements PreReceiveHook, P
                                switch (cmd.getType()) {\r
                                case DELETE:\r
                                        LOGGER.info(MessageFormat.format("{0} DELETED {1} in {2} ({3})", user.username, cmd.getRefName(), repository.name, cmd.getOldId().name()));\r
+                                       isRefCreationOrDeletion = true;\r
                                        break;\r
                                case CREATE:\r
                                        LOGGER.info(MessageFormat.format("{0} CREATED {1} in {2}", user.username, cmd.getRefName(), repository.name));\r
+                                       isRefCreationOrDeletion = true;\r
                                        break;\r
                                case UPDATE:\r
                                        LOGGER.info(MessageFormat.format("{0} UPDATED {1} in {2} (from {3} to {4})", user.username, cmd.getRefName(), repository.name, cmd.getOldId().name(), cmd.getNewId().name()));\r
@@ -355,6 +359,10 @@ public class GitblitReceivePack extends ReceivePack implements PreReceiveHook, P
                        }\r
                }\r
 \r
+               if (isRefCreationOrDeletion) {\r
+                       gitblit.resetRepositoryCache(repository.name);\r
+               }\r
+\r
                if (repository.useIncrementalPushTags) {\r
                        // tag each pushed branch tip\r
                        String emailAddress = user.emailAddress == null ? rp.getRefLogIdent().getEmailAddress() : user.emailAddress;\r
index 5b16ef668cc32098e34448050726cade72a3ec4a..2782e724f4447626da6f8f704cb97c736d4ac312 100644 (file)
@@ -928,6 +928,11 @@ public class GitblitManager implements IGitblit {
                repositoryManager.resetRepositoryListCache();
        }
 
+       @Override
+       public void resetRepositoryCache(String repositoryName) {
+               repositoryManager.resetRepositoryCache(repositoryName);
+       }
+
        @Override
        public List<String> getRepositoryList() {
                return repositoryManager.getRepositoryList();
index fd5fc14bb2fea76a1d6ec402972d4c01cc49796f..69177f1e0b3119ace1cd96e22da97b1ff0d72d69 100644 (file)
@@ -158,6 +158,14 @@ public interface IRepositoryManager extends IManager {
         */
        void resetRepositoryListCache();
 
+       /**
+        * Reset all caches for this repository.
+        *
+        * @param repositoryName
+        * @since 1.5.1
+        */
+       void resetRepositoryCache(String repositoryName);
+
        /**
         * Returns the list of all repositories available to Gitblit. This method
         * does not consider user access permissions.
index a76787bb74fceddf3457bf799cf8c6264f898e42..7351eb97b7e08c069da6ef9454ec1c4c6f7b0330 100644 (file)
@@ -454,6 +454,18 @@ public class RepositoryManager implements IRepositoryManager {
                CommitCache.instance().clear(repositoryName);
        }
 
+       /**
+        * Reset all caches for this repository.
+        *
+        * @param repositoryName
+        * @since 1.5.1
+        */
+       @Override
+       public void resetRepositoryCache(String repositoryName) {
+               removeFromCachedRepositoryList(repositoryName);
+               clearRepositoryMetadataCache(repositoryName);
+       }
+
        /**
         * Resets the repository list cache.
         *