Skip to content

Commit

Permalink
Add 'Delete / Delete (keep local)' context menu options
Browse files Browse the repository at this point in the history
  • Loading branch information
Samir L. Boulema committed Jan 28, 2020
1 parent bac19e6 commit 51cb93e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
18 changes: 18 additions & 0 deletions TGit/Commands/ContextMenuCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public void AddCommands()
CommandHelper.AddCommand(_mcs, CommitContextCommand, PkgCmdIDList.CommitContext, ActiveDocument_BeforeQueryStatus);
CommandHelper.AddCommand(_mcs, RevertContextCommand, PkgCmdIDList.RevertContext, ActiveDocument_BeforeQueryStatus);
CommandHelper.AddCommand(_mcs, AddContextCommand, PkgCmdIDList.AddContext, ActiveDocument_BeforeQueryStatus);
CommandHelper.AddCommand(_mcs, DeleteContextCommand, PkgCmdIDList.DeleteContext, ActiveDocument_BeforeQueryStatus);
CommandHelper.AddCommand(_mcs, DeleteKeepContextCommand, PkgCmdIDList.DeleteKeepContext, ActiveDocument_BeforeQueryStatus);
CommandHelper.AddCommand(_mcs, DiffContextCommand, PkgCmdIDList.DiffContext, ActiveDocument_BeforeQueryStatus);
CommandHelper.AddCommand(_mcs, PrefDiffContextCommand, PkgCmdIDList.PrefDiffContext, ActiveDocument_BeforeQueryStatus);
}
Expand Down Expand Up @@ -105,6 +107,22 @@ private void AddContextCommand(object sender, EventArgs e)
_dte.ActiveDocument.Save();
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:add /path:\"{currentFilePath}\"");
}
private void DeleteContextCommand(object sender, EventArgs e)
{
var currentFilePath = _dte.ActiveDocument.FullName;
if (string.IsNullOrEmpty(currentFilePath)) return;
if (!_dte.ActiveDocument.Saved)
_dte.ActiveDocument.Save();
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:remove /path:\"{currentFilePath}\"");
}
private void DeleteKeepContextCommand(object sender, EventArgs e)
{
var currentFilePath = _dte.ActiveDocument.FullName;
if (string.IsNullOrEmpty(currentFilePath)) return;
if (!_dte.ActiveDocument.Saved)
_dte.ActiveDocument.Save();
ProcessHelper.StartTortoiseGitProc(_envHelper, $"/command:remove /keep /path:\"{currentFilePath}\"");
}
private void FetchContextCommand(object sender, EventArgs e)
{
var currentFilePath = _dte.ActiveDocument.FullName;
Expand Down
2 changes: 2 additions & 0 deletions TGit/PkgCmdID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,7 @@ static class PkgCmdIDList
public const uint RevGraph = 0x148;

public const uint AddContext = 0x150;
public const uint DeleteContext = 0x151;
public const uint DeleteKeepContext = 0x152;
}
}
16 changes: 16 additions & 0 deletions TGit/TGIT.vsct
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,20 @@
<ButtonText>Add File...</ButtonText>
</Strings>
</Button>
<Button guid="guidTGitCmdSet" id="deleteContext" priority="0x0400" type="Button">
<Parent guid="guidTGitCmdSet" id="fourthContextMenuGroup" />
<Icon guid="guidImages" id="cleanup" />
<Strings>
<ButtonText>Delete File...</ButtonText>
</Strings>
</Button>
<Button guid="guidTGitCmdSet" id="deleteKeepContext" priority="0x0400" type="Button">
<Parent guid="guidTGitCmdSet" id="fourthContextMenuGroup" />
<Icon guid="guidImages" id="cleanup" />
<Strings>
<ButtonText>Delete File (keep local)...</ButtonText>
</Strings>
</Button>
<Button guid="guidTGitCmdSet" id="diffContext" priority="0x0500" type="Button">
<Parent guid="guidTGitCmdSet" id="fourthContextMenuGroup" />
<Icon guid="guidImages" id="differences" />
Expand Down Expand Up @@ -689,6 +703,8 @@
<IDSymbol name="rebase" value="0x0146" />

<IDSymbol name="addContext" value="0x0150" />
<IDSymbol name="deleteContext" value="0x0151" />
<IDSymbol name="deleteKeepContext" value="0x0152" />
</GuidSymbol>
</Symbols>
</CommandTable>

0 comments on commit 51cb93e

Please sign in to comment.