-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds Open tag on remote option to tagView #3768
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3668,7 +3668,8 @@ | |
"fileInCommit", | ||
"fileInBranch", | ||
"fileLine", | ||
"fileRange" | ||
"fileRange", | ||
"tag" | ||
], | ||
"properties": { | ||
"repository": { | ||
|
@@ -3706,6 +3707,10 @@ | |
"fileRange": { | ||
"type": "string", | ||
"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" | ||
}, | ||
"tag": { | ||
"type": "string", | ||
"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" | ||
} | ||
}, | ||
"additionalProperties": false | ||
|
@@ -6757,6 +6762,22 @@ | |
"title": "Open Commits on Remote", | ||
"icon": "$(globe)" | ||
}, | ||
{ | ||
"command": "gitlens.openTagOnRemote", | ||
"title": "Open Tag on Remote", | ||
"category": "GitLens", | ||
"icon": "$(globe)" | ||
}, | ||
{ | ||
"command": "gitlens.views.openTagOnRemote", | ||
"title": "Open Tag on Remote", | ||
"icon": "$(globe)" | ||
}, | ||
{ | ||
"command": "gitlens.views.openTagOnRemote.multi", | ||
"title": "Open Tags on Remote", | ||
"icon": "$(globe)" | ||
}, | ||
{ | ||
"command": "gitlens.copyRemoteCommitUrl", | ||
"title": "Copy Remote Commit URL", | ||
|
@@ -6773,6 +6794,22 @@ | |
"title": "Copy Remote Commit URLs", | ||
"icon": "$(copy)" | ||
}, | ||
{ | ||
"command": "gitlens.copyRemoteTagUrl", | ||
"title": "Copy Remote Tag URL", | ||
"category": "GitLens", | ||
"icon": "$(copy)" | ||
}, | ||
{ | ||
"command": "gitlens.views.copyRemoteTagUrl", | ||
"title": "Copy Remote Tag URL", | ||
"icon": "$(copy)" | ||
}, | ||
{ | ||
"command": "gitlens.views.copyRemoteTagUrl.multi", | ||
"title": "Copy Remote Tag URLs", | ||
"icon": "$(copy)" | ||
}, | ||
{ | ||
"command": "gitlens.openComparisonOnRemote", | ||
"title": "Open Comparison on Remote", | ||
|
@@ -10560,6 +10597,18 @@ | |
"command": "gitlens.views.openCommitOnRemote.multi", | ||
"when": "false" | ||
}, | ||
{ | ||
"command": "gitlens.openTagOnRemote", | ||
"when": "gitlens:repos:withRemotes" | ||
}, | ||
{ | ||
"command": "gitlens.views.openTagOnRemote", | ||
"when": "false" | ||
}, | ||
{ | ||
"command": "gitlens.views.openTagOnRemote.multi", | ||
"when": "false" | ||
}, | ||
{ | ||
"command": "gitlens.copyRemoteCommitUrl", | ||
"when": "gitlens:repos:withRemotes" | ||
|
@@ -10572,6 +10621,14 @@ | |
"command": "gitlens.views.copyRemoteCommitUrl.multi", | ||
"when": "false" | ||
}, | ||
{ | ||
"command": "gitlens.views.copyRemoteTagUrl", | ||
"when": "false" | ||
}, | ||
{ | ||
"command": "gitlens.views.copyRemoteTagUrl.multi", | ||
"when": "false" | ||
}, | ||
{ | ||
"command": "gitlens.openComparisonOnRemote", | ||
"when": "false" | ||
|
@@ -14868,6 +14925,12 @@ | |
"group": "inline@99", | ||
"alt": "gitlens.views.copyRemoteCommitUrl" | ||
}, | ||
{ | ||
"command": "gitlens.views.openTagOnRemote", | ||
"when": "gitlens:repos:withRemotes && viewItem =~ /gitlens:tag\\b(.*?\\b\\+remote\\b)/", | ||
"group": "inline@99", | ||
"alt": "gitlens.views.copyRemoteTagUrl" | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs to also follow the commit[s] pattern to add this to the context menu as well |
||
{ | ||
"command": "gitlens.views.cherryPick", | ||
"when": "!listMultiSelection && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && viewItem =~ /gitlens:commit\\b(?!.*?\\b\\+(current|rebase)\\b)/", | ||
|
@@ -14984,6 +15047,16 @@ | |
"when": "listMultiSelection && gitlens:repos:withRemotes && viewItem =~ /gitlens:commit\\b/", | ||
"group": "3_gitlens_explore@2" | ||
}, | ||
{ | ||
"command": "gitlens.views.openTagOnRemote", | ||
"when": "!listMultiSelection && gitlens:repos:withRemotes && viewItem =~ /gitlens:tag\\b(.*?\\b\\+remote\\b)/", | ||
"group": "3_gitlens_explore@2" | ||
}, | ||
{ | ||
"command": "gitlens.views.openTagOnRemote.multi", | ||
"when": "listMultiSelection && gitlens:repos:withRemotes && viewItem =~ /gitlens:tag\\b(.*?\\b\\+remote\\b)/", | ||
"group": "3_gitlens_explore@2" | ||
}, | ||
{ | ||
"submenu": "gitlens/share", | ||
"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/", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import type { TextEditor, Uri } from 'vscode'; | ||
import { Commands } from '../constants.commands'; | ||
import type { Container } from '../container'; | ||
import { GitUri } from '../git/gitUri'; | ||
// import { getTagNameWithoutRemote, getRemoteNameFromTagName } from '../git/models/tag'; | ||
import { RemoteResourceType } from '../git/models/remoteResource'; | ||
import { showGenericErrorMessage } from '../messages'; | ||
import { CommandQuickPickItem } from '../quickpicks/items/common'; | ||
import { ReferencesQuickPickIncludes, showReferencePicker } from '../quickpicks/referencePicker'; | ||
import { getBestRepositoryOrShowPicker } from '../quickpicks/repositoryPicker'; | ||
import { Logger } from '../system/logger'; | ||
import { command, executeCommand } from '../system/vscode/command'; | ||
import type { CommandContext } from './base'; | ||
import { ActiveEditorCommand, getCommandUri, isCommandContextViewNodeHasTag } from './base'; | ||
import type { OpenOnRemoteCommandArgs } from './openOnRemote'; | ||
|
||
export interface OpenTagOnRemoteCommandArgs { | ||
tag?: string; | ||
clipboard?: boolean; | ||
remote?: string; | ||
} | ||
|
||
@command() | ||
export class OpenTagOnRemoteCommand extends ActiveEditorCommand { | ||
constructor(private readonly container: Container) { | ||
super([Commands.OpenTagOnRemote, Commands.CopyRemoteTagUrl]); | ||
} | ||
|
||
protected override preExecute(context: CommandContext, args?: OpenTagOnRemoteCommandArgs) { | ||
if (isCommandContextViewNodeHasTag(context)) { | ||
args = { | ||
...args, | ||
tag: context.node.tag.name, | ||
remote: context.node.tag.name, | ||
}; | ||
} | ||
|
||
if (context.command === Commands.CopyRemoteTagUrl) { | ||
args = { ...args, clipboard: true }; | ||
} | ||
|
||
return this.execute(context.editor, context.uri, args); | ||
} | ||
|
||
async execute(editor?: TextEditor, uri?: Uri, args?: OpenTagOnRemoteCommandArgs) { | ||
uri = getCommandUri(uri, editor); | ||
|
||
const gitUri = uri != null ? await GitUri.fromUri(uri) : undefined; | ||
|
||
const repoPath = ( | ||
await getBestRepositoryOrShowPicker( | ||
gitUri, | ||
editor, | ||
args?.clipboard ? 'Copy Remote Tag URL' : 'Open Tag On Remote', | ||
) | ||
)?.path; | ||
if (!repoPath) return; | ||
|
||
args = { ...args }; | ||
|
||
try { | ||
if (args.tag == null) { | ||
const pick = await showReferencePicker( | ||
repoPath, | ||
args.clipboard ? 'Copy Remote Tag URL' : 'Open Tag On Remote', | ||
args.clipboard ? 'Choose a Tag to copy the URL from' : 'Choose a Tag to open', | ||
{ | ||
autoPick: true, | ||
filter: { tags: () => true, branches: () => false }, | ||
include: ReferencesQuickPickIncludes.Tags, | ||
sort: { tags: { current: true } }, | ||
}, | ||
); | ||
if (pick == null || pick instanceof CommandQuickPickItem) return; | ||
|
||
if (pick.refType === 'tag') { | ||
args.tag = pick.name; | ||
} else { | ||
args.tag = pick.ref; | ||
} | ||
} | ||
|
||
void (await executeCommand<OpenOnRemoteCommandArgs>(Commands.OpenOnRemote, { | ||
resource: { | ||
type: RemoteResourceType.Tag, | ||
tag: args.tag, | ||
}, | ||
repoPath: repoPath, | ||
remote: args.remote, | ||
clipboard: args.clipboard, | ||
})); | ||
} catch (ex) { | ||
Logger.error(ex, 'OpenTagOnRemoteCommand'); | ||
void showGenericErrorMessage('Unable to open Tag on remote provider'); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -580,12 +580,14 @@ export interface RemotesUrlsConfig { | |
readonly fileInCommit: string; | ||
readonly fileLine: string; | ||
readonly fileRange: string; | ||
readonly tag: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is correct once |
||
} | ||
|
||
// NOTE: Must be kept in sync with `gitlens.advanced.messages` setting in the package.json | ||
export type SuppressedMessages = | ||
| 'suppressCommitHasNoPreviousCommitWarning' | ||
| 'suppressCommitNotFoundWarning' | ||
| 'suppressTagNotFoundWarning' | ||
| 'suppressCreatePullRequestPrompt' | ||
| 'suppressDebugLoggingWarning' | ||
| 'suppressFileNotUnderSourceControlWarning' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,4 +191,8 @@ export class GerritRemote extends RemoteProvider { | |
if (branch) return `${this.encodeUrl(`${this.getUrlForBranch(branch)}/${fileName}`)}${line}`; | ||
return `${this.encodeUrl(`${this.baseUrl}/+/HEAD/${fileName}`)}${line}`; | ||
} | ||
|
||
protected override getUrlForTag(): string | undefined { | ||
return undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there no support for tags? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no tag details view for gerrit, only tags list view |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also add
gitlens.views.openTagOnRemote.multi
command to follow the pattern of commit[s]There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added