Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 18 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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...",
Expand Down Expand Up @@ -12432,6 +12439,10 @@
"command": "gitlens.graph.switchToTag",
"when": "false"
},
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

"command": "gitlens.graph.resetToTag",
"when": "false"
},
{
"command": "gitlens.graph.createWorktree",
"when": "false"
Expand Down Expand Up @@ -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/",
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/commands/git/reset.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -31,7 +31,7 @@ type Flags = '--hard' | '--soft';

interface State {
repo: string | Repository;
reference: GitRevisionReference;
reference: GitRevisionReference | GitTagReference;
flags: Flags[];
}

Expand Down
4 changes: 2 additions & 2 deletions src/git/actions/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]) {
Expand Down Expand Up @@ -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<ResetGitCommandArgs['state']>['flags'],
) {
return executeGitCommand({
Expand Down
8 changes: 8 additions & 0 deletions src/plus/webviews/graph/graphWebview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,7 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
this.host.registerWebviewCommand('gitlens.graph.createTag', this.createTag),
this.host.registerWebviewCommand('gitlens.graph.deleteTag', this.deleteTag),
this.host.registerWebviewCommand('gitlens.graph.switchToTag', this.switchTo),
this.host.registerWebviewCommand('gitlens.graph.resetToTag', this.resetToTag),

this.host.registerWebviewCommand('gitlens.graph.createWorktree', this.createWorktree),

Expand Down Expand Up @@ -3339,6 +3340,13 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
return RepoActions.switchTo(ref.repoPath, ref);
}

@log()
private resetToTag(item?: GraphItemContext) {
const ref = this.getGraphItemRef(item, 'tag');
if (ref == null) return Promise.resolve();
return RepoActions.reset(ref.repoPath, ref);
}

@log()
private hideRef(item?: GraphItemContext, options?: { group?: boolean; remote?: boolean }) {
let refs;
Expand Down
Loading