From 1fd62bda1e7bea6158b23f92b39cbf0924d89e74 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Wed, 8 Mar 2023 15:38:03 -0500 Subject: [PATCH] Adds Open Git Worktree command --- CHANGELOG.md | 1 + package.json | 9 +++++++++ src/commands/gitCommands.ts | 4 ++++ src/constants.ts | 1 + 4 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f2baee..b0a13f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ### Added - Adds an experimental _Generate Commit Message (Experimental)_ command to use OpenAI to generate a commit message for staged changes — currently only available in the pre-release edition +- Adds a _Open Git Worktree..._ command to jump directly to opening a worktree in the _Git Command Palette_ ### Fixed diff --git a/package.json b/package.json index 08efce4..b584b52 100644 --- a/package.json +++ b/package.json @@ -4953,6 +4953,11 @@ "category": "GitLens+" }, { + "command": "gitlens.gitCommands.worktree.open", + "title": "Open Git Worktree...", + "category": "GitLens+" + }, + { "command": "gitlens.switchMode", "title": "Switch Mode", "category": "GitLens" @@ -7737,6 +7742,10 @@ "when": "!gitlens:disabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders" }, { + "command": "gitlens.gitCommands.worktree.open", + "when": "!gitlens:disabled && !gitlens:readonly && !gitlens:untrusted && !gitlens:hasVirtualFolders" + }, + { "command": "gitlens.switchMode", "when": "gitlens:enabled" }, diff --git a/src/commands/gitCommands.ts b/src/commands/gitCommands.ts index 28c1c16..df23a57 100644 --- a/src/commands/gitCommands.ts +++ b/src/commands/gitCommands.ts @@ -82,6 +82,7 @@ export class GitCommandsCommand extends Command { Commands.GitCommandsSwitch, Commands.GitCommandsTag, Commands.GitCommandsWorktree, + Commands.GitCommandsWorktreeOpen, ]); } @@ -114,6 +115,9 @@ export class GitCommandsCommand extends Command { case Commands.GitCommandsWorktree: args = { command: 'worktree' }; break; + case Commands.GitCommandsWorktreeOpen: + args = { command: 'worktree', state: { subcommand: 'open' } }; + break; } return this.execute(args); diff --git a/src/constants.ts b/src/constants.ts index 64d886d..8366957 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -172,6 +172,7 @@ export const enum Commands { GitCommandsSwitch = 'gitlens.gitCommands.switch', GitCommandsTag = 'gitlens.gitCommands.tag', GitCommandsWorktree = 'gitlens.gitCommands.worktree', + GitCommandsWorktreeOpen = 'gitlens.gitCommands.worktree.open', OpenOrCreateWorktreeForGHPR = 'gitlens.ghpr.views.openOrCreateWorktree', PlusHide = 'gitlens.plus.hide', PlusLearn = 'gitlens.plus.learn',