Skip to content

Commit 391266c

Browse files
Fix ?until in BBS commit contexts (#18987)
* Fix `?until` in BBS commit contexts * force branch name * Change test name
1 parent 99ff097 commit 391266c

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

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

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

189+
@test async test_branch_context_01() {
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+
ref: "my-branch",
198+
refType: "branch",
199+
revision: "3ca42b45bc693973cb21a112a418c13f8b4d11a5",
200+
path: "",
201+
isFile: false,
202+
repository: {
203+
cloneUrl: "https://bitbucket.gitpod-dev.com/scm/~svenefftinge/browser-extension-test.git",
204+
defaultBranch: "main",
205+
host: "bitbucket.gitpod-dev.com",
206+
name: "browser-extension-test",
207+
owner: "svenefftinge",
208+
repoKind: "users",
209+
private: false,
210+
webUrl: "https://bitbucket.gitpod-dev.com/users/svenefftinge/repos/browser-extension-test",
211+
},
212+
title: "svenefftinge/browser-extension-test - my-branch",
213+
});
214+
}
215+
189216
@test async test_PR_context_01() {
190217
const result = await this.parser.handle(
191218
{},

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)