]> source.dussan.org Git - gitblit.git/commitdiff
Improve NPE handling for hook script enumeration (issue-253)
authorJames Moger <james.moger@gitblit.com>
Tue, 11 Jun 2013 19:50:13 +0000 (15:50 -0400)
committerJames Moger <james.moger@gitblit.com>
Tue, 11 Jun 2013 19:50:13 +0000 (15:50 -0400)
releases.moxie
src/main/java/com/gitblit/GitBlit.java
src/main/java/com/gitblit/git/ReceiveHook.java

index d5c04ae29792f6bda277e73b1fe22aa2b25ce50b..197013ac89b7881336592961f54e875ca16ccb13 100644 (file)
@@ -28,6 +28,7 @@ r17: {
         - Ensure Redmine url is properly formatted (issue 223)\r
         - Use standard ServletRequestWrapper instead of custom wrapper (issue 224)\r
         - Switch commit message back to a pre and ensure that it is properly escaped when combined with commit message regex substitution (issue 242)\r
+        - Improve NPE handling for hook script enumeration (issue-253)\r
 \r
        changes:\r
         - Improved error logging for servlet containers which provide a null contextFolder (issue 199)\r
index df17edd900cd628659445acef6c538a465393cbe..c538acea36b27c7573149f23cc8ea756ca55453c 100644 (file)
@@ -3009,7 +3009,9 @@ public class GitBlit implements ServletContextListener {
                if (repository != null) {
                        for (String teamname : userService.getTeamnamesForRepositoryRole(repository.name)) {
                                TeamModel team = userService.getTeamModel(teamname);
-                               scripts.addAll(team.preReceiveScripts);
+                               if (!ArrayUtils.isEmpty(team.preReceiveScripts)) {
+                                       scripts.addAll(team.preReceiveScripts);
+                               }
                        }
                }
                return new ArrayList<String>(scripts);
@@ -3059,7 +3061,9 @@ public class GitBlit implements ServletContextListener {
                if (repository != null) {
                        for (String teamname : userService.getTeamnamesForRepositoryRole(repository.name)) {
                                TeamModel team = userService.getTeamModel(teamname);
-                               scripts.addAll(team.postReceiveScripts);
+                               if (!ArrayUtils.isEmpty(team.postReceiveScripts)) {
+                                       scripts.addAll(team.postReceiveScripts);
+                               }
                        }
                }
                return new ArrayList<String>(scripts);
index a961f5a6adb61d02396874962795b8d9cd7b4684..3e00b3812aa0607396c328bf6d3f1662be3884dd 100644 (file)
@@ -42,6 +42,7 @@ import com.gitblit.Keys;
 import com.gitblit.client.Translation;\r
 import com.gitblit.models.RepositoryModel;\r
 import com.gitblit.models.UserModel;\r
+import com.gitblit.utils.ArrayUtils;\r
 import com.gitblit.utils.ClientLogger;\r
 import com.gitblit.utils.JGitUtils;\r
 import com.gitblit.utils.PushLogUtils;\r
@@ -170,7 +171,9 @@ public class ReceiveHook implements PreReceiveHook, PostReceiveHook {
 \r
                Set<String> scripts = new LinkedHashSet<String>();\r
                scripts.addAll(GitBlit.self().getPreReceiveScriptsInherited(repository));\r
-               scripts.addAll(repository.preReceiveScripts);\r
+               if (!ArrayUtils.isEmpty(repository.preReceiveScripts)) {\r
+                       scripts.addAll(repository.preReceiveScripts);\r
+               }\r
                runGroovy(repository, user, commands, rp, scripts);\r
                for (ReceiveCommand cmd : commands) {\r
                        if (!Result.NOT_ATTEMPTED.equals(cmd.getResult())) {\r
@@ -262,7 +265,9 @@ public class ReceiveHook implements PreReceiveHook, PostReceiveHook {
                // run Groovy hook scripts \r
                Set<String> scripts = new LinkedHashSet<String>();\r
                scripts.addAll(GitBlit.self().getPostReceiveScriptsInherited(repository));\r
-               scripts.addAll(repository.postReceiveScripts);\r
+               if (!ArrayUtils.isEmpty(repository.postReceiveScripts)) {\r
+                       scripts.addAll(repository.postReceiveScripts);\r
+               }\r
                runGroovy(repository, user, commands, rp, scripts);\r
        }\r
 \r