Skip to content

Commit 04c46c8

Browse files
Use revision to get files from bitbucket api (#755)
Co-authored-by: Gleb Samsonov <[email protected]> Co-authored-by: Günter Grodotzki <[email protected]>
1 parent cb537d0 commit 04c46c8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/server/client/BitbucketServerAPIClient.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,12 +1210,13 @@ private String deleteRequest(String path) throws IOException, InterruptedExcepti
12101210
public Iterable<SCMFile> getDirectoryContent(BitbucketSCMFile directory) throws IOException, InterruptedException {
12111211
List<SCMFile> files = new ArrayList<>();
12121212
int start=0;
1213+
String branchOrHash = directory.getHash().contains("+") ? directory.getRef() : directory.getHash();
12131214
UriTemplate template = UriTemplate
12141215
.fromTemplate(API_BROWSE_PATH + "{&start,limit}")
12151216
.set("owner", getUserCentricOwner())
12161217
.set("repo", repositoryName)
12171218
.set("path", directory.getPath().split(Operator.PATH.getSeparator()))
1218-
.set("at", directory.getRef())
1219+
.set("at", branchOrHash)
12191220
.set("start", start)
12201221
.set("limit", 500);
12211222
String url = template.expand();
@@ -1258,12 +1259,13 @@ private void collectFileAndDirectories(BitbucketSCMFile parent, List<Map> values
12581259
public InputStream getFileContent(BitbucketSCMFile file) throws IOException, InterruptedException {
12591260
List<String> lines = new ArrayList<>();
12601261
int start=0;
1262+
String branchOrHash = file.getHash().contains("+") ? file.getRef() : file.getHash();
12611263
UriTemplate template = UriTemplate
12621264
.fromTemplate(API_BROWSE_PATH + "{&start,limit}")
12631265
.set("owner", getUserCentricOwner())
12641266
.set("repo", repositoryName)
12651267
.set("path", file.getPath().split(Operator.PATH.getSeparator()))
1266-
.set("at", file.getRef())
1268+
.set("at", branchOrHash)
12671269
.set("start", start)
12681270
.set("limit", 500);
12691271
String url = template.expand();

0 commit comments

Comments
 (0)