Skip to content

Commit d458b99

Browse files
committed
Merge pull request #17 from pmiossec/fix_plugin
Fix plugin to work with new version of GitExtensions (2.48.03)
2 parents 13e0a9b + d077f81 commit d458b99

File tree

10 files changed

+178
-43
lines changed

10 files changed

+178
-43
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ _ReSharper.GitTfs.GitExtensions.Plugin
33
*.user
44
*.suo
55
[Oo]bj
6+
/packages

.nuget/NuGet.Config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<solution>
4+
<add key="disableSourceControlIntegration" value="true" />
5+
</solution>
6+
</configuration>

.nuget/NuGet.exe

636 KB
Binary file not shown.

.nuget/NuGet.targets

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
5+
6+
<!-- Enable the restore command to run before builds -->
7+
<RestorePackages Condition=" '$(RestorePackages)' == '' Or '$(OS)' != 'Windows_NT' ">false</RestorePackages>
8+
9+
<!-- Property that enables building a package from a project -->
10+
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
11+
12+
<!-- Determines if package restore consent is required to restore packages -->
13+
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>
14+
15+
<!-- Download NuGet.exe if it does not already exist -->
16+
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
17+
</PropertyGroup>
18+
19+
<ItemGroup Condition=" '$(PackageSources)' == '' ">
20+
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
21+
<!-- The official NuGet package source (https://nuget.org/api/v2/) will be excluded if package sources are specified and it does not appear in the list -->
22+
<!--
23+
<PackageSource Include="https://nuget.org/api/v2/" />
24+
<PackageSource Include="https://my-nuget-source/nuget/" />
25+
-->
26+
</ItemGroup>
27+
28+
<PropertyGroup>
29+
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
30+
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
31+
<PackagesConfig>packages.config</PackagesConfig>
32+
</PropertyGroup>
33+
34+
<PropertyGroup>
35+
<!-- NuGet command -->
36+
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
37+
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
38+
39+
<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
40+
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>
41+
42+
<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
43+
44+
<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
45+
<!-- Commands -->
46+
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(RequireConsentSwitch) -solutionDir "$(SolutionDir) "</RestoreCommand>
47+
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand>
48+
49+
<!-- We need to ensure packages are restored prior to assembly resolve -->
50+
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
51+
RestorePackages;
52+
$(BuildDependsOn);
53+
</BuildDependsOn>
54+
55+
<!-- Make the build depend on restore packages -->
56+
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
57+
$(BuildDependsOn);
58+
BuildPackage;
59+
</BuildDependsOn>
60+
</PropertyGroup>
61+
62+
<Target Name="CheckPrerequisites">
63+
<!-- Raise an error if we're unable to locate nuget.exe -->
64+
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
65+
<SetEnvironmentVariable EnvKey="VisualStudioVersion" EnvValue="$(VisualStudioVersion)" Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' " />
66+
<!--
67+
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
68+
This effectively acts as a lock that makes sure that the download operation will only happen once and all
69+
parallel builds will have to wait for it to complete.
70+
-->
71+
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT" />
72+
</Target>
73+
74+
<Target Name="_DownloadNuGet">
75+
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
76+
</Target>
77+
78+
<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
79+
<Exec Command="$(RestoreCommand)" Condition="Exists('$(PackagesConfig)')" />
80+
</Target>
81+
82+
<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
83+
<Exec Command="$(BuildCommand)" />
84+
</Target>
85+
86+
<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
87+
<ParameterGroup>
88+
<OutputFilename ParameterType="System.String" Required="true" />
89+
</ParameterGroup>
90+
<Task>
91+
<Reference Include="System.Core" />
92+
<Using Namespace="System" />
93+
<Using Namespace="System.IO" />
94+
<Using Namespace="System.Net" />
95+
<Using Namespace="Microsoft.Build.Framework" />
96+
<Using Namespace="Microsoft.Build.Utilities" />
97+
<Code Type="Fragment" Language="cs">
98+
<![CDATA[
99+
try {
100+
OutputFilename = Path.GetFullPath(OutputFilename);
101+
102+
Log.LogMessage("Downloading latest version of NuGet.exe...");
103+
WebClient webClient = new WebClient();
104+
webClient.DownloadFile("https://nuget.org/nuget.exe", OutputFilename);
105+
106+
return true;
107+
}
108+
catch (Exception ex) {
109+
Log.LogErrorFromException(ex);
110+
return false;
111+
}
112+
]]>
113+
</Code>
114+
</Task>
115+
</UsingTask>
116+
117+
<UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
118+
<ParameterGroup>
119+
<EnvKey ParameterType="System.String" Required="true" />
120+
<EnvValue ParameterType="System.String" Required="true" />
121+
</ParameterGroup>
122+
<Task>
123+
<Using Namespace="System" />
124+
<Code Type="Fragment" Language="cs">
125+
<![CDATA[
126+
try {
127+
Environment.SetEnvironmentVariable(EnvKey, EnvValue, System.EnvironmentVariableTarget.Process);
128+
}
129+
catch {
130+
}
131+
]]>
132+
</Code>
133+
</Task>
134+
</UsingTask>
135+
</Project>

.nuget/Nuget.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
if [ ! -d 'packages' ]; then
4+
mkdir packages
5+
fi
6+
if [ "$1" = "NoMono" ] ; then
7+
8+
find ./ -name packages.config -exec .nuget/NuGet.exe install {} -o packages \;
9+
10+
else
11+
find ./ -name packages.config -exec mono --runtime=v4.0.30319 .nuget/NuGet.exe install {} -o packages \;
12+
fi
13+

GitTfsPlugin.cs

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,11 @@
77

88
namespace GitTfs.GitExtensions.Plugin
99
{
10-
public class GitTfsPlugin : IGitPlugin
10+
public class GitTfsPlugin : GitPluginBase
1111
{
12-
public void Register(IGitUICommands gitUiCommands)
12+
public override bool Execute(GitUIBaseEventArgs gitUiCommands)
1313
{
14-
var existingKeys = Settings.GetAvailableSettings();
15-
16-
var settingsToAdd = from field in typeof(SettingKeys).GetFields(BindingFlags.Public | BindingFlags.Static)
17-
let key = (string)field.GetValue(null)
18-
where !existingKeys.Contains(key)
19-
select key;
20-
21-
foreach (var settingToAdd in settingsToAdd)
22-
{
23-
Settings.AddSetting(settingToAdd, string.Empty);
24-
}
25-
26-
}
27-
28-
public void Unregister(IGitUICommands gitUiCommands)
29-
{
30-
}
31-
32-
public bool Execute(GitUIBaseEventArgs gitUiCommands)
33-
{
34-
if (string.IsNullOrEmpty(gitUiCommands.GitModule.GitWorkingDir))
14+
if (string.IsNullOrEmpty(gitUiCommands.GitModule.WorkingDir))
3515
{
3616
return true;
3717
}
@@ -58,13 +38,11 @@ private static IEnumerable<string> GetTfsRemotes(IGitUICommands commands)
5838
: Enumerable.Empty<string>();
5939
}
6040

61-
public string Description
41+
public override string Description
6242
{
63-
get { return "git-tfs"; }
43+
get { return "Git-Tfs"; }
6444
}
6545

66-
public IGitPluginSettingsContainer Settings { get; set; }
67-
6846
public SettingsContainer PluginSettings
6947
{
7048
get { return new SettingsContainer(Settings); }

SettingsContainer.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ namespace GitTfs.GitExtensions.Plugin
66
{
77
public class SettingsContainer
88
{
9-
private readonly IGitPluginSettingsContainer _container;
9+
private readonly ISettingsSource _container;
1010

11-
public SettingsContainer(IGitPluginSettingsContainer container)
11+
public SettingsContainer(ISettingsSource container)
1212
{
1313
_container = container;
1414
}
1515

1616
public string TfsRemote
1717
{
18-
get { return _container.GetSetting(SettingKeys.TfsRemote); }
19-
set { _container.SetSetting(SettingKeys.TfsRemote, value); }
18+
get { return _container.GetValue(SettingKeys.TfsRemote, null , x => x); }
19+
set { _container.SetValue(SettingKeys.TfsRemote, value, x => x); }
2020
}
2121

2222
public PullSetting? PullSetting
@@ -40,17 +40,15 @@ public ShelveSettingsContainer ShelveSettings
4040
where T : struct
4141
{
4242
var type = typeof (T);
43-
var value = _container.GetSetting(key);
44-
45-
return (from name in Enum.GetNames(type)
46-
where name == value
47-
select (T?) Enum.Parse(type, name)).FirstOrDefault();
43+
return _container.GetValue(key, default(T), x => (from name in Enum.GetNames(type)
44+
where name == x
45+
select (T?) Enum.Parse(type, name)).FirstOrDefault());
4846
}
4947

5048
private void SetEnumSettingValue<T>(string key, T? value)
5149
where T : struct
5250
{
53-
_container.SetSetting(key, value.HasValue ? value.ToString() : string.Empty);
51+
_container.SetValue(key, value, x => x.HasValue ? x.ToString() : string.Empty);
5452
}
5553
}
5654
}

ShelveSettingsContainer.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ namespace GitTfs.GitExtensions.Plugin
44
{
55
public class ShelveSettingsContainer
66
{
7-
private readonly IGitPluginSettingsContainer _container;
7+
private readonly ISettingsSource _container;
88

9-
public ShelveSettingsContainer(IGitPluginSettingsContainer container)
9+
public ShelveSettingsContainer(ISettingsSource container)
1010
{
1111
_container = container;
1212
}
1313

1414
public string Name
1515
{
16-
get { return _container.GetSetting(SettingKeys.ShelvesetName); }
17-
set { _container.SetSetting(SettingKeys.ShelvesetName, value); }
16+
get { return _container.GetValue(SettingKeys.ShelvesetName, string.Empty, x => x); }
17+
set { _container.SetValue(SettingKeys.ShelvesetName, value, x => x); }
1818
}
1919

2020
public bool Overwrite
@@ -26,7 +26,7 @@ public bool Overwrite
2626
}
2727
set
2828
{
29-
_container.SetSetting(SettingKeys.OverwriteShelveset, value.ToString());
29+
_container.SetValue(SettingKeys.OverwriteShelveset, value, x => x.ToString());
3030
}
3131
}
3232
}

gitextensions

Submodule gitextensions updated 1389 files

packages/repositories.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<repositories>
3+
<repository path="..\gitextensions\Plugins\GitUIPluginInterfaces\packages.config" />
4+
</repositories>

0 commit comments

Comments
 (0)