Skip to content

Commit

Permalink
[FIXED JENKINS-42236] Replicate the isMatch guard in heads
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenc committed Feb 21, 2017
1 parent 16e366e commit 59a8264
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/main/java/jenkins/plugins/git/GitSCMSource.java
Expand Up @@ -341,9 +341,25 @@ public boolean isMatch(SCMSource source) {
@NonNull
@Override
public Map<SCMHead, SCMRevision> heads(@NonNull SCMSource source) {
SCMHead head = new SCMHead(branch);
return Collections.<SCMHead, SCMRevision>singletonMap(head,
sha1 != null ? new SCMRevisionImpl(head, sha1) : null);
if (source instanceof GitSCMSource) {
GitSCMSource git = (GitSCMSource) source;
if (git.ignoreOnPushNotifications) {
return Collections.emptyMap();
}
URIish remote;
try {
remote = new URIish(git.getRemote());
} catch (URISyntaxException e) {
// ignore
return Collections.emptyMap();
}
if (GitStatus.looselyMatches(u, remote)) {
SCMHead head = new SCMHead(branch);
return Collections.<SCMHead, SCMRevision>singletonMap(head,
sha1 != null ? new SCMRevisionImpl(head, sha1) : null);
}
}
return Collections.emptyMap();
}

@Override
Expand Down

0 comments on commit 59a8264

Please sign in to comment.