Skip to content

Commit

Permalink
Fix backward compatibility of PullRequestSCMRevision
Browse files Browse the repository at this point in the history
Method `getPull` is used in some private plugins.
jenkinsci#796 changed signature of this method.

Now signature is returned back.
See also jenkinsci#817.
  • Loading branch information
andrey-fomin committed Feb 28, 2024
1 parent 857269a commit 78891e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import hudson.plugins.git.GitSCM;
import hudson.plugins.git.browser.BitbucketWeb;
import java.util.List;
import jenkins.plugins.git.AbstractGitSCMSource;
import jenkins.plugins.git.GitSCMBuilder;
import jenkins.scm.api.SCMHead;
import jenkins.scm.api.SCMRevision;
Expand Down Expand Up @@ -223,14 +224,15 @@ private void withPullRequestRemote(PullRequestSCMHead head, String headName) {
String primaryRemoteName = remoteName().equals("primary") ? "primary-primary" : "primary";
String cloneLink = getCloneLink(primaryCloneLinks);
List<BranchWithHash> branchWithHashes;
AbstractGitSCMSource.SCMRevisionImpl pullRevision = (AbstractGitSCMSource.SCMRevisionImpl) pullRequestSCMRevision.getPull();
if (checkoutStrategy == ChangeRequestCheckoutStrategy.MERGE) {
branchWithHashes = List.of(
new BranchWithHash(branchName, pullRequestSCMRevision.getPull().getHash()),
new BranchWithHash(branchName, pullRevision.getHash()),
new BranchWithHash(targetBranch, pullRequestSCMRevision.getTargetImpl().getHash())
);
} else {
branchWithHashes = List.of(
new BranchWithHash(branchName, pullRequestSCMRevision.getPull().getHash())
new BranchWithHash(branchName, pullRevision.getHash())
);
}
withExtension(new FallbackToOtherRepositoryGitSCMExtension(cloneLink, primaryRemoteName, branchWithHashes));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import edu.umd.cs.findbugs.annotations.NonNull;
import jenkins.plugins.git.AbstractGitSCMSource;
import jenkins.scm.api.SCMRevision;
import jenkins.scm.api.mixin.ChangeRequestCheckoutStrategy;
import jenkins.scm.api.mixin.ChangeRequestSCMRevision;

Expand Down Expand Up @@ -65,7 +66,7 @@ public PullRequestSCMRevision(@NonNull PullRequestSCMHead head, @NonNull Abstrac
* @return the pull revision.
*/
@NonNull
public AbstractGitSCMSource.SCMRevisionImpl getPull() {
public SCMRevision getPull() {
return pull;
}

Expand Down

0 comments on commit 78891e9

Please sign in to comment.