use of cd.go.contrib.plugins.configrepo.groovy.dsl.BranchContext in project gocd-groovy-dsl-config-plugin by gocd-contrib.
the class BranchHelper method createContext.
public static BranchContext createContext(Attributes<?> attrs, MergeCandidate merge) {
final String ref = merge.ref();
final String branch = prettifyRef(gitShortRef(ref), attrs);
final BranchContext bc = new BranchContext(ref, branch, createMaterial(attrs, merge));
bc.setProvider(attrs.asConnectionConfig());
bc.setIdentifier(requireNonNullElse(merge.identifier(), ""));
bc.setTitle(requireNonNullElse(merge.title(), ""));
bc.setAuthor(requireNonNullElse(merge.author(), ""));
bc.setReferenceUrl(requireNonNullElse(merge.showUrl(), ""));
bc.setLabels(new ArrayList<>(requireNonNullElse(merge.labels(), Collections.emptyList())));
validate(bc, (errors) -> {
throw new ValidationException("Branch context binding is missing data! " + "Check the provider's API response. Error(s):\n" + errors.stream().map(ConstraintViolation::getMessage).collect(Collectors.joining("\n", " ", "")));
});
return bc;
}
Aggregations