diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a0c55a8139d9..d514458516d09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ## [16.0.1] - 2024-11-15 +### Added + +- Adds context menu command in _Commit Graph_ to reset Current Branch to a tag. + ### Changed - Changes the _Search & Compare_ view to be separate (detached) from the new grouped _GitLens_ view diff --git a/package.json b/package.json index 68d081c40e247..a66451bb79512 100644 --- a/package.json +++ b/package.json @@ -9014,6 +9014,13 @@ "title": "Reset Current Branch to Commit...", "enablement": "!operationInProgress" }, + { + "command": "gitlens.graph.resetToTag", + "title": "Reset Current Branch to Tag...", + "category": "GitLens", + "icon": "$(gitlens-reset)", + "enablement": "!operationInProgress" + }, { "command": "gitlens.graph.resetToTip", "title": "Reset Current Branch to Tip...", @@ -12432,6 +12439,10 @@ "command": "gitlens.graph.switchToTag", "when": "false" }, + { + "command": "gitlens.graph.resetToTag", + "when": "false" + }, { "command": "gitlens.graph.createWorktree", "when": "false" @@ -16292,6 +16303,11 @@ "when": "!listMultiSelection && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && webviewItem =~ /gitlens:commit\\b/", "group": "1_gitlens_actions@4" }, + { + "command": "gitlens.graph.resetToTag", + "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && !listMultiSelection && webviewItem =~ /gitlens:tag\\b/", + "group": "1_gitlens_actions@2" + }, { "command": "gitlens.graph.resetToTip", "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && webviewItem =~ /gitlens:branch\\b/", @@ -16415,12 +16431,12 @@ { "command": "gitlens.graph.deleteTag", "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && webviewItem == gitlens:tag", - "group": "1_gitlens_actions@2" + "group": "1_gitlens_actions@3" }, { "command": "gitlens.graph.createBranch", "when": "!gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders && webviewItem =~ /gitlens:tag\\b/", - "group": "1_gitlens_actions@3" + "group": "1_gitlens_actions@4" }, { "command": "gitlens.graph.hideTag", diff --git a/src/commands/git/reset.ts b/src/commands/git/reset.ts index 06d8babe628c9..67fd346d9b464 100644 --- a/src/commands/git/reset.ts +++ b/src/commands/git/reset.ts @@ -1,7 +1,7 @@ import type { Container } from '../../container'; import type { GitBranch } from '../../git/models/branch'; import type { GitLog } from '../../git/models/log'; -import type { GitReference, GitRevisionReference } from '../../git/models/reference'; +import type { GitReference, GitRevisionReference, GitTagReference } from '../../git/models/reference'; import { getReferenceLabel } from '../../git/models/reference'; import type { Repository } from '../../git/models/repository'; import type { FlagsQuickPickItem } from '../../quickpicks/items/flags'; @@ -31,7 +31,7 @@ type Flags = '--hard' | '--soft'; interface State { repo: string | Repository; - reference: GitRevisionReference; + reference: GitRevisionReference | GitTagReference; flags: Flags[]; } diff --git a/src/git/actions/repository.ts b/src/git/actions/repository.ts index 6a45fb36653c9..dd2a4e92fc1f3 100644 --- a/src/git/actions/repository.ts +++ b/src/git/actions/repository.ts @@ -2,7 +2,7 @@ import type { ResetGitCommandArgs } from '../../commands/git/reset'; import { Container } from '../../container'; import type { ViewsWithRepositoryFolders } from '../../views/viewBase'; import { executeGitCommand } from '../actions'; -import type { GitBranchReference, GitReference, GitRevisionReference } from '../models/reference'; +import type { GitBranchReference, GitReference, GitRevisionReference, GitTagReference } from '../models/reference'; import type { Repository } from '../models/repository'; export function cherryPick(repo?: string | Repository, refs?: GitRevisionReference | GitRevisionReference[]) { @@ -40,7 +40,7 @@ export function rebase(repo?: string | Repository, ref?: GitReference, interacti export function reset( repo?: string | Repository, - ref?: GitRevisionReference, + ref?: GitRevisionReference | GitTagReference, flags?: NonNullable['flags'], ) { return executeGitCommand({ diff --git a/src/plus/webviews/graph/graphWebview.ts b/src/plus/webviews/graph/graphWebview.ts index 635a8570e47ba..c6e7a6dbe8566 100644 --- a/src/plus/webviews/graph/graphWebview.ts +++ b/src/plus/webviews/graph/graphWebview.ts @@ -554,6 +554,7 @@ export class GraphWebviewProvider implements WebviewProvider