Skip to content

Commit 51cb93e

Browse files
author
Samir L. Boulema
committed
Add 'Delete / Delete (keep local)' context menu options
1 parent bac19e6 commit 51cb93e

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

TGit/Commands/ContextMenuCommands.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public void AddCommands()
3939
CommandHelper.AddCommand(_mcs, CommitContextCommand, PkgCmdIDList.CommitContext, ActiveDocument_BeforeQueryStatus);
4040
CommandHelper.AddCommand(_mcs, RevertContextCommand, PkgCmdIDList.RevertContext, ActiveDocument_BeforeQueryStatus);
4141
CommandHelper.AddCommand(_mcs, AddContextCommand, PkgCmdIDList.AddContext, ActiveDocument_BeforeQueryStatus);
42+
CommandHelper.AddCommand(_mcs, DeleteContextCommand, PkgCmdIDList.DeleteContext, ActiveDocument_BeforeQueryStatus);
43+
CommandHelper.AddCommand(_mcs, DeleteKeepContextCommand, PkgCmdIDList.DeleteKeepContext, ActiveDocument_BeforeQueryStatus);
4244
CommandHelper.AddCommand(_mcs, DiffContextCommand, PkgCmdIDList.DiffContext, ActiveDocument_BeforeQueryStatus);
4345
CommandHelper.AddCommand(_mcs, PrefDiffContextCommand, PkgCmdIDList.PrefDiffContext, ActiveDocument_BeforeQueryStatus);
4446
}
@@ -105,6 +107,22 @@ private void AddContextCommand(object sender, EventArgs e)
105107
_dte.ActiveDocument.Save();
106108
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:add /path:\"{currentFilePath}\"");
107109
}
110+
private void DeleteContextCommand(object sender, EventArgs e)
111+
{
112+
var currentFilePath = _dte.ActiveDocument.FullName;
113+
if (string.IsNullOrEmpty(currentFilePath)) return;
114+
if (!_dte.ActiveDocument.Saved)
115+
_dte.ActiveDocument.Save();
116+
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:remove /path:\"{currentFilePath}\"");
117+
}
118+
private void DeleteKeepContextCommand(object sender, EventArgs e)
119+
{
120+
var currentFilePath = _dte.ActiveDocument.FullName;
121+
if (string.IsNullOrEmpty(currentFilePath)) return;
122+
if (!_dte.ActiveDocument.Saved)
123+
_dte.ActiveDocument.Save();
124+
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:remove /keep /path:\"{currentFilePath}\"");
125+
}
108126
private void FetchContextCommand(object sender, EventArgs e)
109127
{
110128
var currentFilePath = _dte.ActiveDocument.FullName;

TGit/PkgCmdID.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,7 @@ static class PkgCmdIDList
7171
public const uint RevGraph = 0x148;
7272

7373
public const uint AddContext = 0x150;
74+
public const uint DeleteContext = 0x151;
75+
public const uint DeleteKeepContext = 0x152;
7476
}
7577
}

TGit/TGIT.vsct

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,20 @@
504504
<ButtonText>Add File...</ButtonText>
505505
</Strings>
506506
</Button>
507+
<Button guid="guidTGitCmdSet" id="deleteContext" priority="0x0400" type="Button">
508+
<Parent guid="guidTGitCmdSet" id="fourthContextMenuGroup" />
509+
<Icon guid="guidImages" id="cleanup" />
510+
<Strings>
511+
<ButtonText>Delete File...</ButtonText>
512+
</Strings>
513+
</Button>
514+
<Button guid="guidTGitCmdSet" id="deleteKeepContext" priority="0x0400" type="Button">
515+
<Parent guid="guidTGitCmdSet" id="fourthContextMenuGroup" />
516+
<Icon guid="guidImages" id="cleanup" />
517+
<Strings>
518+
<ButtonText>Delete File (keep local)...</ButtonText>
519+
</Strings>
520+
</Button>
507521
<Button guid="guidTGitCmdSet" id="diffContext" priority="0x0500" type="Button">
508522
<Parent guid="guidTGitCmdSet" id="fourthContextMenuGroup" />
509523
<Icon guid="guidImages" id="differences" />
@@ -689,6 +703,8 @@
689703
<IDSymbol name="rebase" value="0x0146" />
690704

691705
<IDSymbol name="addContext" value="0x0150" />
706+
<IDSymbol name="deleteContext" value="0x0151" />
707+
<IDSymbol name="deleteKeepContext" value="0x0152" />
692708
</GuidSymbol>
693709
</Symbols>
694710
</CommandTable>

0 commit comments

Comments
 (0)