Skip to content

Commit 00af1ef

Browse files
authored
Release v1.19.0 (#63)
2 parents 0522fd2 + 5d33c06 commit 00af1ef

File tree

6 files changed

+73
-17
lines changed

6 files changed

+73
-17
lines changed

GitTreeFilter/Commands/CommandRegistrar.cs

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ public static async Task InitializeAsync(IGitFiltersPackage package)
2222
try
2323
{
2424
await RegisterAsync(package, commandService);
25+
GitTreeFilterOutput.WriteLine($"Initialized all commands");
2526
}
2627
catch (Exception ex)
2728
{
29+
GitTreeFilterOutput.WriteLine($"Failed to register commands: {ex}");
2830
ActivityLog.LogError(nameof(CommandRegistrar), $"Failed to register commands - {ex}");
2931
throw ex;
3032
}
@@ -50,19 +52,38 @@ private static async Task RegisterAsync(IGitFiltersPackage package, IMenuCommand
5052

5153
private static void RegisterCommand(IMenuCommandService commandService, int rawCommandId, GitFiltersCommand command)
5254
{
53-
var commandId = new CommandID(GitFiltersControls.GitFiltersControlsCmdSet, rawCommandId);
54-
var menuCommand = new OleMenuCommand(command.OnExecute, commandId);
55+
GitTreeFilterOutput.WriteLine($"Registering command {command.GetType()} with id {rawCommandId}");
5556

56-
menuCommand.BeforeQueryStatus += delegate (object sender, EventArgs e)
57+
var commandId = new CommandID(GitFiltersControls.GitFiltersControlsCmdSet, rawCommandId);
58+
if (commandService.FindCommand(commandId) == null)
5759
{
58-
menuCommand.Visible = command.IsVisible;
59-
};
60+
var menuCommand = new OleMenuCommand(command.OnExecute, commandId);
6061

61-
command.VisibilityChanged += delegate
62-
{
63-
menuCommand.Visible = command.IsVisible;
64-
};
62+
menuCommand.BeforeQueryStatus += delegate (object sender, EventArgs e)
63+
{
64+
ThreadHelper.JoinableTaskFactory.Run(() =>
65+
{
66+
menuCommand.Visible = command.IsVisible;
67+
return Task.CompletedTask;
68+
});
69+
};
70+
71+
command.VisibilityChanged += delegate
72+
{
73+
ThreadHelper.JoinableTaskFactory.Run(() =>
74+
{
75+
menuCommand.Visible = command.IsVisible;
76+
return Task.CompletedTask;
77+
});
78+
};
6579

66-
commandService.AddCommand(menuCommand);
80+
commandService.AddCommand(menuCommand);
81+
82+
GitTreeFilterOutput.WriteLine($"Command {command.GetType()} with id {rawCommandId} registered");
83+
}
84+
else
85+
{
86+
GitTreeFilterOutput.WriteLine($"Command {command.GetType()} with id {rawCommandId} already registered");
87+
}
6788
}
6889
}

GitTreeFilter/GitTreeFilter.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
<Compile Include="Commands\Diffrence\OpenDiffCommandManager.cs" />
6363
<Compile Include="Commands\Diffrence\OpenPhysicalFileDiffCommand.cs" />
6464
<Compile Include="Commands\Diffrence\OpenProjectFileDiffCommand.cs" />
65+
<Compile Include="GitTreeFilterOutput.cs" />
6566
<Compile Include="GitTreeFilterProvider.GitFileFilter.cs" />
6667
<Compile Include="Models\ComparisonConfig.cs" />
6768
<Compile Include="GitTreeFilterErrorPresenter.cs" />

