Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ _ReSharper.GitTfs.GitExtensions.Plugin
*.user
*.suo
[Oo]bj
/packages
6 changes: 6 additions & 0 deletions .nuget/NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
</configuration>
Binary file added .nuget/NuGet.exe
Binary file not shown.
135 changes: 135 additions & 0 deletions .nuget/NuGet.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>

<!-- Enable the restore command to run before builds -->
<RestorePackages Condition=" '$(RestorePackages)' == '' Or '$(OS)' != 'Windows_NT' ">false</RestorePackages>

<!-- Property that enables building a package from a project -->
<BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>

<!-- Determines if package restore consent is required to restore packages -->
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">true</RequireRestoreConsent>

<!-- Download NuGet.exe if it does not already exist -->
<DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">false</DownloadNuGetExe>
</PropertyGroup>

<ItemGroup Condition=" '$(PackageSources)' == '' ">
<!-- Package sources used to restore packages. By default, registered sources under %APPDATA%\NuGet\NuGet.Config will be used -->
<!-- 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 -->
<!--
<PackageSource Include="https://nuget.org/api/v2/" />
<PackageSource Include="https://my-nuget-source/nuget/" />
-->
</ItemGroup>

<PropertyGroup>
<!-- We need to launch nuget.exe with the mono command if we're not on windows -->
<NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
<PackagesConfig>packages.config</PackagesConfig>
</PropertyGroup>

<PropertyGroup>
<!-- NuGet command -->
<NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\NuGet.exe</NuGetExePath>
<PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>

<NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
<NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>

<PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>

<RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
<!-- Commands -->
<RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(RequireConsentSwitch) -solutionDir "$(SolutionDir) "</RestoreCommand>
<BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand>

<!-- We need to ensure packages are restored prior to assembly resolve -->
<BuildDependsOn Condition="$(RestorePackages) == 'true'">
RestorePackages;
$(BuildDependsOn);
</BuildDependsOn>

<!-- Make the build depend on restore packages -->
<BuildDependsOn Condition="$(BuildPackage) == 'true'">
$(BuildDependsOn);
BuildPackage;
</BuildDependsOn>
</PropertyGroup>

<Target Name="CheckPrerequisites">
<!-- Raise an error if we're unable to locate nuget.exe -->
<Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
<SetEnvironmentVariable EnvKey="VisualStudioVersion" EnvValue="$(VisualStudioVersion)" Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' " />
<!--
Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
This effectively acts as a lock that makes sure that the download operation will only happen once and all
parallel builds will have to wait for it to complete.
-->
<MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT" />
</Target>

<Target Name="_DownloadNuGet">
<DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
</Target>

<Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(RestoreCommand)" Condition="Exists('$(PackagesConfig)')" />
</Target>

<Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
<Exec Command="$(BuildCommand)" />
</Target>

<UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<OutputFilename ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Net" />
<Using Namespace="Microsoft.Build.Framework" />
<Using Namespace="Microsoft.Build.Utilities" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
OutputFilename = Path.GetFullPath(OutputFilename);

Log.LogMessage("Downloading latest version of NuGet.exe...");
WebClient webClient = new WebClient();
webClient.DownloadFile("https://nuget.org/nuget.exe", OutputFilename);

return true;
}
catch (Exception ex) {
Log.LogErrorFromException(ex);
return false;
}
]]>
</Code>
</Task>
</UsingTask>

<UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<EnvKey ParameterType="System.String" Required="true" />
<EnvValue ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Code Type="Fragment" Language="cs">
<![CDATA[
try {
Environment.SetEnvironmentVariable(EnvKey, EnvValue, System.EnvironmentVariableTarget.Process);
}
catch {
}
]]>
</Code>
</Task>
</UsingTask>
</Project>
13 changes: 13 additions & 0 deletions .nuget/Nuget.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

if [ ! -d 'packages' ]; then
mkdir packages
fi
if [ "$1" = "NoMono" ] ; then

find ./ -name packages.config -exec .nuget/NuGet.exe install {} -o packages \;

else
find ./ -name packages.config -exec mono --runtime=v4.0.30319 .nuget/NuGet.exe install {} -o packages \;
fi

32 changes: 5 additions & 27 deletions GitTfsPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,11 @@

