Skip to content

Commit 72bc2b0

Browse files
committed
Fix ?until in BBS commit contexts
1 parent 15d2d34 commit 72bc2b0

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

components/server/src/bitbucket-server/bitbucket-server-context-parser.spec.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,32 @@ class TestBitbucketServerContextParser {
186186
});
187187
}
188188

189+
@test async test_commit_context_02() {
190+
const result = await this.parser.handle(
191+
{},
192+
this.user,
193+
"https://bitbucket.gitpod-dev.com/users/svenefftinge/repos/browser-extension-test/commits?until=refs%2Fheads%2Fmy-branch&merges=include",
194+
);
195+
196+
expect(result).to.deep.include({
197+
refType: "branch",
198+
revision: "3ca42b45bc693973cb21a112a418c13f8b4d11a5",
199+
path: "",
200+
isFile: false,
201+
repository: {
202+
cloneUrl: "https://bitbucket.gitpod-dev.com/scm/~svenefftinge/browser-extension-test.git",
203+
defaultBranch: "main",
204+
host: "bitbucket.gitpod-dev.com",
205+
name: "browser-extension-test",
206+
owner: "svenefftinge",
207+
repoKind: "users",
208+
private: false,
209+
webUrl: "https://bitbucket.gitpod-dev.com/users/svenefftinge/repos/browser-extension-test",
210+
},
211+
title: "svenefftinge/browser-extension-test - my-branch",
212+
});
213+
}
214+
189215
@test async test_PR_context_01() {
190216
const result = await this.parser.handle(
191217
{},

components/server/src/bitbucket-server/bitbucket-server-context-parser.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ export class BitbucketServerContextParser extends AbstractContextParser implemen
3535
const branchName = this.toSimpleBranchName(decodeURIComponent(searchParams.get("at")!));
3636
more.ref = branchName;
3737
more.refType = "branch";
38+
} else if (searchParams.has("until")) {
39+
const branchName = this.toSimpleBranchName(decodeURIComponent(searchParams.get("until")!));
40+
more.ref = branchName;
41+
more.refType = "branch";
3842
}
3943

4044
if (moreSegments[0] === "pull-requests" && !!moreSegments[1]) {
@@ -72,11 +76,11 @@ export class BitbucketServerContextParser extends AbstractContextParser implemen
7276

7377
const host = this.host; // as per contract, cf. `canHandle(user, contextURL)`
7478

75-
const lenghtOfRelativePath = host.split("/").length - 1; // e.g. "123.123.123.123/gitlab" => length of 1
76-
if (lenghtOfRelativePath > 0) {
79+
const lengthOfRelativePath = host.split("/").length - 1; // e.g. "123.123.123.123/gitlab" => length of 1
80+
if (lengthOfRelativePath > 0) {
7781
// remove segments from the path to be consider further, which belong to the relative location of the host
7882
// cf. https://github.com/gitpod-io/gitpod/issues/2637
79-
segments.splice(0, lenghtOfRelativePath);
83+
segments.splice(0, lengthOfRelativePath);
8084
}
8185

8286
const firstSegment = segments[0];

0 commit comments

Comments
 (0)