Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
[JENKINS-32925] Handle recursion
Browse files Browse the repository at this point in the history
Use stack to keep track of traversal.
  • Loading branch information
kohsuke committed Mar 29, 2016
1 parent 041c313 commit ff210c3
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -15,6 +15,9 @@ import org.jenkinsci.plugins.workflow.steps.StepDescriptor

import javax.servlet.RequestDispatcher

// keeps track of recursion inside generateHelp
stack = new Stack();

Snippetizer snippetizer = my;

def l = namespace(lib.LayoutTagLib)
Expand Down Expand Up @@ -91,6 +94,10 @@ def generateHelp(DescribableModel model, int headerLevel) throws Exception {
if (help != null && !help.equals("")) {
div(class:"help", style:"display: block") { raw(help) }
}
if (stack.contains(model.type))
return; // recursion. just show the title & cut the search

stack.push(model.type);
dl(class:'help-list mandatory'){
// TODO else could use RequestDispatcher (as in Descriptor.doHelp) to serve template-based help
model.parameters.findAll{ it.required }.each { p ->
Expand All @@ -115,6 +122,7 @@ def generateHelp(DescribableModel model, int headerLevel) throws Exception {
}
}
}
stack.pop();
}.call()
}

Expand Down

0 comments on commit ff210c3

Please sign in to comment.