Skip to content

Latest commit

 

History

History
53 lines (41 loc) · 2.51 KB

README.md

File metadata and controls

53 lines (41 loc) · 2.51 KB

Build Status NuGet MyGet feedz.io

GitReader.SourceGenerator

This library build on top of kekyo/GitReader, which is "Lightweight Git local repository traversal library".

Install

<ItemGroup>
    <PackageReference Include="GitReader.SourceGenerator" Version="0.1.4" OutputItemType="Analyzer" ReferenceOutputAssembly="false" PrivateAssets="all" />
</ItemGroup>

How to configure library

<PropertyGroup Label="Configure GitInfo">
    <!-- optional, default value: $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), '.gitignore')) -->
    <GitInfo_RootDirectory>$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildProjectDirectory), 'My.Project.sln'))\..\.git</GitInfo_RootDirectory>

    <GitInfo_Namespace>My.Project.GitInfoNamespace</GitInfo_Namespace>

    <!-- optional, default value 9 -->
    <GitInfo_CommitAbbreviatedLength>9</GitInfo_CommitAbbreviatedLength>

    <!-- optional, default value true -->
    <GitInfo_UseCache>true</GitInfo_UseCache>

    <!-- optional, default value false -->
    <!-- it check only cache existence, not that HEAD equals HEAD in cache -->
    <GitInfo_UseAggressiveCache>true</GitInfo_UseAggressiveCache>
</PropertyGroup>

How to use library

using My.Project.GitInfoNamespace;

Console.WriteLine(GitInfo.Branch);
Console.WriteLine(GitInfo.CommitAbbreviatedHash);
Console.WriteLine(GitInfo.CommitHash);
Console.WriteLine(GitInfo.CommitDate);
Console.WriteLine(GitInfo.TagName);
Console.WriteLine(GitInfo.Tag);
Console.WriteLine(GitInfo.TagMajor);
Console.WriteLine(GitInfo.TagMinor);
Console.WriteLine(GitInfo.TagBuild);
Console.WriteLine(GitInfo.TagRevision);