Skip to content

Commit 0d60ddb

Browse files
committed
Adds Open tag on remote option to tagView
1 parent b779add commit 0d60ddb

16 files changed

+92
-19
lines changed

package.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3668,7 +3668,8 @@
36683668
"fileInCommit",
36693669
"fileInBranch",
36703670
"fileLine",
3671-
"fileRange"
3671+
"fileRange",
3672+
"tagName"
36723673
],
36733674
"properties": {
36743675
"repository": {
@@ -3706,6 +3707,10 @@
37063707
"fileRange": {
37073708
"type": "string",
37083709
"markdownDescription": "Specifies the format of a range in a file URL for the custom remote service\n\nAvailable tokens\\\n`${start}` — starting line\\\n`${end}` — ending line"
3710+
},
3711+
"tagName": {
3712+
"type": "string",
3713+
"markdownDescription": "Specifies the format of a tag URL for the custom remote service\n\nAvailable tokens\\\n`${repo}` — repository path\\\n`${tagName}` — name of the tag"
37093714
}
37103715
},
37113716
"additionalProperties": false
@@ -6752,6 +6757,12 @@
67526757
"title": "Open Commit on Remote",
67536758
"icon": "$(globe)"
67546759
},
6760+
{
6761+
"command": "gitlens.views.openTagOnRemote",
6762+
"title": "Open Tag on Remote",
6763+
"category": "GitLens",
6764+
"icon": "$(globe)"
6765+
},
67556766
{
67566767
"command": "gitlens.views.openCommitOnRemote.multi",
67576768
"title": "Open Commits on Remote",
@@ -14868,6 +14879,11 @@
1486814879
"group": "inline@99",
1486914880
"alt": "gitlens.views.copyRemoteCommitUrl"
1487014881
},
14882+
{
14883+
"command": "gitlens.views.openTagOnRemote",
14884+
"when": "gitlens:repos:withRemotes && viewItem =~ /gitlens:tag\\b(.*?\\b\\+remote\\b)/",
14885+
"group": "inline@99"
14886+
},
1487114887
{
1487214888
"command": "gitlens.views.cherryPick",
1487314889
"when": "!listMultiSelection && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:commit\\b(?!.*?\\b\\+(current|rebase)\\b)/",

src/commands/openOnRemote.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,13 @@ export class OpenOnRemoteCommand extends Command {
196196
break;
197197
}
198198

199-
// case RemoteResourceType.Tag: {
200-
// title = getTitlePrefix('Tag');
201-
// if (resources.length === 1) {
202-
// title += `${pad(GlyphChars.Dot, 2, 2)}${args.resource.tag}`;
203-
// }
204-
// break;
205-
// }
199+
case RemoteResourceType.Tag: {
200+
title = getTitlePrefix('Tag');
201+
if (resources.length === 1) {
202+
title += `${pad(GlyphChars.Dot, 2, 2)}${resource.tag}`;
203+
}
204+
break;
205+
}
206206
}
207207

208208
const pick = await showRemoteProviderPicker(title, placeholder, resources, remotes, options);

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ export interface RemotesUrlsConfig {
580580
readonly fileInCommit: string;
581581
readonly fileLine: string;
582582
readonly fileRange: string;
583+
readonly tag: string;
583584
}
584585

585586
// NOTE: Must be kept in sync with `gitlens.advanced.messages` setting in the package.json

src/git/models/remoteResource.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const enum RemoteResourceType {
1010
File = 'file',
1111
Repo = 'repo',
1212
Revision = 'revision',
13-
// Tag = 'tag',
13+
Tag = 'tag',
1414
}
1515

1616
export type RemoteResource =
@@ -58,11 +58,11 @@ export type RemoteResource =
5858
fileName: string;
5959
range?: Range;
6060
sha?: string;
61+
}
62+
| {
63+
type: RemoteResourceType.Tag;
64+
tag: string;
6165
};
62-
// | {
63-
// type: RemoteResourceType.Tag;
64-
// tag: string;
65-
// };
6666

6767
export function getNameFromRemoteResource(resource: RemoteResource) {
6868
switch (resource.type) {

src/git/remotes/azure-devops.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,8 @@ export class AzureDevOpsRemote extends RemoteProvider {
201201
if (branch) return this.encodeUrl(`${this.baseUrl}/?path=/${fileName}&version=GB${branch}&_a=contents${line}`);
202202
return this.encodeUrl(`${this.baseUrl}?path=/${fileName}${line}`);
203203
}
204+
205+
protected override getUrlForTag(tagName: string): string {
206+
return this.encodeUrl(`${this.baseUrl}?version=GT${tagName}`);
207+
}
204208
}

src/git/remotes/bitbucket-server.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,8 @@ export class BitbucketServerRemote extends RemoteProvider {
171171
if (branch) return `${this.encodeUrl(`${this.baseUrl}/browse/${fileName}?at=${branch}`)}${line}`;
172172
return `${this.encodeUrl(`${this.baseUrl}/browse/${fileName}`)}${line}`;
173173
}
174+
175+
protected override getUrlForTag(tagName: string): string {
176+
return this.encodeUrl(`${this.baseUrl}/commits/tag/${tagName}`);
177+
}
174178
}

src/git/remotes/bitbucket.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,8 @@ export class BitbucketRemote extends RemoteProvider {
157157
if (branch) return `${this.encodeUrl(`${this.baseUrl}/src/${branch}/${fileName}`)}${line}`;
158158
return `${this.encodeUrl(`${this.baseUrl}?path=${fileName}`)}${line}`;
159159
}
160+
161+
protected override getUrlForTag(tagName: string): string {
162+
return this.encodeUrl(`${this.baseUrl}/commits/tag/${tagName}`);
163+
}
160164
}

src/git/remotes/custom.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ export class CustomRemote extends RemoteProvider {
100100
return url;
101101
}
102102

103+
protected override getUrlForTag(tagName: string): string {
104+
return this.getUrl(this.urls.tag, this.getContext({ tagName: tagName }));
105+
}
106+
103107
private getUrl(template: string, context: Record<string, string>): string {
104108
const url = interpolate(template, context);
105109
const encoded = getTokensFromTemplate(template).some(t => t.key.endsWith('_encoded'));

src/git/remotes/gerrit.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,8 @@ export class GerritRemote extends RemoteProvider {
191191
if (branch) return `${this.encodeUrl(`${this.getUrlForBranch(branch)}/${fileName}`)}${line}`;
192192
return `${this.encodeUrl(`${this.baseUrl}/+/HEAD/${fileName}`)}${line}`;
193193
}
194+
195+
protected override getUrlForTag(): string | undefined {
196+
return undefined;
197+
}
194198
}

src/git/remotes/gitea.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,8 @@ export class GiteaRemote extends RemoteProvider {
155155
// this route is deprecated but there is no alternative
156156
return `${this.encodeUrl(`${this.baseUrl}/src/${fileName}`)}${line}`;
157157
}
158+
159+
protected getUrlForTag(tagName: string): string {
160+
return this.encodeUrl(`${this.baseUrl}/releases/tag/${tagName}`);
161+
}
158162
}

0 commit comments

Comments
 (0)