Skip to content

Commit

Permalink
Use Community Toolkit for options retrieval, Use correct KnownCommands
Browse files Browse the repository at this point in the history
  • Loading branch information
Samir L. Boulema committed Jul 30, 2021
1 parent 49177c7 commit ce74efb
Show file tree
Hide file tree
Showing 60 changed files with 187 additions and 172 deletions.
4 changes: 2 additions & 2 deletions TGit/Commands/Context/AddFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ internal sealed class AddFileCommand : BaseCommand<AddFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await KnownCommands.File_SaveSelectedItems.ExecuteAsync();
await KnownCommands.File_SaveAll.ExecuteAsync();

await ProcessHelper.RunTortoiseGitFileCommand(Package, "add");
await ProcessHelper.RunTortoiseGitFileCommand("add");
}
}
}
4 changes: 2 additions & 2 deletions TGit/Commands/Context/BlameFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ internal sealed class BlameFileCommand : BaseCommand<BlameFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await KnownCommands.File_SaveSelectedItems.ExecuteAsync();
await KnownCommands.File_SaveAll.ExecuteAsync();

await ProcessHelper.RunTortoiseGitFileCommand(Package, "blame", $"/line:{await FileHelper.GetActiveDocumentCurrentLine()}");
await ProcessHelper.RunTortoiseGitFileCommand("blame", $"/line:{await FileHelper.GetActiveDocumentCurrentLine()}");
}
}
}
6 changes: 3 additions & 3 deletions TGit/Commands/Context/CommitFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ internal sealed class CommitFileCommand : BaseCommand<CommitFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await KnownCommands.File_SaveSelectedItems.ExecuteAsync();
await KnownCommands.File_SaveAll.ExecuteAsync();

var options = (OptionPageGrid)Package.GetDialogPage(typeof(OptionPageGrid));
var options = await General.GetLiveInstanceAsync();
var commitMessage = await GitHelper.GetCommitMessage(options.CommitMessage);
var bugId = await GitHelper.GetCommitMessage(options.BugId);
var gitConfig = await GitHelper.GetGitConfig();

var args = $"{(string.IsNullOrEmpty(commitMessage) ? string.Empty : $"/logmsg:\"{commitMessage}\"")} " +
$"{(!string.IsNullOrEmpty(bugId) && !string.IsNullOrEmpty(gitConfig.BugTraqMessage) ? $"/bugid:\"{bugId}\"" : string.Empty)}";

await ProcessHelper.RunTortoiseGitFileCommand(Package, "commit", args);
await ProcessHelper.RunTortoiseGitFileCommand("commit", args);
}
}
}
2 changes: 1 addition & 1 deletion TGit/Commands/Context/DeleteFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal sealed class DeleteFileCommand : BaseCommand<DeleteFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await ProcessHelper.RunTortoiseGitFileCommand(Package, "remove");
await ProcessHelper.RunTortoiseGitFileCommand("remove");
}
}
}
2 changes: 1 addition & 1 deletion TGit/Commands/Context/DeleteKeepFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal sealed class DeleteKeepFileCommand : BaseCommand<DeleteKeepFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await ProcessHelper.RunTortoiseGitFileCommand(Package, "remove", "/keep");
await ProcessHelper.RunTortoiseGitFileCommand("remove", "/keep");
}
}
}
4 changes: 2 additions & 2 deletions TGit/Commands/Context/DiffFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ internal sealed class DiffFileCommand : BaseCommand<DiffFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await KnownCommands.File_SaveSelectedItems.ExecuteAsync();
await KnownCommands.File_SaveAll.ExecuteAsync();

await ProcessHelper.RunTortoiseGitFileCommand(Package, "diff");
await ProcessHelper.RunTortoiseGitFileCommand("diff");
}
}
}
4 changes: 2 additions & 2 deletions TGit/Commands/Context/FetchFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ internal sealed class FetchFileCommand : BaseCommand<FetchFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await KnownCommands.File_SaveSelectedItems.ExecuteAsync();
await KnownCommands.File_SaveAll.ExecuteAsync();

await ProcessHelper.RunTortoiseGitFileCommand(Package, "fetch");
await ProcessHelper.RunTortoiseGitFileCommand("fetch");
}
}
}
4 changes: 2 additions & 2 deletions TGit/Commands/Context/MergeFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ internal sealed class MergeFileCommand : BaseCommand<MergeFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await KnownCommands.File_SaveSelectedItems.ExecuteAsync();
await KnownCommands.File_SaveAll.ExecuteAsync();

