Skip to content
This repository was archived by the owner on Jan 6, 2021. It is now read-only.

Commit 32da7d6

Browse files
authored
Merge pull request #6 from conniey/netstandard
Migrates library to .NETStandard 1.3
2 parents 478e8be + d1b323b commit 32da7d6

12 files changed

+104
-219
lines changed

.travis.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
language: csharp
2+
mono: latest
3+
dotnet: 1.0.4
4+
dist: trusty
5+
26
solution: src/GitTools.Testing.sln
37
sudo: false
48
install:
5-
# - sudo nuget update -self
6-
- nuget restore src/GitTools.Testing.sln
79
- nuget install xunit.runner.console -Version 2.1.0 -OutputDirectory ./src/packages
810
script:
9-
- xbuild ./src/GitTools.Testing.sln /property:Configuration="Debug" /verbosity:detailed
10-
- mono --debug --runtime=v4.0.30319 ./src/packages/xunit.runner.console.2.1.0/tools/xunit.console.exe ./src/GitTools.Testing.Tests/bin/Debug/GitTools.Testing.Tests.dll
11+
- dotnet restore src/GitTools.Testing.sln
12+
- msbuild ./src/GitTools.Testing.sln /property:Configuration=Debug
13+
- dotnet test ./src/GitTools.Testing.Tests/GitTools.Testing.Tests.csproj --configuration Debug --no-build --framework netcoreapp1.0
14+
# Disable testing against .NET 4.5.2 through Mono because it tries to resolve
15+
# the Windows libgit binary instead of the linux one.
16+
# - mono --debug --runtime=v4.0.30319 ./src/packages/xunit.runner.console.2.1.0/tools/xunit.console.exe ./src/GitTools.Testing.Tests/bin/Debug/net452/GitTools.Testing.Tests.dll

appveyor.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
1+
image:
2+
- Visual Studio 2017
3+
14
install:
25
- choco install gitversion.portable -pre -y
36

4-
platform:
5-
- Any CPU
6-
77
configuration:
88
- Release
99

1010
assembly_info:
1111
patch: false
1212

1313
before_build:
14-
- nuget restore src\
14+
- dotnet restore src\GitTools.Testing.sln
1515
- ps: gitversion /l console /output buildserver /updateAssemblyInfo
1616

1717
build:
1818
project: src\GitTools.Testing.sln
1919

2020
after_build:
21-
- cmd: nuget pack src\GitTools.Testing.nuspec -version "%GitVersion_NuGetVersion%"
21+
- cmd: dotnet pack src\GitTools.Testing\GitTools.Testing.csproj /p:PackageVersion="%GitVersion_NuGetVersion%" /p:NoBuild=true /p:PackageOutputPath=%APPVEYOR_BUILD_FOLDER%
2222
- cmd: appveyor PushArtifact "GitTools.Testing.%GitVersion_NuGetVersion%.nupkg"
23+
24+
# Setting this off until the auto-detection for dotnet test tooling in AppVeyor
25+
# is integrated. https://github.com/appveyor/ci/issues/1404
26+
# The test_script is used as a workaround to fix this.
27+
test: off
28+
test_script:
29+
- cmd: dotnet test src\GitTools.Testing.Tests\GitTools.Testing.Tests.csproj --configuration %Configuration% --no-build
30+
2331
cache:
2432
- src\packages -> **\packages.config # preserve "packages" directory in the root of build folder but will reset it if packages.config is modified

src/GitTools.Testing.Tests/Example.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
namespace GitTools.Testing.Tests
55
{
66
using System;
7+
#if NET452
78
using System.Runtime.Remoting.Messaging;
9+
#endif
810
using JetBrains.Annotations;
911
using Logging;
1012

@@ -16,8 +18,10 @@ public class Example
1618
[Fact]
1719
public void TheReadmeSample()
1820
{
21+
#if NET452
1922
using (LogHelper.Capture(_outputHelper, LogProvider.SetCurrentLogProvider))
2023
{
24+
#endif
2125
using (var fixture = new EmptyRepositoryFixture())
2226
{
2327
fixture.MakeACommit();
@@ -28,10 +32,13 @@ public void TheReadmeSample()
2832
fixture.Checkout("master");
2933
fixture.MergeNoFF("develop");
3034
}
35+
#if NET452
3136
}
37+
#endif
3238
}
3339
}
3440

