瀏覽代碼

Improve NPE handling for hook script enumeration (issue-253)

tags/v1.3.0
James Moger 11 年之前
父節點
當前提交
9788200234
共有 3 個檔案被更改,包括 14 行新增4 行删除
  1. 1
    0
      releases.moxie
  2. 6
    2
      src/main/java/com/gitblit/GitBlit.java
  3. 7
    2
      src/main/java/com/gitblit/git/ReceiveHook.java

+ 1
- 0
releases.moxie 查看文件

@@ -28,6 +28,7 @@ r17: {
- Ensure Redmine url is properly formatted (issue 223)
- Use standard ServletRequestWrapper instead of custom wrapper (issue 224)
- Switch commit message back to a pre and ensure that it is properly escaped when combined with commit message regex substitution (issue 242)
- Improve NPE handling for hook script enumeration (issue-253)
changes:
- Improved error logging for servlet containers which provide a null contextFolder (issue 199)

+ 6
- 2
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);

+ 7
- 2
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);
}

Loading…
取消
儲存