From 86d848d8e788f109621469de5872f8bb7c12a788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moreno?= Date: Mon, 9 Nov 2020 14:45:36 +0100 Subject: [PATCH] :lipstick: --- extensions/git/package.json | 29 +++++++++++++++++++++-------- extensions/git/package.nls.json | 3 ++- extensions/git/src/commands.ts | 25 +++++++++++++------------ 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/extensions/git/package.json b/extensions/git/package.json index 10097afd5ac..e0659e26395 100644 --- a/extensions/git/package.json +++ b/extensions/git/package.json @@ -163,12 +163,6 @@ "category": "Git", "icon": "$(discard)" }, - { - "command": "git.rename", - "title": "%command.rename%", - "category": "Git", - "icon": "$(discard)" - }, { "command": "git.cleanAll", "title": "%command.cleanAll%", @@ -187,6 +181,12 @@ "category": "Git", "icon": "$(discard)" }, + { + "command": "git.rename", + "title": "%command.rename%", + "category": "Git", + "icon": "$(discard)" + }, { "command": "git.commit", "title": "%command.commit%", @@ -616,6 +616,10 @@ "command": "git.cleanAllUntracked", "when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0" }, + { + "command": "git.rename", + "when": "false" + }, { "command": "git.commit", "when": "config.git.enabled && !git.missing && gitOpenRepositoryCount != 0" @@ -1332,11 +1336,16 @@ ], "explorer/context": [ { - "command": "git.rename", - "group": "7_modification", + "submenu": "git.explorer", + "group": "7_git", "when": "config.git.enabled && !git.missing && !explorerResourceIsRoot" } ], + "git.explorer": [ + { + "command": "git.rename" + } + ], "git.commit": [ { "command": "git.commit", @@ -1555,6 +1564,10 @@ ] }, "submenus": [ + { + "id": "git.explorer", + "label": "%submenu.explorer%" + }, { "id": "git.commit", "label": "%submenu.commit%" diff --git a/extensions/git/package.nls.json b/extensions/git/package.nls.json index 26a69c3439c..7b9d6cc1166 100644 --- a/extensions/git/package.nls.json +++ b/extensions/git/package.nls.json @@ -23,7 +23,7 @@ "command.unstage": "Unstage Changes", "command.unstageAll": "Unstage All Changes", "command.unstageSelectedRanges": "Unstage Selected Ranges", - "command.rename": "Rename (Git)", + "command.rename": "Rename", "command.clean": "Discard Changes", "command.cleanAll": "Discard All Changes", "command.cleanAllTracked": "Discard All Tracked Changes", @@ -176,6 +176,7 @@ "config.timeline.date": "Controls which date to use for items in the Timeline view", "config.timeline.date.committed": "Use the committed date", "config.timeline.date.authored": "Use the authored date", + "submenu.explorer": "Git", "submenu.commit": "Commit", "submenu.commit.amend": "Amend", "submenu.commit.signoff": "Sign Off", diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index 1447ed556a6..7ef60677563 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -921,22 +921,23 @@ export class CommandCenter { @command('git.rename', { repository: true }) async rename(repository: Repository, fromUri: Uri): Promise { - this.outputChannel.appendLine(`git.rename ${fromUri.fsPath}`); - - const rootPath = workspace.rootPath; - const fromPath = workspace.asRelativePath(fromUri); - const fromBasename = path.basename(fromPath); - const toPath = await window.showInputBox({ - value: fromPath, - valueSelection: [fromPath.length - fromBasename.length, fromPath.length] + if (!fromUri) { + return; + } + + const from = path.relative(repository.root, fromUri.path); + let to = await window.showInputBox({ + value: from, + valueSelection: [from.length - path.basename(from).length, from.length] }); - if (!toPath?.trim()) { + + to = to?.trim(); + + if (!to) { return; } - const fullToPath = path.join(rootPath || '', toPath); - this.outputChannel.appendLine(`git.rename from ${fromPath} to ${fullToPath}`); - await repository.move(fromPath, fullToPath); + await repository.move(from, to); } @command('git.stage') -- GitLab