41+
#if NET452
3542
public static class LogHelper
3643
{
3744
private static readonly XUnitProvider Provider;
@@ -45,7 +52,7 @@ public static IDisposable Capture(ITestOutputHelper outputHelper, Action<ILogPro
4552
{
4653
// TODO Only do this once
4754
setProvider(Provider);
48-
55+
4956
CallContext.SetData("CurrentOutputHelper", outputHelper);
5057

5158
return new DelegateDisposable(() =>
@@ -101,4 +108,5 @@ public IDisposable OpenMappedContext(string key, string value)
101108
throw new NotImplementedException();
102109
}
103110
}
111+
#endif
104112
}
Lines changed: 37 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,49 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" />
4-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
53
<PropertyGroup>
6-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
8-
<ProjectGuid>{5CF365CF-85B2-4AA3-8A17-680EFDF617C5}</ProjectGuid>
9-
<OutputType>Library</OutputType>
10-
<AppDesignerFolder>Properties</AppDesignerFolder>
11-
<RootNamespace>GitTools.Testing.Tests</RootNamespace>
12-
<AssemblyName>GitTools.Testing.Tests</AssemblyName>
13-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
14-
<FileAlignment>512</FileAlignment>
15-
<NuGetPackageImportStamp>
16-
</NuGetPackageImportStamp>
17-
<TargetFrameworkProfile />
4+
<TargetFrameworks>net452;netcoreapp1.0</TargetFrameworks>
5+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
6+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
187
</PropertyGroup>
19-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
20-
<DebugSymbols>true</DebugSymbols>
21-
<DebugType>full</DebugType>
22-
<Optimize>false</Optimize>
23-
<OutputPath>bin\Debug\</OutputPath>
24-
<DefineConstants>DEBUG;TRACE</DefineConstants>
25-
<ErrorReport>prompt</ErrorReport>
26-
<WarningLevel>4</WarningLevel>
27-
<Prefer32Bit>false</Prefer32Bit>
28-
</PropertyGroup>
29-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
30-
<DebugType>pdbonly</DebugType>
31-
<Optimize>true</Optimize>
32-
<OutputPath>bin\Release\</OutputPath>
33-
<DefineConstants>TRACE</DefineConstants>
34-
<ErrorReport>prompt</ErrorReport>
35-
<WarningLevel>4</WarningLevel>
36-
<Prefer32Bit>false</Prefer32Bit>
8+
9+
<!-- NuGet properties for creating a NuGet package.
10+
More information: https://docs.microsoft.com/en-us/nuget/schema/msbuild-targets -->
11+
<PropertyGroup>
12+
<Title>GitTools.Testing</Title>
13+
<Authors>GitTools Contributors</Authors>
14+
<Description>Makes it easy to automate git for testing libraries which interact with git</Description>
15+
<PackageTags>git tools testing</PackageTags>
16+
<Copyright>Copyright GitTools 2015</Copyright>
17+
<PackageProjectUrl>https://github.com/GitTools/GitTools.Core</PackageProjectUrl>
18+
<PackageLicenseUrl>https://github.com/GitTools/GitTools.Core/blob/master/LICENSE</PackageLicenseUrl>
19+
<PackageIconUrl>https://raw.github.com/GitTools/GitTools.Core/master/GitTools_logo.png</PackageIconUrl>
3720
</PropertyGroup>
21+
3822
<ItemGroup>
39-
<Reference Include="System" />
40-
<Reference Include="System.Core" />
41-
<Reference Include="System.Xml.Linq" />
42-
<Reference Include="System.Data.DataSetExtensions" />
43-
<Reference Include="Microsoft.CSharp" />
44-
<Reference Include="System.Data" />
45-
<Reference Include="System.Xml" />
46-
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
47-
<HintPath>..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
48-
<Private>True</Private>
49-
</Reference>
50-
<Reference Include="xunit.core, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
51-
<HintPath>..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll</HintPath>
52-
<Private>True</Private>
53-
</Reference>
54-
<Reference Include="xunit.execution.desktop, Version=2.1.0.3179, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
55-
<HintPath>..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll</HintPath>
56-
<Private>True</Private>
57-
</Reference>
23+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
24+
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="15.0.0" />
25+
<PackageReference Include="xunit.abstractions" Version="2.0.1" />
26+
<PackageReference Include="xunit.core" Version="2.3.0-beta3-build3705" />
27+
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0-beta3-build3705" />
28+
<PackageReference Include="xunit.runner.console" Version="2.3.0-beta3-build3705" />
29+
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta2-build3683" />
5830
</ItemGroup>
59-
<ItemGroup>
60-
<Compile Include="Example.cs" />
61-
<Compile Include="Properties\AssemblyInfo.cs" />
62-
<Compile Include="Properties\JetBrainsAnnotations.cs" />
31+
32+
<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
33+
<PackageReference Include="LibGit2Sharp" Version="0.24.0" />
6334
</ItemGroup>
64-
<ItemGroup>
65-
<None Include="packages.config">
66-
<SubType>Designer</SubType>
67-
</None>
35+
36+
<!-- TODO: Unify this dependency with the LibGit2Sharp NuGet dependency
37+
when the portable NuGet has been officially released. -->
38+
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp1.0'">
39+
<PackageReference Include="LibGit2Sharp.Portable" Version="0.24.10" />
6840
</ItemGroup>
41+
6942
<ItemGroup>
70-
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
43+
<ProjectReference Include="..\GitTools.Testing\GitTools.Testing.csproj" />
7144
</ItemGroup>
45+
7246
<ItemGroup>
73-
<ProjectReference Include="..\GitTools.Testing\GitTools.Testing.csproj">
74-
<Project>{3DCA1530-7A7F-46E4-955F-B4358F1299FA}</Project>
75-
<Name>GitTools.Testing</Name>
76-
</ProjectReference>
47+
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
7748
</ItemGroup>
78-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
79-
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
80-
<PropertyGroup>
81-
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
82-
</PropertyGroup>
83-
<Error Condition="!Exists('..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.runner.visualstudio.2.1.0\build\net20\xunit.runner.visualstudio.props'))" />
84-
</Target>
85-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
86-
Other similar extension points exist, see Microsoft.Common.targets.
87-
<Target Name="BeforeBuild">
88-
</Target>
89-
<Target Name="AfterBuild">
90-
</Target>
91-
-->
9249
</Project>

src/GitTools.Testing.Tests/packages.config

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/GitTools.Testing.nuspec

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/GitTools.Testing.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".configs", ".configs", "{EB
1212
..\README.md = ..\README.md
1313
EndProjectSection
1414
EndProject
15-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTools.Testing.Tests", "GitTools.Testing.Tests\GitTools.Testing.Tests.csproj", "{5CF365CF-85B2-4AA3-8A17-680EFDF617C5}"
15+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitTools.Testing.Tests", "GitTools.Testing.Tests\GitTools.Testing.Tests.csproj", "{5CF365CF-85B2-4AA3-8A17-680EFDF617C5}"
1616
EndProject
17-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitTools.Testing", "GitTools.Testing\GitTools.Testing.csproj", "{3DCA1530-7A7F-46E4-955F-B4358F1299FA}"
17+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GitTools.Testing", "GitTools.Testing\GitTools.Testing.csproj", "{3DCA1530-7A7F-46E4-955F-B4358F1299FA}"
1818
EndProject
1919
Global
2020
GlobalSection(SolutionConfigurationPlatforms) = preSolution

src/GitTools.Testing/Fixtures/BaseGitFlowRepositoryFixture.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ public class BaseGitFlowRepositoryFixture : EmptyRepositoryFixture
1212
{
1313
/// <summary>
1414
/// Creates a repo with a develop branch off master which is a single commit ahead of master
15-
///
15+
///
1616
/// Master will be tagged with the initial version before branching develop
1717
/// </summary>
18-
public BaseGitFlowRepositoryFixture(string initialVersion) :
18+
public BaseGitFlowRepositoryFixture(string initialVersion) :
1919
this(r => r.MakeATaggedCommit(initialVersion))
2020
{
2121
}
2222

2323
/// <summary>
2424
/// Creates a repo with a develop branch off master which is a single commit ahead of master
25-
///
25+
///
2626
/// The initial setup actions will be performed before branching develop
2727
/// </summary>
2828
public BaseGitFlowRepositoryFixture(Action<IRepository> initialMasterAction)
@@ -38,7 +38,7 @@ void SetupRepo(Action<IRepository> initialMasterAction)
3838

3939
initialMasterAction(Repository);
4040

41-
Repository.Checkout(Repository.CreateBranch("develop"));
41+
Commands.Checkout(Repository, Repository.CreateBranch("develop"));
4242
Repository.MakeACommit();
4343
}
4444
}

