Skip to content

Commit ba92943

Browse files
committed
Fixed review notes
1 parent 0d60ddb commit ba92943

16 files changed

+201
-24
lines changed

package.json

+63-6
Original file line numberDiff line numberDiff line change
@@ -3669,7 +3669,7 @@
36693669
"fileInBranch",
36703670
"fileLine",
36713671
"fileRange",
3672-
"tagName"
3672+
"tag"
36733673
],
36743674
"properties": {
36753675
"repository": {
@@ -3708,7 +3708,7 @@
37083708
"type": "string",
37093709
"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"
37103710
},
3711-
"tagName": {
3711+
"tag": {
37123712
"type": "string",
37133713
"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"
37143714
}
@@ -6758,14 +6758,24 @@
67586758
"icon": "$(globe)"
67596759
},
67606760
{
6761-
"command": "gitlens.views.openTagOnRemote",
6761+
"command": "gitlens.views.openCommitOnRemote.multi",
6762+
"title": "Open Commits on Remote",
6763+
"icon": "$(globe)"
6764+
},
6765+
{
6766+
"command": "gitlens.openTagOnRemote",
67626767
"title": "Open Tag on Remote",
67636768
"category": "GitLens",
67646769
"icon": "$(globe)"
67656770
},
67666771
{
6767-
"command": "gitlens.views.openCommitOnRemote.multi",
6768-
"title": "Open Commits on Remote",
6772+
"command": "gitlens.views.openTagOnRemote",
6773+
"title": "Open Tag on Remote",
6774+
"icon": "$(globe)"
6775+
},
6776+
{
6777+
"command": "gitlens.views.openTagOnRemote.multi",
6778+
"title": "Open Tags on Remote",
67696779
"icon": "$(globe)"
67706780
},
67716781
{
@@ -6784,6 +6794,22 @@
67846794
"title": "Copy Remote Commit URLs",
67856795
"icon": "$(copy)"
67866796
},
6797+
{
6798+
"command": "gitlens.copyRemoteTagUrl",
6799+
"title": "Copy Remote Tag URL",
6800+
"category": "GitLens",
6801+
"icon": "$(copy)"
6802+
},
6803+
{
6804+
"command": "gitlens.views.copyRemoteTagUrl",
6805+
"title": "Copy Remote Tag URL",
6806+
"icon": "$(copy)"
6807+
},
6808+
{
6809+
"command": "gitlens.views.copyRemoteTagUrl.multi",
6810+
"title": "Copy Remote Tag URLs",
6811+
"icon": "$(copy)"
6812+
},
67876813
{
67886814
"command": "gitlens.openComparisonOnRemote",
67896815
"title": "Open Comparison on Remote",
@@ -10571,6 +10597,18 @@
1057110597
"command": "gitlens.views.openCommitOnRemote.multi",
1057210598
"when": "false"
1057310599
},
10600+
{
10601+
"command": "gitlens.openTagOnRemote",
10602+
"when": "gitlens:repos:withRemotes"
10603+
},
10604+
{
10605+
"command": "gitlens.views.openTagOnRemote",
10606+
"when": "false"
10607+
},
10608+
{
10609+
"command": "gitlens.views.openTagOnRemote.multi",
10610+
"when": "false"
10611+
},
1057410612
{
1057510613
"command": "gitlens.copyRemoteCommitUrl",
1057610614
"when": "gitlens:repos:withRemotes"
@@ -10583,6 +10621,14 @@
1058310621
"command": "gitlens.views.copyRemoteCommitUrl.multi",
1058410622
"when": "false"
1058510623
},
10624+
{
10625+
"command": "gitlens.views.copyRemoteTagUrl",
10626+
"when": "false"
10627+
},
10628+
{
10629+
"command": "gitlens.views.copyRemoteTagUrl.multi",
10630+
"when": "false"
10631+
},
1058610632
{
1058710633
"command": "gitlens.openComparisonOnRemote",
1058810634
"when": "false"
@@ -14882,7 +14928,8 @@
1488214928
{
1488314929
"command": "gitlens.views.openTagOnRemote",
1488414930
"when": "gitlens:repos:withRemotes && viewItem =~ /gitlens:tag\\b(.*?\\b\\+remote\\b)/",
14885-
"group": "inline@99"
14931+
"group": "inline@99",
14932+
"alt": "gitlens.views.copyRemoteTagUrl"
1488614933
},
1488714934
{
1488814935
"command": "gitlens.views.cherryPick",
@@ -15000,6 +15047,16 @@
1500015047
"when": "listMultiSelection && gitlens:repos:withRemotes && viewItem =~ /gitlens:commit\\b/",
1500115048
"group": "3_gitlens_explore@2"
1500215049
},
15050+
{
15051+
"command": "gitlens.views.openTagOnRemote",
15052+
"when": "!listMultiSelection && gitlens:repos:withRemotes && viewItem =~ /gitlens:tag\\b(.*?\\b\\+remote\\b)/",
15053+
"group": "3_gitlens_explore@2"
15054+
},
15055+
{
15056+
"command": "gitlens.views.openTagOnRemote.multi",
15057+
"when": "listMultiSelection && gitlens:repos:withRemotes && viewItem =~ /gitlens:tag\\b(.*?\\b\\+remote\\b)/",
15058+
"group": "3_gitlens_explore@2"
15059+
},
1500315060
{
1500415061
"submenu": "gitlens/share",
1500515062
"when": "viewItem =~ /gitlens:(branch|commit|compare:(branch(?=.*?\\b\\+comparing\\b)|results(:commits(?!:)|(?!:)))|remote|repo-folder|repository|stash|status:upstream|tag|workspace|file\\b(?=.*?\\b\\+committed\\b))\\b/",

src/commands.ts

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import './commands/openBranchOnRemote';
3333
import './commands/openCurrentBranchOnRemote';
3434
import './commands/openChangedFiles';
3535
import './commands/openCommitOnRemote';
36+
import './commands/openTagOnRemote';
3637
import './commands/openComparisonOnRemote';
3738
import './commands/openFileFromRemote';
3839
import './commands/openFileOnRemote';

src/commands/openTagOnRemote.ts

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import type { TextEditor, Uri } from 'vscode';
2+
import { Commands } from '../constants.commands';
3+
import type { Container } from '../container';
4+
import { GitUri } from '../git/gitUri';
5+
// import { getTagNameWithoutRemote, getRemoteNameFromTagName } from '../git/models/tag';
6+
import { RemoteResourceType } from '../git/models/remoteResource';
7+
import { showGenericErrorMessage } from '../messages';
8+
import { CommandQuickPickItem } from '../quickpicks/items/common';
9+
import { ReferencesQuickPickIncludes, showReferencePicker } from '../quickpicks/referencePicker';
10+
import { getBestRepositoryOrShowPicker } from '../quickpicks/repositoryPicker';
11+
import { Logger } from '../system/logger';
12+
import { command, executeCommand } from '../system/vscode/command';
13+
import type { CommandContext } from './base';
14+
import { ActiveEditorCommand, getCommandUri, isCommandContextViewNodeHasTag } from './base';
15+
import type { OpenOnRemoteCommandArgs } from './openOnRemote';
16+
17+
export interface OpenTagOnRemoteCommandArgs {
18+
tag?: string;
19+
clipboard?: boolean;
20+
remote?: string;
21+
}
22+
23+
@command()
24+
export class OpenTagOnRemoteCommand extends ActiveEditorCommand {
25+
constructor(private readonly container: Container) {
26+
super([Commands.OpenTagOnRemote, Commands.CopyRemoteTagUrl]);
27+
}
28+
29+
protected override preExecute(context: CommandContext, args?: OpenTagOnRemoteCommandArgs) {
30+
if (isCommandContextViewNodeHasTag(context)) {
31+
args = {
32+
...args,
33+
tag: context.node.tag.name,
34+
remote: context.node.tag.name,
35+
};
36+
}
37+
38+
if (context.command === Commands.CopyRemoteTagUrl) {
39+
args = { ...args, clipboard: true };
40+
}
41+
42+
return this.execute(context.editor, context.uri, args);
43+
}
44+
45+
async execute(editor?: TextEditor, uri?: Uri, args?: OpenTagOnRemoteCommandArgs) {
46+
uri = getCommandUri(uri, editor);
47+
48+
const gitUri = uri != null ? await GitUri.fromUri(uri) : undefined;
49+
50+
const repoPath = (
51+
await getBestRepositoryOrShowPicker(
52+
gitUri,
53+
editor,
54+
args?.clipboard ? 'Copy Remote Tag URL' : 'Open Tag On Remote',
55+
)
56+
)?.path;
57+
if (!repoPath) return;
58+
59+
args = { ...args };
60+
61+
try {
62+
if (args.tag == null) {
63+
const pick = await showReferencePicker(
64+
repoPath,
65+
args.clipboard ? 'Copy Remote Tag URL' : 'Open Tag On Remote',
66+
args.clipboard ? 'Choose a Tag to copy the URL from' : 'Choose a Tag to open',
67+
{
68+
autoPick: true,
69+
filter: { tags: () => true, branches: () => false },
70+
include: ReferencesQuickPickIncludes.Tags,
71+
sort: { tags: { current: true } },
72+
},
73+
);
74+
if (pick == null || pick instanceof CommandQuickPickItem) return;
75+
76+
if (pick.refType === 'tag') {
77+
args.tag = pick.name;
78+
} else {
79+
args.tag = pick.ref;
80+
}
81+
}
82+
83+
void (await executeCommand<OpenOnRemoteCommandArgs>(Commands.OpenOnRemote, {
84+
resource: {
85+
type: RemoteResourceType.Tag,
86+
tag: args.tag,
87+
},
88+
repoPath: repoPath,
89+
remote: args.remote,
90+
clipboard: args.clipboard,
91+
}));
92+
} catch (ex) {
93+
Logger.error(ex, 'OpenTagOnRemoteCommand');
94+
void showGenericErrorMessage('Unable to open Tag on remote provider');
95+
}
96+
}
97+
}

src/config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ export interface RemotesUrlsConfig {
587587
export type SuppressedMessages =
588588
| 'suppressCommitHasNoPreviousCommitWarning'
589589
| 'suppressCommitNotFoundWarning'
590+
| 'suppressTagNotFoundWarning'
590591
| 'suppressCreatePullRequestPrompt'
591592
| 'suppressDebugLoggingWarning'
592593
| 'suppressFileNotUnderSourceControlWarning'

src/constants.commands.ts

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const enum Commands {
2929
CopyRemoteBranchesUrl = 'gitlens.copyRemoteBranchesUrl',
3030
CopyRemoteBranchUrl = 'gitlens.copyRemoteBranchUrl',
3131
CopyRemoteCommitUrl = 'gitlens.copyRemoteCommitUrl',
32+
CopyRemoteTagUrl = 'gitlens.copyRemoteTagUrl',
3233
CopyRemoteComparisonUrl = 'gitlens.copyRemoteComparisonUrl',
3334
CopyRemoteFileUrl = 'gitlens.copyRemoteFileUrlToClipboard',
3435
CopyRemoteFileUrlWithoutRange = 'gitlens.copyRemoteFileUrlWithoutRange',
@@ -81,6 +82,7 @@ export const enum Commands {
8182
OpenCurrentBranchOnRemote = 'gitlens.openCurrentBranchOnRemote',
8283
OpenChangedFiles = 'gitlens.openChangedFiles',
8384
OpenCommitOnRemote = 'gitlens.openCommitOnRemote',
85+
OpenTagOnRemote = 'gitlens.openTagOnRemote',
8486
OpenComparisonOnRemote = 'gitlens.openComparisonOnRemote',
8587
OpenFileHistory = 'gitlens.openFileHistory',
8688
OpenFileFromRemote = 'gitlens.openFileFromRemote',

src/git/remotes/azure-devops.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ export class AzureDevOpsRemote extends RemoteProvider {
202202
return this.encodeUrl(`${this.baseUrl}?path=/${fileName}${line}`);
203203
}
204204

205-
protected override getUrlForTag(tagName: string): string {
206-
return this.encodeUrl(`${this.baseUrl}?version=GT${tagName}`);
205+
protected override getUrlForTag(tag: string): string {
206+
return this.encodeUrl(`${this.baseUrl}?version=GT${tag}`);
207207
}
208208
}

src/git/remotes/bitbucket-server.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export class BitbucketServerRemote extends RemoteProvider {
172172
return `${this.encodeUrl(`${this.baseUrl}/browse/${fileName}`)}${line}`;
173173
}
174174

175-
protected override getUrlForTag(tagName: string): string {
176-
return this.encodeUrl(`${this.baseUrl}/commits/tag/${tagName}`);
175+
protected override getUrlForTag(tag: string): string {
176+
return this.encodeUrl(`${this.baseUrl}/commits/tag/${tag}`);
177177
}
178178
}

src/git/remotes/bitbucket.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export class BitbucketRemote extends RemoteProvider {
158158
return `${this.encodeUrl(`${this.baseUrl}?path=${fileName}`)}${line}`;
159159
}
160160

161-
protected override getUrlForTag(tagName: string): string {
162-
return this.encodeUrl(`${this.baseUrl}/commits/tag/${tagName}`);
161+
protected override getUrlForTag(tag: string): string {
162+
return this.encodeUrl(`${this.baseUrl}/commits/tag/${tag}`);
163163
}
164164
}

src/git/remotes/custom.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ 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 }));
103+
protected override getUrlForTag(tag: string): string {
104+
return this.getUrl(this.urls.tag, this.getContext({ tag: tag }));
105105
}
106106

107107
private getUrl(template: string, context: Record<string, string>): string {

src/git/remotes/gitea.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export class GiteaRemote extends RemoteProvider {
156156
return `${this.encodeUrl(`${this.baseUrl}/src/${fileName}`)}${line}`;
157157
}
158158

159-
protected getUrlForTag(tagName: string): string {
160-
return this.encodeUrl(`${this.baseUrl}/releases/tag/${tagName}`);
159+
protected getUrlForTag(tag: string): string {
160+
return this.encodeUrl(`${this.baseUrl}/releases/tag/${tag}`);
161161
}
162162
}

src/git/remotes/github.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ export class GitHubRemote extends RemoteProvider<GitHubRepositoryDescriptor> {
298298
if (branch) return `${this.encodeUrl(`${this.baseUrl}/blob/${branch}/${fileName}`)}${line}`;
299299
return `${this.encodeUrl(`${this.baseUrl}?path=${fileName}`)}${line}`;
300300
}
301-
protected override getUrlForTag(tagName: string) {
302-
return this.encodeUrl(`${this.baseUrl}/releases/tag/${tagName}`);
301+
protected override getUrlForTag(tag: string) {
302+
return this.encodeUrl(`${this.baseUrl}/releases/tag/${tag}`);
303303
}
304304
}
305305

src/git/remotes/gitlab.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ export class GitLabRemote extends RemoteProvider<GitLabRepositoryDescriptor> {
383383
return `${this.encodeUrl(`${this.baseUrl}?path=${fileName}`)}${line}`;
384384
}
385385

386-
protected override getUrlForTag(tagName: string) {
387-
return this.encodeUrl(`${this.baseUrl}/-/tags/${tagName}`);
386+
protected override getUrlForTag(tag: string) {
387+
return this.encodeUrl(`${this.baseUrl}/-/tags/${tag}`);
388388
}
389389
}

src/git/remotes/remoteProvider.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export abstract class RemoteProvider<T extends ResourceDescriptor = ResourceDesc
174174
): string | undefined;
175175

176176
protected abstract getUrlForFile(fileName: string, branch?: string, sha?: string, range?: Range): string;
177-
protected abstract getUrlForTag(tagName: string): string | undefined;
177+
protected abstract getUrlForTag(tag: string): string | undefined;
178178

179179
protected getUrlForRepository(): string {
180180
return this.baseUrl;

src/messages.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ export function showCommitHasNoPreviousCommitWarningMessage(commit?: GitCommit):
4242
}
4343

4444
export function showCommitNotFoundWarningMessage(message: string): Promise<MessageItem | undefined> {
45-
return showMessage('warn', `${message}. The commit could not be found.`, 'suppressCommitNotFoundWarning');
45+
return showMessage('warn', `${message}. The tag commit not be found.`, 'suppressCommitNotFoundWarning');
46+
}
47+
48+
export function showTagNotFoundWarningMessage(message: string): Promise<MessageItem | undefined> {
49+
return showMessage('warn', `${message}. The tag could not be found.`, 'suppressTagNotFoundWarning');
4650
}
4751

4852
export async function showCreatePullRequestPrompt(branch: string): Promise<boolean> {

src/views/nodes/tagsNode.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ export class TagsNode extends CacheableChildrenViewNode<'tags', ViewsWithTagsNod
3434
}
3535

3636
async getChildren(): Promise<ViewNode[]> {
37-
const remote = await this.repo.git.getBestRemoteWithProvider();
3837
if (this.children == null) {
3938
const tags = await this.repo.git.getTags({ sort: true });
4039
if (tags.values.length === 0) return [new MessageNode(this.view, this, 'No tags could be found.')];
40+
const remote = await this.repo.git.getBestRemoteWithProvider();
4141
// TODO@eamodio handle paging
4242
const tagNodes = tags.values.map(
4343
t =>

src/views/viewCommands.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,27 @@ export class ViewCommands implements Disposable {
259259
(n, nodes) => this.openCommitOnRemote(n, nodes),
260260
this,
261261
),
262-
registerViewCommand('gitlens.views.openTagOnRemote', (n, nodes) => this.openTagOnRemote(n, nodes), this),
263262
registerViewCommand(
264263
'gitlens.views.openCommitOnRemote.multi',
265264
(n, nodes) => this.openCommitOnRemote(n, nodes),
266265
this,
267266
),
267+
registerViewCommand('gitlens.views.openTagOnRemote', (n, nodes) => this.openTagOnRemote(n, nodes), this),
268+
registerViewCommand(
269+
'gitlens.views.openTagOnRemote.multi',
270+
(n, nodes) => this.openTagOnRemote(n, nodes),
271+
this,
272+
),
273+
registerViewCommand(
274+
'gitlens.views.copyRemoteTagUrl',
275+
(n, nodes) => this.openTagOnRemote(n, nodes, true),
276+
this,
277+
),
278+
registerViewCommand(
279+
'gitlens.views.copyRemoteTagUrl.multi',
280+
(n, nodes) => this.openTagOnRemote(n, nodes, true),
281+
this,
282+
),
268283

269284
registerViewCommand('gitlens.views.openChanges', this.openChanges, this),
270285
registerViewCommand('gitlens.views.openChangesWithWorking', this.openChangesWithWorking, this),

0 commit comments

Comments
 (0)