summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2013-06-11 15:50:13 -0400
committerJames Moger <james.moger@gitblit.com>2013-06-11 15:50:13 -0400
commit9788200234dfe222989823c6160d2be40fd84415 (patch)
tree6dea94207431ad05a064cfd3196d3bf5dde43b62 /src/main/java
parentcedf138f3c9afeae7bcbda5dbb0511ebec297d10 (diff)
downloadgitblit-9788200234dfe222989823c6160d2be40fd84415.tar.gz
gitblit-9788200234dfe222989823c6160d2be40fd84415.zip
Improve NPE handling for hook script enumeration (issue-253)
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/gitblit/GitBlit.java8
-rw-r--r--src/main/java/com/gitblit/git/ReceiveHook.java9
2 files changed, 13 insertions, 4 deletions
diff --git a/src/main/java/com/gitblit/GitBlit.java b/src/main/java/com/gitblit/GitBlit.java
index df17edd9..c538acea 100644
--- a/src/main/java/com/gitblit/GitBlit.java
+++ b/src/main/java/com/gitblit/GitBlit.java
@@ -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);
diff --git a/src/main/java/com/gitblit/git/ReceiveHook.java b/src/main/java/com/gitblit/git/ReceiveHook.java
index a961f5a6..3e00b381 100644
--- a/src/main/java/com/gitblit/git/ReceiveHook.java
+++ b/src/main/java/com/gitblit/git/ReceiveHook.java
@@ -42,6 +42,7 @@ import com.gitblit.Keys;
import com.gitblit.client.Translation;
import com.gitblit.models.RepositoryModel;
import com.gitblit.models.UserModel;
+import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.ClientLogger;
import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.PushLogUtils;
@@ -170,7 +171,9 @@ public class ReceiveHook implements PreReceiveHook, PostReceiveHook {
Set<String> scripts = new LinkedHashSet<String>();
scripts.addAll(GitBlit.self().getPreReceiveScriptsInherited(repository));
- scripts.addAll(repository.preReceiveScripts);
+ if (!ArrayUtils.isEmpty(repository.preReceiveScripts)) {
+ scripts.addAll(repository.preReceiveScripts);
+ }
runGroovy(repository, user, commands, rp, scripts);
for (ReceiveCommand cmd : commands) {
if (!Result.NOT_ATTEMPTED.equals(cmd.getResult())) {
@@ -262,7 +265,9 @@ public class ReceiveHook implements PreReceiveHook, PostReceiveHook {
// run Groovy hook scripts
Set<String> scripts = new LinkedHashSet<String>();
scripts.addAll(GitBlit.self().getPostReceiveScriptsInherited(repository));
- scripts.addAll(repository.postReceiveScripts);
+ if (!ArrayUtils.isEmpty(repository.postReceiveScripts)) {
+ scripts.addAll(repository.postReceiveScripts);
+ }
runGroovy(repository, user, commands, rp, scripts);
}