namespace GitTfs.GitExtensions.Plugin
{
public class GitTfsPlugin : IGitPlugin
public class GitTfsPlugin : GitPluginBase
{
public void Register(IGitUICommands gitUiCommands)
public override bool Execute(GitUIBaseEventArgs gitUiCommands)
{
var existingKeys = Settings.GetAvailableSettings();

var settingsToAdd = from field in typeof(SettingKeys).GetFields(BindingFlags.Public | BindingFlags.Static)
let key = (string)field.GetValue(null)
where !existingKeys.Contains(key)
select key;

foreach (var settingToAdd in settingsToAdd)
{
Settings.AddSetting(settingToAdd, string.Empty);
}

}

public void Unregister(IGitUICommands gitUiCommands)
{
}

public bool Execute(GitUIBaseEventArgs gitUiCommands)
{
if (string.IsNullOrEmpty(gitUiCommands.GitModule.GitWorkingDir))
if (string.IsNullOrEmpty(gitUiCommands.GitModule.WorkingDir))
{
return true;
}
Expand All @@ -58,13 +38,11 @@ private static IEnumerable<string> GetTfsRemotes(IGitUICommands commands)
: Enumerable.Empty<string>();
}

public string Description
public override string Description
{
get { return "git-tfs"; }
get { return "Git-Tfs"; }
}

public IGitPluginSettingsContainer Settings { get; set; }

public SettingsContainer PluginSettings
{
get { return new SettingsContainer(Settings); }
Expand Down
18 changes: 8 additions & 10 deletions SettingsContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ namespace GitTfs.GitExtensions.Plugin
{
public class SettingsContainer
{
private readonly IGitPluginSettingsContainer _container;
private readonly ISettingsSource _container;

public SettingsContainer(IGitPluginSettingsContainer container)
public SettingsContainer(ISettingsSource container)
{
_container = container;
}

public string TfsRemote
{
get { return _container.GetSetting(SettingKeys.TfsRemote); }
set { _container.SetSetting(SettingKeys.TfsRemote, value); }
get { return _container.GetValue(SettingKeys.TfsRemote, null , x => x); }
set { _container.SetValue(SettingKeys.TfsRemote, value, x => x); }
}

public PullSetting? PullSetting
Expand All @@ -40,17 +40,15 @@ public ShelveSettingsContainer ShelveSettings
where T : struct
{
var type = typeof (T);
var value = _container.GetSetting(key);

return (from name in Enum.GetNames(type)
where name == value
select (T?) Enum.Parse(type, name)).FirstOrDefault();
return _container.GetValue(key, default(T), x => (from name in Enum.GetNames(type)
where name == x
select (T?) Enum.Parse(type, name)).FirstOrDefault());
}

private void SetEnumSettingValue<T>(string key, T? value)
where T : struct
{
_container.SetSetting(key, value.HasValue ? value.ToString() : string.Empty);
_container.SetValue(key, value, x => x.HasValue ? x.ToString() : string.Empty);
}
}
}
10 changes: 5 additions & 5 deletions ShelveSettingsContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ namespace GitTfs.GitExtensions.Plugin
{
public class ShelveSettingsContainer
{
private readonly IGitPluginSettingsContainer _container;
private readonly ISettingsSource _container;

public ShelveSettingsContainer(IGitPluginSettingsContainer container)
public ShelveSettingsContainer(ISettingsSource container)
{
_container = container;
}

public string Name
{
get { return _container.GetSetting(SettingKeys.ShelvesetName); }
set { _container.SetSetting(SettingKeys.ShelvesetName, value); }
get { return _container.GetValue(SettingKeys.ShelvesetName, string.Empty, x => x); }
set { _container.SetValue(SettingKeys.ShelvesetName, value, x => x); }
}

public bool Overwrite
Expand All @@ -26,7 +26,7 @@ public bool Overwrite
}
set
{
_container.SetSetting(SettingKeys.OverwriteShelveset, value.ToString());
_container.SetValue(SettingKeys.OverwriteShelveset, value, x => x.ToString());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gitextensions
Submodule gitextensions updated 1389 files
4 changes: 4 additions & 0 deletions packages/repositories.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<repositories>
<repository path="..\gitextensions\Plugins\GitUIPluginInterfaces\packages.config" />
</repositories>