src/GitTools.Testing/Fixtures/RepositoryFixtureBase.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public virtual void Dispose()
6565

6666
public void Checkout(string branch)
6767
{
68-
Repository.Checkout(branch);
68+
Commands.Checkout(Repository, branch);
6969
}
7070

7171
public void MakeATaggedCommit(string tag)
@@ -83,13 +83,15 @@ public void ApplyTag(string tag)
8383
public void BranchTo(string branchName, string @as = null)
8484
{
8585
_sequenceDiagram.BranchTo(branchName, Repository.Head.FriendlyName, @as);
86-
Repository.Checkout(Repository.CreateBranch(branchName));
86+
var branch = Repository.CreateBranch(branchName);
87+
Commands.Checkout(Repository, branch);
8788
}
8889

8990
public void BranchToFromTag(string branchName, string fromTag, string onBranch, string @as = null)
9091
{
9192
_sequenceDiagram.BranchToFromTag(branchName, fromTag, onBranch, @as);
92-
Repository.Checkout(Repository.CreateBranch(branchName));
93+
var branch = Repository.CreateBranch(branchName);
94+
Commands.Checkout(Repository, branch);
9395
}
9496

9597
public void MakeACommit()

src/GitTools.Testing/GitTestExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static Tag MakeATaggedCommit(this IRepository repository, string tag)
6363

6464
public static Commit CreatePullRequestRef(this IRepository repository, string from, string to, int prNumber = 2, bool normalise = false, bool allowFastFowardMerge = false)
6565
{
66-
repository.Checkout(repository.Branches[to].Tip);
66+
Commands.Checkout(repository, repository.Branches[to].Tip);
6767
if (allowFastFowardMerge)
6868
{
6969
repository.Merge(repository.Branches[from], Generate.SignatureNow());
@@ -74,11 +74,11 @@ public static Commit CreatePullRequestRef(this IRepository repository, string fr
7474
}
7575
var commit = repository.Head.Tip;
7676
repository.Refs.Add("refs/pull/" + prNumber + "/merge", commit.Id);
77-
repository.Checkout(to);
77+
Commands.Checkout(repository, to);
7878
if (normalise)
7979
{
8080
// Turn the ref into a real branch
81-
repository.Checkout(repository.Branches.Add("pull/" + prNumber + "/merge", commit));
81+
Commands.Checkout(repository, repository.Branches.Add("pull/" + prNumber + "/merge", commit));
8282
}
8383

8484
return commit;

0 commit comments

Comments
 (0)