Skip to content

Commit e53c6fb

Browse files
committed
Generates create Bitbucket DataCenter PR URLs (without cross-forks)
(#4142, #4143)
1 parent 28a5220 commit e53c6fb

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/git/remotes/bitbucket-server.ts

+20-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,26 @@ export class BitbucketServerRemote extends RemoteProvider {
157157
return this.encodeUrl(`${this.baseUrl}/commits/${sha}`);
158158
}
159159

160-
protected override getUrlForComparison(base: string, compare: string, _notation: '..' | '...'): string {
161-
return this.encodeUrl(`${this.baseUrl}/branches/compare/${base}%0D${compare}`).replace('%250D', '%0D');
160+
protected override getUrlForComparison(base: string, head: string, _notation: '..' | '...'): string {
161+
return this.encodeUrl(`${this.baseUrl}/branches/compare/${base}%0D${head}`).replace('%250D', '%0D');
162+
}
163+
164+
protected override getUrlForCreatePullRequest(
165+
base: { branch?: string; remote: { path: string; url: string } },
166+
head: { branch: string; remote: { path: string; url: string } },
167+
options?: { title?: string; description?: string },
168+
): string | undefined {
169+
const query = new URLSearchParams({ sourceBranch: head.branch, targetBranch: base.branch ?? '' });
170+
// TODO: figure this out
171+
// query.set('targetRepoId', base.repoId);
172+
if (options?.title) {
173+
query.set('title', options.title);
174+
}
175+
if (options?.description) {
176+
query.set('description', options.description);
177+
}
178+
179+
return `${this.encodeUrl(`${this.baseUrl}/pull-requests?create`)}&${query.toString()}`;
162180
}
163181

164182
protected getUrlForFile(fileName: string, branch?: string, sha?: string, range?: Range): string {

0 commit comments

Comments
 (0)