Skip to content

Commit fc5de2f

Browse files
committed
Add git support
1 parent 5b1d94a commit fc5de2f

3 files changed

Lines changed: 35 additions & 2 deletions

File tree

StyleCop.Analyzers.Status.Generator/Program.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
namespace StyleCop.Analyzers.Status.Generator
22
{
33
using System;
4+
using System.IO;
5+
using LibGit2Sharp;
46
using Newtonsoft.Json;
57

68
/// <summary>
@@ -22,7 +24,22 @@ internal static void Main(string[] args)
2224

2325
SolutionReader reader = SolutionReader.CreateAsync(args[0]).Result;
2426

25-
Console.WriteLine(JsonConvert.SerializeObject(reader.GetDiagnosticsAsync().Result));
27+
var diagnostics = reader.GetDiagnosticsAsync().Result;
28+
29+
string commitId;
30+
31+
using (Repository repository = new Repository(Path.GetDirectoryName(args[0])))
32+
{
33+
commitId = repository.Head.Tip.Sha;
34+
}
35+
36+
var output = new
37+
{
38+
diagnostics,
39+
commitId
40+
};
41+
42+
Console.WriteLine(JsonConvert.SerializeObject(output));
2643
}
2744
}
2845
}

StyleCop.Analyzers.Status.Generator/StyleCop.Analyzers.Status.Generator.csproj

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\packages\LibGit2Sharp.0.21.0.176\build\net40\LibGit2Sharp.props" Condition="Exists('..\packages\LibGit2Sharp.0.21.0.176\build\net40\LibGit2Sharp.props')" />
34
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
45
<PropertyGroup>
56
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -11,6 +12,8 @@
1112
<AssemblyName>StyleCop.Analyzers.Status.Generator</AssemblyName>
1213
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1314
<FileAlignment>512</FileAlignment>
15+
<NuGetPackageImportStamp>
16+
</NuGetPackageImportStamp>
1417
</PropertyGroup>
1518
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1619
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -33,6 +36,10 @@
3336
<WarningLevel>4</WarningLevel>
3437
</PropertyGroup>
3538
<ItemGroup>
39+
<Reference Include="LibGit2Sharp, Version=0.21.0.176, Culture=neutral, processorArchitecture=MSIL">
40+
<HintPath>..\packages\LibGit2Sharp.0.21.0.176\lib\net40\LibGit2Sharp.dll</HintPath>
41+
<Private>True</Private>
42+
</Reference>
3643
<Reference Include="Microsoft.CodeAnalysis, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
3744
<HintPath>..\packages\Microsoft.CodeAnalysis.Common.1.0.0-rc2\lib\net45\Microsoft.CodeAnalysis.dll</HintPath>
3845
<Private>True</Private>
@@ -118,7 +125,9 @@
118125
</ItemGroup>
119126
<ItemGroup>
120127
<None Include="App.config" />
121-
<None Include="packages.config" />
128+
<None Include="packages.config">
129+
<SubType>Designer</SubType>
130+
</None>
122131
<None Include="Rules.ruleset" />
123132
</ItemGroup>
124133
<ItemGroup>
@@ -127,6 +136,12 @@
127136
<Analyzer Include="..\packages\StyleCop.Analyzers.1.0.0-alpha007\tools\analyzers\C#\StyleCop.Analyzers.dll" />
128137
</ItemGroup>
129138
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
139+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
140+
<PropertyGroup>
141+
<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>
142+
</PropertyGroup>
143+
<Error Condition="!Exists('..\packages\LibGit2Sharp.0.21.0.176\build\net40\LibGit2Sharp.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LibGit2Sharp.0.21.0.176\build\net40\LibGit2Sharp.props'))" />
144+
</Target>
130145
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
131146
Other similar extension points exist, see Microsoft.Common.targets.
132147
<Target Name="BeforeBuild">

StyleCop.Analyzers.Status.Generator/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3+
<package id="LibGit2Sharp" version="0.21.0.176" targetFramework="net45" userInstalled="true" />
34
<package id="Microsoft.CodeAnalysis.Analyzers" version="1.0.0-rc2" targetFramework="net45" userInstalled="true" />
45
<package id="Microsoft.CodeAnalysis.Common" version="1.0.0-rc2" targetFramework="net45" userInstalled="true" />
56
<package id="Microsoft.CodeAnalysis.CSharp" version="1.0.0-rc2" targetFramework="net45" userInstalled="true" />

0 commit comments

Comments
 (0)