Skip to content

Commit 63c2939

Browse files
sergeibbbaxosoft-ramint
authored andcommitted
Adds support for comparison and create pull request URLs in remote services
Adds configuration options for comparison and create pull request URLs to support custom remote services. Updates the relevant interfaces and abstract methods to include these new URL types. (#4142, #4143)
1 parent ffe5dbf commit 63c2939

File tree

6 files changed

+19
-5
lines changed

6 files changed

+19
-5
lines changed

package.json

+8
Original file line numberDiff line numberDiff line change
@@ -3913,6 +3913,14 @@
39133913
"type": "string",
39143914
"markdownDescription": "Specifies the format of a commit URL for the custom remote service\n\nAvailable tokens\\\n`${repo}` — repository path\\\n`${id}` — commit SHA"
39153915
},
3916+
"comparison": {
3917+
"type": "string",
3918+
"markdownDescription": "Specifies the format of a comparison URL for the custom remote service\n\nAvailable tokens\\\n`${repo}` — repository path\\\n`${ref1}` — ref 1\\\n`${ref2}` — ref 2\\\n`${notation}` — notation"
3919+
},
3920+
"createPullRequest": {
3921+
"type": "string",
3922+
"markdownDescription": "Specifies the format of a create pull request URL for the custom remote service\n\nAvailable tokens\\\n`${repo}` — repository path\\\n`${base}` — base branch\\\n`${compare}` — compare branch"
3923+
},
39163924
"file": {
39173925
"type": "string",
39183926
"markdownDescription": "Specifies the format of a file URL for the custom remote service\n\nAvailable tokens\\\n`${repo}` — repository path\\\n`${file}` — file name\\\n`${line}` — formatted line information"

src/commands/createPullRequestOnRemote.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { GlCommandBase } from './commandBase';
1111
import type { OpenOnRemoteCommandArgs } from './openOnRemote';
1212

1313
export interface CreatePullRequestOnRemoteCommandArgs {
14-
base?: string;
14+
base: string | undefined;
1515
compare: string;
1616
remote: string;
1717
repoPath: string;

src/config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@ export interface RemotesUrlsConfig {
641641
readonly branch: string;
642642
readonly commit: string;
643643
readonly comparison?: string;
644+
readonly createPullRequest?: string;
644645
readonly file: string;
645646
readonly fileInBranch: string;
646647
readonly fileInCommit: string;

src/git/models/remoteResource.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export type RemoteResource =
3434
| {
3535
type: RemoteResourceType.CreatePullRequest;
3636
base: {
37-
branch?: string;
37+
branch: string | undefined;
3838
remote: { path: string; url: string };
3939
};
4040
compare: {

src/git/remotes/gerrit.ts

+4
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ export class GerritRemote extends RemoteProvider {
189189
return this.encodeUrl(`${this.baseReviewUrl}/q/${sha}`);
190190
}
191191

192+
protected override getUrlForComparison(base: string, head: string, notation: '..' | '...'): string | undefined {
193+
return this.encodeUrl(`${this.baseReviewUrl}/q/${base}${notation}${head}`);
194+
}
195+
192196
protected getUrlForFile(fileName: string, branch?: string, sha?: string, range?: Range): string {
193197
const line = range != null ? `#${range.start.line}` : '';
194198

src/git/remotes/remoteProvider.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export abstract class RemoteProvider<T extends ResourceDescriptor = ResourceDesc
129129
case RemoteResourceType.Commit:
130130
return this.getUrlForCommit(resource.sha);
131131
case RemoteResourceType.Comparison: {
132-
return this.getUrlForComparison?.(resource.base, resource.compare, resource.notation ?? '...');
132+
return this.getUrlForComparison(resource.base, resource.compare, resource.notation ?? '...');
133133
}
134134
case RemoteResourceType.CreatePullRequest: {
135135
return this.getUrlForCreatePullRequest?.(resource.base, resource.compare);
@@ -180,11 +180,12 @@ export abstract class RemoteProvider<T extends ResourceDescriptor = ResourceDesc
180180

181181
protected abstract getUrlForCommit(sha: string): string;
182182

183-
protected getUrlForComparison?(base: string, compare: string, notation: '..' | '...'): string | undefined;
183+
protected abstract getUrlForComparison(base: string, head: string, notation: '..' | '...'): string | undefined;
184184

185185
protected getUrlForCreatePullRequest?(
186186
base: { branch?: string; remote: { path: string; url: string } },
187-
compare: { branch: string; remote: { path: string; url: string } },
187+
head: { branch: string; remote: { path: string; url: string } },
188+
options?: { title?: string; description?: string },
188189
): string | undefined;
189190

190191
protected abstract getUrlForFile(fileName: string, branch?: string, sha?: string, range?: Range): string;

0 commit comments

Comments
 (0)