Skip to content
Permalink
Browse files

[JENKINS-43507] Fix the <scm:traits> taglib

  • Loading branch information...
stephenc committed May 4, 2017
1 parent 865bdc9 commit 84c61db4c686f6112d72f871394ffea48468ea90
@@ -853,7 +853,7 @@ public String getIconClassName() {
@Override
public SCMNavigator newInstance(String name) {
GitHubSCMNavigator navigator = new GitHubSCMNavigator("", name, "");
navigator.setTraits(getDefaultTraits());
navigator.setTraits(getTraitDefaults());
return navigator;
}

@@ -897,9 +897,9 @@ public boolean isApiUriSelectable() {
return descriptors;
}

public List<SCMTrait<? extends SCMTrait<?>>> getDefaultTraits() {
public List<SCMTrait<? extends SCMTrait<?>>> getTraitDefaults() {
List<SCMTrait<? extends SCMTrait<?>>> result = new ArrayList<>();
result.addAll(delegate.getDefaultTraits());
result.addAll(delegate.getTraitDefaults());
return result;
}

@@ -242,7 +242,7 @@ public GitHubSCMSource(String id, String apiUri, String scanCredentialsId, Strin
this.scanCredentialsId = Util.fixEmpty(scanCredentialsId);
pullRequestMetadataCache = new ConcurrentHashMap<>();
pullRequestContributorCache = new ConcurrentHashMap<>();
this.traits = new ArrayList<>(((DescriptorImpl)getDescriptor()).getDefaultTraits());
this.traits = new ArrayList<>(((DescriptorImpl) getDescriptor()).getTraitDefaults());
if (!DescriptorImpl.SAME.equals(checkoutCredentialsId)) {
traits.add(new SSHCheckoutTrait(checkoutCredentialsId));
}
@@ -1515,7 +1515,7 @@ private static ListBoxModel nameAndValueModel(Collection<String> items) {
return SCMSourceTrait._for(this, GitHubSCMSourceContext.class, GitHubSCMBuilder.class);
}

public List<SCMSourceTrait> getDefaultTraits() {
public List<SCMSourceTrait> getTraitDefaults() {
return Arrays.asList( // TODO finalize
new BranchDiscoveryTrait(1),
new OriginPullRequestDiscoveryTrait(1),
@@ -1,27 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form" xmlns:c="/lib/credentials">
<j:choose>
<j:when test="${descriptor.apiUriSelectable}">
<f:entry title="${%API endpoint}" field="apiUri">
<f:select/>
</f:entry>
</j:when>
<j:otherwise>
<f:invisibleEntry>
<f:select field="apiUri"/>
</f:invisibleEntry>
</j:otherwise>
</j:choose>
<f:entry title="${%Credentials}" field="scanCredentialsId">
<c:select/>
</f:entry>
<f:entry title="${%Owner}" field="repoOwner">
<f:textbox/>
</f:entry>
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form" xmlns:c="/lib/credentials" xmlns:scm="/jenkins/scm/api/form">
<j:choose>
<j:when test="${descriptor.apiUriSelectable}">
<f:entry title="${%API endpoint}" field="apiUri">
<f:select/>
</f:entry>
</j:when>
<j:otherwise>
<f:invisibleEntry>
<f:select field="apiUri"/>
</f:invisibleEntry>
</j:otherwise>
</j:choose>
<f:entry title="${%Credentials}" field="scanCredentialsId">
<c:select/>
</f:entry>
<f:entry title="${%Owner}" field="repoOwner">
<f:textbox/>
</f:entry>
<f:entry title="${%Behaviours}">
<f:entry title="${%Behaviours}">
<f:hetero-list name="traits" items="${instance == null ? descriptor.defaultTraits : instance.traits}"
descriptors="${descriptor[attrs.field+'Descriptors'] ?: descriptor.getPropertyType(instance,'traits').getApplicableItemDescriptors()}"
hasHeader="true" honorOrder="true" oneEach="true"/>
<scm:traits field="traits"/>
</f:entry>
</f:entry>
</j:jelly>
@@ -1,6 +1,7 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:c="/lib/credentials" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
xmlns:f2="/org/jenkinsci/plugins/github_branch_source/form">
<j:jelly xmlns:j="jelly:core" xmlns:c="/lib/credentials"
xmlns:f="/lib/form"
xmlns:f2="/org/jenkinsci/plugins/github_branch_source/form" xmlns:scm="/jenkins/scm/api/form">
<j:choose>
<j:when test="${descriptor.apiUriSelectable}">
<f:entry title="${%API endpoint}" field="apiUri">
@@ -24,9 +25,7 @@
<f2:select/>
</f:entry>
<f:entry title="${%Behaviours}">
<f:hetero-list name="traits" items="${instance == null ? descriptor.defaultTraits : instance.traits}"
descriptors="${descriptor[attrs.field+'Descriptors'] ?: descriptor.getPropertyType(instance,'traits').getApplicableItemDescriptors()}"
hasHeader="true" honorOrder="true" oneEach="true"/>
<scm:traits field="traits"/>
</f:entry>

</j:jelly>

0 comments on commit 84c61db

Please sign in to comment.
You can’t perform that action at this time.