diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java index 29d6d20fa..f9ef4f9d8 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMSource.java @@ -619,8 +619,7 @@ private void doRetrieve(SCMSourceCriteria criteria, SCMHeadObserver observer, Ta } continue; } - boolean trusted = collaboratorNames != null - && collaboratorNames.contains(ghPullRequest.getHead().getRepository().getOwnerName()); + boolean trusted = isTrusted(ghPullRequest, collaboratorNames); if (!trusted) { listener.getLogger().format(" (not from a trusted source)%n"); } @@ -807,6 +806,13 @@ private void doRetrieve(SCMSourceCriteria criteria, SCMHeadObserver observer, Ta } } + private boolean isTrusted(GHPullRequest ghPullRequest, Collection collaboratorNames) { + String prUserLogin = ghPullRequest.getUser().getLogin(); + String prRepoOwner = ghPullRequest.getHead().getRepository().getOwnerName(); + return collaboratorNames != null + && (collaboratorNames.contains(prRepoOwner) || collaboratorNames.contains(prUserLogin)); + } + /** * {@inheritDoc} */