GitTreeFilter/GitTreeFilterOutput.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using Microsoft.VisualStudio.Shell;
2+
using Microsoft.VisualStudio.Shell.Interop;
3+
using System;
4+
5+
public static class GitTreeFilterOutput
6+
{
7+
private static IVsOutputWindowPane _outputPane;
8+
9+
public static void Initialize(IServiceProvider serviceProvider)
10+
{
11+
ThreadHelper.ThrowIfNotOnUIThread();
12+
if (_outputPane == null)
13+
{
14+
var outputWindow = serviceProvider.GetService(typeof(SVsOutputWindow)) as IVsOutputWindow;
15+
if (outputWindow != null)
16+
{
17+
Guid customPaneGuid = Guid.NewGuid();
18+
outputWindow.CreatePane(ref customPaneGuid, nameof(GitTreeFilter), 1, 1);
19+
outputWindow.GetPane(ref customPaneGuid, out _outputPane);
20+
}
21+
}
22+
}
23+
24+
public static void WriteLine(string message)
25+
{
26+
ThreadHelper.ThrowIfNotOnUIThread();
27+
28+
if (_outputPane != null)
29+
{
30+
_outputPane.OutputStringThreadSafe(message + Environment.NewLine);
31+
}
32+
}
33+
}

GitTreeFilter/GitTreeFilterService.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public ISessionSettings SessionSettings
7777

7878
public bool IsFilterApplied
7979
{
80-
get => _isFilterApplied;
80+
get => _isFilterApplied; // true
8181
set
8282
{
8383
_isFilterApplied = value;
@@ -119,6 +119,7 @@ public async Task InitializeAsync(CancellationToken cancellationToken)
119119
{
120120
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
121121

122+
GitTreeFilterOutput.Initialize(ServiceProvider.GlobalProvider);
122123
_gitExt = ServiceProvider.GlobalProvider.GetService(typeof(IGitExt)) as IGitExt;
123124
_dte = await _package.GetServiceAsync<DTE>();
124125

@@ -151,6 +152,7 @@ private async Task SetUpAsync()
151152

152153
if (!TryGetRootRepositoryPath(out string repositoryRootPath))
153154
{
155+
GitTreeFilterOutput.WriteLine("Could not identify GIT repository to use, deactivating the plugin for now");
154156
PluginState = PluginLifecycleState.INACTIVE;
155157
Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Could not identify GIT repository to use, deactivating the plugin for now"));
156158
return;
@@ -174,11 +176,10 @@ private async Task SetUpAsync()
174176
LoadSessionSettings();
175177
ItemTagManager.CreateTagTables();
176178

177-
if (PluginState == PluginLifecycleState.LOADING)
178-
{
179-
await CommandRegistrar.InitializeAsync(_package);
180-
}
179+
GitTreeFilterOutput.WriteLine($"Initializing commands");
180+
await CommandRegistrar.InitializeAsync(_package);
181181

182+
GitTreeFilterOutput.WriteLine($"Initialization done");
182183
PluginState = PluginLifecycleState.RUNNING;
183184
}
184185

GitTreeFilter/source.extension.vsixmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
33
<Metadata>
4-
<Identity Id="GitTreeFilter.eae60f56-2c84-4ba9-9cbc-d021d9c67958" Version="1.2.3.4" Language="en-US" Publisher="Grzegorz Gurgul" />
4+
<Identity Id="GitTreeFilter.eae60f56-2c84-4ba9-9cbc-d021d9c67958" Version="999.999.999" Language="en-US" Publisher="Grzegorz Gurgul" />
55
<DisplayName>GitTreeFilter</DisplayName>
66
<Description xml:space="preserve">Filter solution explorer by showing only the files that were changed in comparison to a working tree from specific branch, commit or tag.</Description>
77
<MoreInfo>https://github.com/kboom/git-tree-filter-4vs/</MoreInfo>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# GitTreeFilter for Visual Studio
22

3-
![example workflow](https://github.com/kboom/GitTreeFilter-4-VisualStudio/actions/workflows/build.yml/badge.svg)
3+
[![CI](https://github.com/kboom/GitTreeFilter-4-VisualStudio/actions/workflows/ci-nightly.yml/badge.svg)](https://github.com/kboom/GitTreeFilter-4-VisualStudio/actions/workflows/ci-nightly.yml)
44

55
This extension for Visual Studio 2022 allows you to filter solution explorer to include only the files changed when comparing to the worktree sometime in the past.
66
Navigate through all these files as usual, and compare the changes using a context menu item.

0 commit comments

Comments
 (0)