await ProcessHelper.RunTortoiseGitFileCommand(Package, "merge");
await ProcessHelper.RunTortoiseGitFileCommand("merge");
}
}
}
4 changes: 2 additions & 2 deletions TGit/Commands/Context/PrefDiffFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal sealed class PrefDiffFileCommand : BaseCommand<PrefDiffFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await KnownCommands.File_SaveSelectedItems.ExecuteAsync();
await KnownCommands.File_SaveAll.ExecuteAsync();

var filePath = await FileHelper.GetActiveDocumentFilePath();
var exactFilePath = FileHelper.GetExactFileName(filePath);
Expand All @@ -25,7 +25,7 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
return;
}

await ProcessHelper.RunTortoiseGitFileCommand(Package, "diff", $"/startrev:{revisions.Split(',')[0]} /endrev:{revisions.Split(',')[1]}", exactFilePath);
await ProcessHelper.RunTortoiseGitFileCommand("diff", $"/startrev:{revisions.Split(',')[0]} /endrev:{revisions.Split(',')[1]}", exactFilePath);
}
}
}
4 changes: 2 additions & 2 deletions TGit/Commands/Context/PullFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ internal sealed class PullFileCommand : BaseCommand<PullFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await KnownCommands.File_SaveSelectedItems.ExecuteAsync();
await KnownCommands.File_SaveAll.ExecuteAsync();

await ProcessHelper.RunTortoiseGitFileCommand(Package, "pull");
await ProcessHelper.RunTortoiseGitFileCommand("pull");
}
}
}
2 changes: 1 addition & 1 deletion TGit/Commands/Context/RepoBrowserFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal sealed class RepoBrowserFileCommand : BaseCommand<RepoBrowserFileComman
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await ProcessHelper.RunTortoiseGitFileCommand(Package, "repobrowser");
await ProcessHelper.RunTortoiseGitFileCommand("repobrowser");
}
}
}
2 changes: 1 addition & 1 deletion TGit/Commands/Context/RevGraphFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal sealed class RevGraphFileCommand : BaseCommand<RevGraphFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await ProcessHelper.RunTortoiseGitFileCommand(Package, "revisiongraph");
await ProcessHelper.RunTortoiseGitFileCommand("revisiongraph");
}
}
}
4 changes: 2 additions & 2 deletions TGit/Commands/Context/RevertFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ internal sealed class RevertFileCommand : BaseCommand<RevertFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await KnownCommands.File_SaveSelectedItems.ExecuteAsync();
await KnownCommands.File_SaveAll.ExecuteAsync();

await ProcessHelper.RunTortoiseGitFileCommand(Package, "revert");
await ProcessHelper.RunTortoiseGitFileCommand("revert");
}
}
}
2 changes: 1 addition & 1 deletion TGit/Commands/Context/ShowLogFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal sealed class ShowLogFileCommand : BaseCommand<ShowLogFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await ProcessHelper.RunTortoiseGitFileCommand(Package, "log");
await ProcessHelper.RunTortoiseGitFileCommand("log");
}
}
}
4 changes: 2 additions & 2 deletions TGit/Commands/GitFlow/GitFlowFinishFeatureCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
var featureBranch = await GitHelper.GetCurrentBranchName(false);
var featureName = await GitHelper.GetCurrentBranchName(true);
var gitConfig = await GitHelper.GetGitConfig();
var options = ProcessHelper.GetOptions(Package);
var options = await General.GetLiveInstanceAsync();

