Skip to content

Commit

Permalink
JENKINS-48737 Adding lightweight checkouts for Bitbucket Pull Requests
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminfuchs committed Mar 23, 2018
1 parent dd92b6a commit 3bac95e
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -855,12 +855,20 @@ private void collectFileAndDirectories(BitbucketSCMFile parent, List<Map> values
public InputStream getFileContent(BitbucketSCMFile file) throws IOException, InterruptedException {
List<String> lines = new ArrayList<>();
int start=0;
String ref;
if(file.getRef().matches("PR-\\d+")) { // because JENKINS-48737
String prId = file.getRef().replace("PR-", "");
ref = "refs/pull-requests/" + prId + "/from";
} else {
ref = file.getRef();
}

UriTemplate template = UriTemplate
.fromTemplate(API_BROWSE_PATH + "{&start,limit}")
.set("owner", getUserCentricOwner())
.set("repo", repositoryName)
.set("path", file.getPath())
.set("at", file.getRef())
.set("at", ref)
.set("start", start)
.set("limit", 500);
String url = template.expand();
Expand Down

0 comments on commit 3bac95e

Please sign in to comment.