Browse Source

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

tags/v1.3.0
James Moger 11 years ago
parent
commit
9788200234

+ 1
- 0
releases.moxie View File

- Ensure Redmine url is properly formatted (issue 223) - Ensure Redmine url is properly formatted (issue 223)
- Use standard ServletRequestWrapper instead of custom wrapper (issue 224) - 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) - 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: changes:
- Improved error logging for servlet containers which provide a null contextFolder (issue 199) - Improved error logging for servlet containers which provide a null contextFolder (issue 199)

+ 6
- 2
src/main/java/com/gitblit/GitBlit.java View File

if (repository != null) { if (repository != null) {
for (String teamname : userService.getTeamnamesForRepositoryRole(repository.name)) { for (String teamname : userService.getTeamnamesForRepositoryRole(repository.name)) {
TeamModel team = userService.getTeamModel(teamname); TeamModel team = userService.getTeamModel(teamname);
scripts.addAll(team.preReceiveScripts);
if (!ArrayUtils.isEmpty(team.preReceiveScripts)) {
scripts.addAll(team.preReceiveScripts);
}
} }
} }
return new ArrayList<String>(scripts); return new ArrayList<String>(scripts);
if (repository != null) { if (repository != null) {
for (String teamname : userService.getTeamnamesForRepositoryRole(repository.name)) { for (String teamname : userService.getTeamnamesForRepositoryRole(repository.name)) {
TeamModel team = userService.getTeamModel(teamname); TeamModel team = userService.getTeamModel(teamname);
scripts.addAll(team.postReceiveScripts);
if (!ArrayUtils.isEmpty(team.postReceiveScripts)) {
scripts.addAll(team.postReceiveScripts);
}
} }
} }
return new ArrayList<String>(scripts); return new ArrayList<String>(scripts);

+ 7
- 2
src/main/java/com/gitblit/git/ReceiveHook.java View File

import com.gitblit.client.Translation; import com.gitblit.client.Translation;
import com.gitblit.models.RepositoryModel; import com.gitblit.models.RepositoryModel;
import com.gitblit.models.UserModel; import com.gitblit.models.UserModel;
import com.gitblit.utils.ArrayUtils;
import com.gitblit.utils.ClientLogger; import com.gitblit.utils.ClientLogger;
import com.gitblit.utils.JGitUtils; import com.gitblit.utils.JGitUtils;
import com.gitblit.utils.PushLogUtils; import com.gitblit.utils.PushLogUtils;
Set<String> scripts = new LinkedHashSet<String>(); Set<String> scripts = new LinkedHashSet<String>();
scripts.addAll(GitBlit.self().getPreReceiveScriptsInherited(repository)); 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); runGroovy(repository, user, commands, rp, scripts);
for (ReceiveCommand cmd : commands) { for (ReceiveCommand cmd : commands) {
if (!Result.NOT_ATTEMPTED.equals(cmd.getResult())) { if (!Result.NOT_ATTEMPTED.equals(cmd.getResult())) {
// run Groovy hook scripts // run Groovy hook scripts
Set<String> scripts = new LinkedHashSet<String>(); Set<String> scripts = new LinkedHashSet<String>();
scripts.addAll(GitBlit.self().getPostReceiveScriptsInherited(repository)); 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); runGroovy(repository, user, commands, rp, scripts);
} }

Loading…
Cancel
Save