/* 1. Switch to the develop branch
* 2. Pull latest changes on develop
Expand All @@ -30,7 +30,7 @@ await GitHelper.GetSshSetup() +
(options.PullChanges ? GitHelper.FormatCliCommand("pull") : string.Empty) +
GitHelper.FormatCliCommand($"merge --no-ff {featureBranch}", false),
$"Finishing feature {featureName}",
featureBranch, null, options, GitHelper.FormatCliCommand($"push origin {gitConfig.DevelopBranch}")
featureBranch, null, GitHelper.FormatCliCommand($"push origin {gitConfig.DevelopBranch}")
);
}

Expand Down
4 changes: 2 additions & 2 deletions TGit/Commands/GitFlow/GitFlowFinishFeatureGitHubCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
var featureBranch = await GitHelper.GetCurrentBranchName(false);
var featureName = await GitHelper.GetCurrentBranchName(true);
var options = ProcessHelper.GetOptions(Package);
var options = await General.GetLiveInstanceAsync();

/* 1. Switch to the master branch
* 2. Pull latest changes on master
Expand All @@ -29,7 +29,7 @@ await GitHelper.GetSshSetup() +
(options.PullChanges ? GitHelper.FormatCliCommand("pull") : string.Empty) +
GitHelper.FormatCliCommand($"merge --no-ff {featureBranch}", false),
$"Finishing feature {featureName}",
featureBranch, null, options, GitHelper.FormatCliCommand("push origin master"));
featureBranch, null, GitHelper.FormatCliCommand("push origin master"));
}

protected override async void BeforeQueryStatus(System.EventArgs e)
Expand Down
7 changes: 3 additions & 4 deletions TGit/Commands/GitFlow/GitFlowFinishHotfixCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
var hotfixBranch = await GitHelper.GetCurrentBranchName(false);
var hotfixName = await GitHelper.GetCurrentBranchName(true);
var gitConfig = await GitHelper.GetGitConfig();
var options = ProcessHelper.GetOptions(Package);
var options = await General.GetLiveInstanceAsync();

var tagMessage = string.Empty;

Expand Down Expand Up @@ -48,11 +48,10 @@ await GitHelper.GetSshSetup() +
(options.PullChanges ? GitHelper.FormatCliCommand("pull") : string.Empty) +
GitHelper.FormatCliCommand($"merge --no-ff {hotfixBranch}", false),
$"Finishing hotfix {hotfixName}",
hotfixBranch, null, options,
hotfixBranch, null,
GitHelper.FormatCliCommand($"push origin {gitConfig.DevelopBranch}") +
GitHelper.FormatCliCommand($"push origin {gitConfig.MasterBranch}") +
GitHelper.FormatCliCommand($"push origin {gitConfig.TagPrefix}{hotfixName}"),
Package
GitHelper.FormatCliCommand($"push origin {gitConfig.TagPrefix}{hotfixName}")
);
}

Expand Down
7 changes: 3 additions & 4 deletions TGit/Commands/GitFlow/GitFlowFinishReleaseCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
var releaseBranch = await GitHelper.GetCurrentBranchName(false);
var releaseName = await GitHelper.GetCurrentBranchName(true);
var gitConfig = await GitHelper.GetGitConfig();
var options = ProcessHelper.GetOptions(Package);
var options = await General.GetLiveInstanceAsync();

var tagMessage = string.Empty;

Expand Down Expand Up @@ -48,11 +48,10 @@ await GitHelper.GetSshSetup() +
(options.PullChanges ? GitHelper.FormatCliCommand("pull") : string.Empty) +
GitHelper.FormatCliCommand($"merge --no-ff {releaseBranch}", false),
$"Finishing release {releaseName}",
releaseBranch, null, options,
releaseBranch, null,
GitHelper.FormatCliCommand($"push origin {gitConfig.DevelopBranch}") +
GitHelper.FormatCliCommand($"push origin {gitConfig.MasterBranch}") +
GitHelper.FormatCliCommand($"push origin {gitConfig.TagPrefix}{releaseName}"),
Package
GitHelper.FormatCliCommand($"push origin {gitConfig.TagPrefix}{releaseName}")
);
}

Expand Down
2 changes: 1 addition & 1 deletion TGit/Commands/GitFlow/GitFlowStartFeatureCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
}

var flowOptions = await GitHelper.GetGitConfig();
var options = ProcessHelper.GetOptions(Package);
var options = await General.GetLiveInstanceAsync();

/* 1. Switch to the develop branch
* 2. Pull latest changes on develop
Expand Down
2 changes: 1 addition & 1 deletion TGit/Commands/GitFlow/GitFlowStartFeatureGitHubCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
return;
}

var options = ProcessHelper.GetOptions(Package);
var options = await General.GetLiveInstanceAsync();

/* 1. Switch to the master branch
* 2. Pull latest changes on master
Expand Down
2 changes: 1 addition & 1 deletion TGit/Commands/GitFlow/GitFlowStartHotfixCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
}

var flowOptions = await GitHelper.GetGitConfig();
var options = ProcessHelper.GetOptions(Package);
var options = await General.GetLiveInstanceAsync();

/* 1. Switch to the master branch
* 2. Pull latest changes on master
Expand Down
2 changes: 1 addition & 1 deletion TGit/Commands/GitFlow/GitFlowStartReleaseCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
}

var flowOptions = await GitHelper.GetGitConfig();
var options = ProcessHelper.GetOptions(Package);
var options = await General.GetLiveInstanceAsync();

/* 1. Switch to the develop branch
* 2. Pull latest changes on develop
Expand Down
4 changes: 2 additions & 2 deletions TGit/Commands/MainMenu/AbortMergeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ internal sealed class AbortMergeCommand : BaseCommand<AbortMergeCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await KnownCommands.File_SaveSelectedItems.ExecuteAsync();
await KnownCommands.File_SaveAll.ExecuteAsync();

await ProcessHelper.RunTortoiseGitCommand(Package, "merge", "/abort");
await ProcessHelper.RunTortoiseGitCommand("merge", "/abort");
}
}
}
4 changes: 2 additions & 2 deletions TGit/Commands/MainMenu/ApplyStashCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ internal sealed class ApplyStashCommand : BaseCommand<ApplyStashCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await KnownCommands.File_SaveSelectedItems.ExecuteAsync();
await KnownCommands.File_SaveAll.ExecuteAsync();

await ProcessHelper.RunTortoiseGitCommand(Package, "reflog", "/ref:refs/stash");
await ProcessHelper.RunTortoiseGitCommand("reflog", "/ref:refs/stash");
}

protected override async void BeforeQueryStatus(EventArgs e)
Expand Down
4 changes: 2 additions & 2 deletions TGit/Commands/MainMenu/BranchCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ internal sealed class BranchCommand : BaseCommand<BranchCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await KnownCommands.File_SaveSelectedItems.ExecuteAsync();
await KnownCommands.File_SaveAll.ExecuteAsync();

await ProcessHelper.RunTortoiseGitCommand(Package, "branch");
await ProcessHelper.RunTortoiseGitCommand("branch");
}
}
}
4 changes: 2 additions & 2 deletions TGit/Commands/MainMenu/BrowseRefCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ internal sealed class BrowseRefCommand : BaseCommand<BrowseRefCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await KnownCommands.File_SaveSelectedItems.ExecuteAsync();
await KnownCommands.File_SaveAll.ExecuteAsync();

await ProcessHelper.RunTortoiseGitCommand(Package, "refbrowse");
await ProcessHelper.RunTortoiseGitCommand("refbrowse");
}
}
}
4 changes: 2 additions & 2 deletions TGit/Commands/MainMenu/CleanupCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ internal sealed class CleanupCommand : BaseCommand<CleanupCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await KnownCommands.File_SaveSelectedItems.ExecuteAsync();
await KnownCommands.File_SaveAll.ExecuteAsync();

await ProcessHelper.RunTortoiseGitCommand(Package, "cleanup");
await ProcessHelper.RunTortoiseGitCommand("cleanup");
}
}
}
6 changes: 3 additions & 3 deletions TGit/Commands/MainMenu/CommitCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ internal sealed class CommitCommand : BaseCommand<CommitCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await KnownCommands.File_SaveSelectedItems.ExecuteAsync();
await KnownCommands.File_SaveAll.ExecuteAsync();

var options = (OptionPageGrid)Package.GetDialogPage(typeof(OptionPageGrid));
var options = await General.GetLiveInstanceAsync();
var commitMessage = await GitHelper.GetCommitMessage(options.CommitMessage);
var bugId = await GitHelper.GetCommitMessage(options.BugId);
var gitConfig = await GitHelper.GetGitConfig();

var args = $"{(string.IsNullOrEmpty(commitMessage) ? string.Empty : $"/logmsg:\"{commitMessage}\"")} " +
$"{(!string.IsNullOrEmpty(bugId) && !string.IsNullOrEmpty(gitConfig.BugTraqMessage) ? $"/bugid:\"{bugId}\"" : string.Empty)}";

await ProcessHelper.RunTortoiseGitCommand(Package, "commit", args);
await ProcessHelper.RunTortoiseGitCommand("commit", args);
}
}
}
4 changes: 2 additions & 2 deletions TGit/Commands/MainMenu/CreateStashCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ internal sealed class CreateStashCommand : BaseCommand<CreateStashCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await KnownCommands.File_SaveSelectedItems.ExecuteAsync();
await KnownCommands.File_SaveAll.ExecuteAsync();

await ProcessHelper.RunTortoiseGitCommand(Package, "stashsave");
await ProcessHelper.RunTortoiseGitCommand("stashsave");
}
}
}
2 changes: 1 addition & 1 deletion TGit/Commands/MainMenu/DiskBrowserCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal sealed class DiskBrowserCommand : BaseCommand<DiskBrowserCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await KnownCommands.File_SaveSelectedItems.ExecuteAsync();
await KnownCommands.File_SaveAll.ExecuteAsync();

ProcessHelper.Start(await FileHelper.GetSolutionDir());
}
Expand Down
4 changes: 2 additions & 2 deletions TGit/Commands/MainMenu/FetchCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ internal sealed class FetchCommand : BaseCommand<FetchCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await KnownCommands.File_SaveSelectedItems.ExecuteAsync();
await KnownCommands.File_SaveAll.ExecuteAsync();

await ProcessHelper.RunTortoiseGitCommand(Package, "fetch");
await ProcessHelper.RunTortoiseGitCommand("fetch");
}
}
}
Loading

0 comments on commit ce74efb

Please sign in to comment.