Skip to content
Permalink
Browse files

[JENKINS-43507] Documentation drives code improvements

  • Loading branch information...
stephenc committed May 3, 2017
1 parent 0978e5d commit 42bcfe1aea0a8118352a38f3018fbbdb9eeb93d8
@@ -6,6 +6,7 @@
import hudson.util.ListBoxModel;
import jenkins.scm.api.SCMHead;
import jenkins.scm.api.SCMHeadCategory;
import jenkins.scm.api.SCMHeadOrigin;
import jenkins.scm.api.SCMRevision;
import jenkins.scm.api.trait.SCMBuilder;
import jenkins.scm.api.trait.SCMHeadAuthority;
@@ -135,6 +136,11 @@ protected boolean checkTrusted(@NonNull SCMSourceRequest request, @NonNull Branc
public String getDisplayName() {
return null;
}

@Override
public boolean isApplicableToOrigin(@NonNull Class<? extends SCMHeadOrigin> originClass) {
return SCMHeadOrigin.Default.class.isAssignableFrom(originClass);
}
}
}
}
@@ -2,10 +2,8 @@

import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.ExtensionList;
import hudson.scm.SCM;
import hudson.util.ListBoxModel;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import jenkins.scm.api.SCMHeadCategory;
@@ -101,14 +99,12 @@ public ListBoxModel doFillStrategyIdItems() {
}

public List<SCMHeadAuthorityDescriptor> getTrustDescriptors() {
List<SCMHeadAuthorityDescriptor> result = new ArrayList<>();
for (SCMHeadAuthorityDescriptor d : ExtensionList.lookup(SCMHeadAuthorityDescriptor.class)) {
if (d.isApplicableToRequest(GitHubSCMSourceRequest.class)
&& d.isApplicableToHead(PullRequestSCMHead.class)) {
result.add(d);
}
}
return result;
return SCMHeadAuthority._for(
GitHubSCMSourceRequest.class,
ChangeRequestSCMHead2.class,
null,
SCMHeadOrigin.Fork.class
);
}
}

@@ -133,6 +129,11 @@ protected boolean checkTrusted(@NonNull GitHubSCMSourceRequest request, @NonNull
public String getDisplayName() {
return "Contributors";
}

@Override
public boolean isApplicableToOrigin(@NonNull Class<? extends SCMHeadOrigin> originClass) {
return SCMHeadOrigin.Fork.class.isAssignableFrom(originClass);
}
}
}

@@ -153,6 +154,11 @@ public boolean checkTrusted(@NonNull SCMSourceRequest request, @NonNull ChangeRe
public String getDisplayName() {
return "Nobody";
}

@Override
public boolean isApplicableToOrigin(@NonNull Class<? extends SCMHeadOrigin> originClass) {
return SCMHeadOrigin.Fork.class.isAssignableFrom(originClass);
}
}
}

@@ -173,6 +179,11 @@ protected boolean checkTrusted(@NonNull SCMSourceRequest request, @NonNull Chang
public String getDisplayName() {
return "Everyone";
}

@Override
public boolean isApplicableToOrigin(@NonNull Class<? extends SCMHeadOrigin> originClass) {
return SCMHeadOrigin.Fork.class.isAssignableFrom(originClass);
}
}
}
}
@@ -101,6 +101,11 @@ protected boolean checkTrusted(@NonNull SCMSourceRequest request, @NonNull Chang
public String getDisplayName() {
return null;
}

@Override
public boolean isApplicableToOrigin(@NonNull Class<? extends SCMHeadOrigin> originClass) {
return SCMHeadOrigin.Default.class.isAssignableFrom(originClass);
}
}
}
}

0 comments on commit 42bcfe1

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