Skip to content

Commit

Permalink
fix: Save before executing git command doesn't work anymore in VS2022 #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Samir Boulema committed Jun 1, 2022
1 parent 2d97bfb commit d3bcbec
Show file tree
Hide file tree
Showing 40 changed files with 96 additions and 3 deletions.
2 changes: 2 additions & 0 deletions TGit/Commands/Context/AddFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class AddFileCommand : BaseCommand<AddFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitFileCommand("add");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/Context/BlameFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class BlameFileCommand : BaseCommand<BlameFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitFileCommand("blame", $"/line:{await FileHelper.GetActiveDocumentCurrentLine()}");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/Context/CommitFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class CommitFileCommand : BaseCommand<CommitFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

var options = await General.GetLiveInstanceAsync();
var commitMessage = await GitHelper.GetCommitMessage(options.CommitMessage);
var bugId = await GitHelper.GetCommitMessage(options.BugId);
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/Context/DiffFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class DiffFileCommand : BaseCommand<DiffFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitFileCommand("diff");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/Context/FetchFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class FetchFileCommand : BaseCommand<FetchFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitFileCommand("fetch");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/Context/MergeFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class MergeFileCommand : BaseCommand<MergeFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitFileCommand("merge");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/Context/PrefDiffFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ internal sealed class PrefDiffFileCommand : BaseCommand<PrefDiffFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

var filePath = await FileHelper.GetActiveDocumentFilePath();
var exactFilePath = FileHelper.GetExactFileName(filePath);

Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/Context/PullFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class PullFileCommand : BaseCommand<PullFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitFileCommand("pull");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/Context/RevGraphFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class RevGraphFileCommand : BaseCommand<RevGraphFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitFileCommand("revisiongraph");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/Context/RevertFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class RevertFileCommand : BaseCommand<RevertFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitFileCommand("revert");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/Context/ShowLogFileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class ShowLogFileCommand : BaseCommand<ShowLogFileCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitFileCommand("log");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/AbortMergeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class AbortMergeCommand : BaseCommand<AbortMergeCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("merge", "/abort");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/ApplyStashCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ internal sealed class ApplyStashCommand : BaseCommand<ApplyStashCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

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

Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/BranchCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class BranchCommand : BaseCommand<BranchCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("branch");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/BrowseRefCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class BrowseRefCommand : BaseCommand<BrowseRefCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("refbrowse");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/CleanupCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class CleanupCommand : BaseCommand<CleanupCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("cleanup");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/CommitCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class CommitCommand : BaseCommand<CommitCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

var options = await General.GetLiveInstanceAsync();
var commitMessage = await GitHelper.GetCommitMessage(options.CommitMessage);
var bugId = await GitHelper.GetCommitMessage(options.BugId);
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/CreateStashCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class CreateStashCommand : BaseCommand<CreateStashCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("stashsave");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/DiskBrowserCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class DiskBrowserCommand : BaseCommand<DiskBrowserCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

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

await ProcessHelper.RunTortoiseGitCommand("fetch");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/MergeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class MergeCommand : BaseCommand<MergeCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("merge");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/PullCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class PullCommand : BaseCommand<PullCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("pull");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/PushCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class PushCommand : BaseCommand<PushCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("push");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/RebaseCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class RebaseCommand : BaseCommand<RebaseCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("rebase");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/RepoBrowserCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class RepoBrowserCommand : BaseCommand<RepoBrowserCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("repobrowser");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/ResolveCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class ResolveCommand : BaseCommand<ResolveCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("resolve");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/RevGraphCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class RevGraphCommand : BaseCommand<RevGraphCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("revisiongraph");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/RevertCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class RevertCommand : BaseCommand<RevertCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("revert");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/ShowChangesCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class ShowChangesCommand : BaseCommand<ShowChangesCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("repostatus");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/ShowLogCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class ShowLogCommand : BaseCommand<ShowLogCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("log");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/StashPopCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ internal sealed class StashPopCommand : BaseCommand<StashPopCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("stashpop");
}

Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/SwitchCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class SwitchCommand : BaseCommand<SwitchCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("switch");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/SyncCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class SyncCommand : BaseCommand<SyncCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("sync");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/MainMenu/TagCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class TagCommand : BaseCommand<TagCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("tag");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/SVN/SVNDCommitCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class SVNDCommitCommand : BaseCommand<SVNDCommitCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("svndcommit");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/SVN/SVNFetchCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class SVNFetchCommand : BaseCommand<SVNFetchCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("svnfetch");
}
}
Expand Down
2 changes: 2 additions & 0 deletions TGit/Commands/SVN/SVNRebaseCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ internal sealed class SVNRebaseCommand : BaseCommand<SVNRebaseCommand>
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e)
{
await CommandHelper.SaveFiles();

await ProcessHelper.RunTortoiseGitCommand("svnrebase");
}
}
Expand Down
16 changes: 15 additions & 1 deletion TGit/Helpers/CommandHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Microsoft.VisualStudio.Shell;
using Community.VisualStudio.Toolkit;
using Microsoft.VisualStudio.Shell;
using System;
using System.ComponentModel.Design;
using System.Threading.Tasks;

namespace SamirBoulema.TGit.Helpers
{
Expand All @@ -25,5 +27,17 @@ public static async void GitHubFlow_BeforeQueryStatus(object sender, EventArgs e

public static async void GitSvn_BeforeQueryStatus(object sender, EventArgs e)
=> ((OleMenuCommand)sender).Visible = await FileHelper.HasSolutionDir() && await GitHelper.IsGitSvn();

public static async Task<bool> SaveFiles()
{
var options = await General.GetLiveInstanceAsync();

if (!options.SaveFiles)
{
return false;
}

return await KnownCommands.File_SaveAll.ExecuteAsync();
}
}
}
5 changes: 5 additions & 0 deletions TGit/Options/General.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,10 @@ public class General : BaseOptionModel<General>
[DisplayName("Default bug id")]
[Description("$(BranchName), $(FeatureName), https://msdn.microsoft.com/en-us/library/c02as0cs.aspx")]
public string BugId { get; set; }

[Category("TGit")]
[DisplayName("Save files before operations")]
[Description("Save files before doing any Git operation")]
public bool SaveFiles { get; set; }
}
}
4 changes: 2 additions & 2 deletions TGit/TGit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -351,15 +351,15 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Community.VisualStudio.Toolkit.15">
<Version>15.0.445</Version>
<Version>15.0.455</Version>
</PackageReference>
<PackageReference Include="Community.VisualStudio.VSCT">
<Version>16.0.29.6</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.VSSDK.BuildTools">
<Version>17.1.4057</Version>
<Version>17.2.2186</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down

0 comments on commit d3bcbec

Please sign in to comment.