Skip to content

Commit 4d79857

Browse files
gitfoolkzu
authored andcommitted
Clean code
1 parent 65aaac9 commit 4d79857

File tree

11 files changed

+601
-784
lines changed

11 files changed

+601
-784
lines changed

readme.md

Lines changed: 111 additions & 135 deletions
Large diffs are not rendered by default.

src/GitInfo/build/GitInfo.AssemblyInfo.targets

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,26 @@
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<!--
44
==============================================================
5-
Provides ThisAssembly generation
5+
Provides ThisAssembly generation.
66
7-
$(GitThisAssembly): set to 'false' to prevent assembly
8-
metadata and constants generation.
7+
$(GitThisAssembly): set to 'false' to prevent assembly metadata and constants generation.
98
10-
$(ThisAssemblyNamespace): allows overriding the namespace
11-
for the ThisAssembly class.
12-
Defaults to the global namespace.
13-
14-
==============================================================
15-
-->
9+
$(ThisAssemblyNamespace): allows overriding the namespace for the ThisAssembly class. Defaults to the global namespace.
10+
==============================================================
11+
-->
1612

1713
<PropertyGroup>
18-
<GitInfoThisAssemblyFile Condition="'$(GitInfoThisAssemblyFile)' == '' And '$(DefaultLanguageSourceExtension)' != ''">$(IntermediateOutputPath)ThisAssembly.GitInfo.g$(DefaultLanguageSourceExtension)</GitInfoThisAssemblyFile>
19-
<GitThisAssembly Condition="'$(Language)' != 'C#' And '$(Language)' != 'F#' And '$(Language)' != 'VB'">false</GitThisAssembly>
20-
<GitThisAssembly Condition="'$(GitThisAssembly)' == '' And '$(GitInfoThisAssemblyFile)' != ''">true</GitThisAssembly>
14+
<GitInfoThisAssemblyFile Condition="'$(GitInfoThisAssemblyFile)' == '' and '$(DefaultLanguageSourceExtension)' != ''">$(IntermediateOutputPath)ThisAssembly.GitInfo.g$(DefaultLanguageSourceExtension)</GitInfoThisAssemblyFile>
15+
<GitThisAssembly Condition="'$(Language)' != 'C#' and '$(Language)' != 'F#' and '$(Language)' != 'VB'">false</GitThisAssembly>
16+
<GitThisAssembly Condition="'$(GitThisAssembly)' == '' and '$(GitInfoThisAssemblyFile)' != ''">true</GitThisAssembly>
2117
</PropertyGroup>
2218

2319
<!-- Private properties -->
2420
<PropertyGroup>
2521
<CoreCompileDependsOn Condition="'$(GitThisAssembly)' == 'true'">GitThisAssembly;$(CoreCompileDependsOn)</CoreCompileDependsOn>
2622
</PropertyGroup>
2723

28-
<Target Name="GitThisAssembly" DependsOnTargets="GitVersion;_GitGenerateThisAssembly"
29-
BeforeTargets="BuildOnlySettings" Condition="'$(GitThisAssembly)' == 'true'">
30-
24+
<Target Name="GitThisAssembly" DependsOnTargets="GitVersion;_GitGenerateThisAssembly" BeforeTargets="BuildOnlySettings" Condition="'$(GitThisAssembly)' == 'true'">
3125
<ItemGroup Condition="'$(Language)' != 'F#'">
3226
<Compile Remove="$(GitInfoThisAssemblyFile)" />
3327
<Compile Include="$(GitInfoThisAssemblyFile)" />
@@ -44,9 +38,7 @@
4438
</ItemGroup>
4539
</Target>
4640

47-
<Target Name="_GitGenerateThisAssembly" Condition="'$(GitThisAssembly)' == 'true'"
48-
Inputs="@(_GitInput)" Outputs="$(GitInfoThisAssemblyFile)">
49-
41+
<Target Name="_GitGenerateThisAssembly" Inputs="@(_GitInput)" Outputs="$(GitInfoThisAssemblyFile)" Condition="'$(GitThisAssembly)' == 'true'">
5042
<PropertyGroup>
5143
<_ThisAssemblyContent>$([System.IO.File]::ReadAllText('$(MSBuildThisFileDirectory)GitInfo$(DefaultLanguageSourceExtension).pp'))</_ThisAssemblyContent>
5244

@@ -61,17 +53,17 @@
6153
<_ThisAssemblyContent>$(_ThisAssemblyContent.Replace('_RootNamespace_', '$(ThisAssemblyNamespace)'))</_ThisAssemblyContent>
6254

6355
<!-- no git repository -->
64-
<_ThisAssemblyContent Condition="'$(Language)' == 'C#' And '$(GitRoot)' == ''">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'false'))</_ThisAssemblyContent>
65-
<_ThisAssemblyContent Condition="'$(Language)' == 'C#' And '$(GitIsDirty)' != '0'">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'true'))</_ThisAssemblyContent>
66-
<_ThisAssemblyContent Condition="'$(Language)' == 'C#' And '$(GitIsDirty)' == '0'">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'false'))</_ThisAssemblyContent>
56+
<_ThisAssemblyContent Condition="'$(Language)' == 'C#' and '$(GitRoot)' == ''">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'false'))</_ThisAssemblyContent>
57+
<_ThisAssemblyContent Condition="'$(Language)' == 'C#' and '$(GitIsDirty)' != '0'">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'true'))</_ThisAssemblyContent>
58+
<_ThisAssemblyContent Condition="'$(Language)' == 'C#' and '$(GitIsDirty)' == '0'">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'false'))</_ThisAssemblyContent>
6759
<!-- no git repository -->
68-
<_ThisAssemblyContent Condition="'$(Language)' == 'F#' And '$(GitRoot)' == ''">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'false'))</_ThisAssemblyContent>
69-
<_ThisAssemblyContent Condition="'$(Language)' == 'F#' And '$(GitIsDirty)' != '0'">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'true'))</_ThisAssemblyContent>
70-
<_ThisAssemblyContent Condition="'$(Language)' == 'F#' And '$(GitIsDirty)' == '0'">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'false'))</_ThisAssemblyContent>
60+
<_ThisAssemblyContent Condition="'$(Language)' == 'F#' and '$(GitRoot)' == ''">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'false'))</_ThisAssemblyContent>
61+
<_ThisAssemblyContent Condition="'$(Language)' == 'F#' and '$(GitIsDirty)' != '0'">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'true'))</_ThisAssemblyContent>
62+
<_ThisAssemblyContent Condition="'$(Language)' == 'F#' and '$(GitIsDirty)' == '0'">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'false'))</_ThisAssemblyContent>
7163
<!-- no git repository -->
72-
<_ThisAssemblyContent Condition="'$(Language)' == 'VB' And '$(GitRoot)' == ''">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'False'))</_ThisAssemblyContent>
73-
<_ThisAssemblyContent Condition="'$(Language)' == 'VB' And '$(GitIsDirty)' != '0'">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'True'))</_ThisAssemblyContent>
74-
<_ThisAssemblyContent Condition="'$(Language)' == 'VB' And '$(GitIsDirty)' == '0'">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'False'))</_ThisAssemblyContent>
64+
<_ThisAssemblyContent Condition="'$(Language)' == 'VB' and '$(GitRoot)' == ''">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'False'))</_ThisAssemblyContent>
65+
<_ThisAssemblyContent Condition="'$(Language)' == 'VB' and '$(GitIsDirty)' != '0'">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'True'))</_ThisAssemblyContent>
66+
<_ThisAssemblyContent Condition="'$(Language)' == 'VB' and '$(GitIsDirty)' == '0'">$(_ThisAssemblyContent.Replace('$GitIsDirty$', 'False'))</_ThisAssemblyContent>
7567

7668
<_ThisAssemblyContent>$(_ThisAssemblyContent.Replace('$GitRepositoryUrl$', '$(GitRepositoryUrl)'))</_ThisAssemblyContent>
7769
<_ThisAssemblyContent>$(_ThisAssemblyContent.Replace('$GitBranch$', '$(GitBranch)'))</_ThisAssemblyContent>
@@ -100,7 +92,6 @@
10092

10193
<MakeDir Directories="$(GitInfoThisAssemblyDir)" Condition="!Exists('$(GitInfoThisAssemblyDir)')" />
10294

103-
<WriteLinesToFile File='$(GitInfoThisAssemblyFile)' Lines='$(_ThisAssemblyContent)' Overwrite='true' />
95+
<WriteLinesToFile File="$(GitInfoThisAssemblyFile)" Lines="$(_ThisAssemblyContent)" Overwrite="true" />
10496
</Target>
105-
106-
</Project>
97+
</Project>

src/GitInfo/build/GitInfo.AssemblyMetadata.targets

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,24 @@
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<!--
44
==============================================================
5-
Provides assembly-level metadata
6-
for Git information.
5+
Provides assembly-level metadata for Git information.
76
8-
$(GitThisAssemblyMetadata): set to 'false' to prevent assembly
9-
metadata generation. Defaults to 'false'.
10-
==============================================================
11-
-->
7+
$(GitThisAssemblyMetadata): set to 'false' to prevent assembly metadata generation. Defaults to 'false'.
8+
==============================================================
9+
-->
1210

1311
<Target Name="GitAssemblyMetadata" DependsOnTargets="GitVersion" BeforeTargets="BuildOnlySettings">
14-
1512
<ItemGroup Condition="'$(Language)' != 'VB'">
16-
<AssemblyMetadata Include="GitInfo.IsDirty"
17-
Condition="'$(GitRoot)' == ''"
18-
Value="false" />
19-
<AssemblyMetadata Include="GitInfo.IsDirty"
20-
Condition="'$(GitIsDirty)' != '0'"
21-
Value="true" />
22-
<AssemblyMetadata Include="GitInfo.IsDirty"
23-
Condition="'$(GitIsDirty)' == '0'"
24-
Value="false" />
13+
<AssemblyMetadata Include="GitInfo.IsDirty" Value="false" Condition="'$(GitRoot)' == ''" />
14+
<AssemblyMetadata Include="GitInfo.IsDirty" Value="true" Condition="'$(GitIsDirty)' != '0'" />
15+
<AssemblyMetadata Include="GitInfo.IsDirty" Value="false" Condition="'$(GitIsDirty)' == '0'" />
2516
</ItemGroup>
2617

27-
<!-- For backwards-compatibility reasons, we keep the VB casing on these -->
18+
<!-- For backwards-compatibility reasons, we keep the VB casing on these. -->
2819
<ItemGroup Condition="'$(Language)' == 'VB'">
29-
<AssemblyMetadata Include="GitInfo.IsDirty"
30-
Condition="'$(GitRoot)' == ''"
31-
Value="False" />
32-
<AssemblyMetadata Include="GitInfo.IsDirty"
33-
Condition="'$(GitIsDirty)' != '0'"
34-
Value="True" />
35-
<AssemblyMetadata Include="GitInfo.IsDirty"
36-
Condition="'$(GitIsDirty)' == '0'"
37-
Value="False" />
20+
<AssemblyMetadata Include="GitInfo.IsDirty" Value="False" Condition="'$(GitRoot)' == ''" />
21+
<AssemblyMetadata Include="GitInfo.IsDirty" Value="True" Condition="'$(GitIsDirty)' != '0'" />
22+
<AssemblyMetadata Include="GitInfo.IsDirty" Value="False" Condition="'$(GitIsDirty)' == '0'" />
3823
</ItemGroup>
3924

4025
<ItemGroup>
@@ -58,5 +43,4 @@
5843
<AssemblyMetadata Include="GitInfo.SemVer.Source" Value="$(GitSemVerSource)" />
5944
</ItemGroup>
6045
</Target>
61-
62-
</Project>
46+
</Project>

src/GitInfo/build/GitInfo.ThisAssembly.targets

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<!--
44
==============================================================
5-
Leverages ThisAssembly.Constants generator
6-
to expose assembly info constants
5+
Leverages ThisAssembly.Constants generator to expose assembly info constants.
76
8-
$(GitThisAssembly): set to 'false' to prevent assembly
9-
metadata and constants generation.
10-
11-
==============================================================
12-
-->
7+
$(GitThisAssembly): set to 'false' to prevent assembly metadata and constants generation.
8+
==============================================================
9+
-->
1310

1411
<PropertyGroup>
1512
<GitThisAssembly Condition="'$(GitThisAssembly)' == ''">true</GitThisAssembly>
@@ -25,9 +22,7 @@
2522
<CompilerVisibleProperty Include="GitThisAssembly" />
2623
</ItemGroup>
2724

28-
<Target Name="GitThisAssembly" DependsOnTargets="GitVersion"
29-
BeforeTargets="PrepareConstants;GenerateMSBuildEditorConfigFileShouldRun" Condition="'$(GitThisAssembly)' == 'true'">
30-
25+
<Target Name="GitThisAssembly" DependsOnTargets="GitVersion" BeforeTargets="PrepareConstants;GenerateMSBuildEditorConfigFileShouldRun" Condition="'$(GitThisAssembly)' == 'true'">
3126
<ItemGroup>
3227
<Constant Include="IsDirtyString" Value="true" Root="Git" Condition="$(GitIsDirty) == '1'" />
3328
<Constant Include="IsDirtyString" Value="false" Root="Git" Condition="$(GitIsDirty) == '0'" />
@@ -52,7 +47,5 @@
5247
<Constant Include="SemVer.DashLabel" Value="$(GitSemVerDashLabel)" Root="Git" />
5348
<Constant Include="SemVer.Source" Value="$(GitSemVerSource)" Root="Git" />
5449
</ItemGroup>
55-
5650
</Target>
57-
58-
</Project>
51+
</Project>

src/GitInfo/build/GitInfo.cache.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
GitSemVerPatch=$GitSemVerPatch$;
1717
GitSemVerLabel=$GitSemVerLabel$;
1818
GitSemVerDashLabel=$GitSemVerDashLabel$;
19-
GitSemVerSource=$GitSemVerSource$
19+
GitSemVerSource=$GitSemVerSource$

src/GitInfo/build/GitInfo.cs.pp

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,78 +6,78 @@
66
namespace _RootNamespace_
77
{
88
#endif
9-
/// <summary>Provides access to the current assembly information.</summary>
10-
partial class ThisAssembly
11-
{
12-
/// <summary>Provides access to the git information for the current assembly.</summary>
13-
public partial class Git
9+
/// <summary>Provides access to the current assembly information.</summary>
10+
partial class ThisAssembly
1411
{
15-
/// <summary>IsDirty: $GitIsDirty$</summary>
16-
public const bool IsDirty = $GitIsDirty$;
12+
/// <summary>Provides access to the git information for the current assembly.</summary>
13+
public partial class Git
14+
{
15+
/// <summary>IsDirty: $GitIsDirty$</summary>
16+
public const bool IsDirty = $GitIsDirty$;
1717

18-
/// <summary>IsDirtyString: $GitIsDirty$</summary>
19-
public const string IsDirtyString = @"$GitIsDirty$";
18+
/// <summary>IsDirtyString: $GitIsDirty$</summary>
19+
public const string IsDirtyString = @"$GitIsDirty$";
2020

21-
/// <summary>Repository URL: $GitRepositoryUrl$</summary>
22-
public const string RepositoryUrl = @"$GitRepositoryUrl$";
21+
/// <summary>Repository URL: $GitRepositoryUrl$</summary>
22+
public const string RepositoryUrl = @"$GitRepositoryUrl$";
2323

24-
/// <summary>Branch: $GitBranch$</summary>
25-
public const string Branch = @"$GitBranch$";
24+
/// <summary>Branch: $GitBranch$</summary>
25+
public const string Branch = @"$GitBranch$";
2626

27-
/// <summary>Commit: $GitCommit$</summary>
28-
public const string Commit = @"$GitCommit$";
27+
/// <summary>Commit: $GitCommit$</summary>
28+
public const string Commit = @"$GitCommit$";
2929

30-
/// <summary>Sha: $GitSha$</summary>
31-
public const string Sha = @"$GitSha$";
30+
/// <summary>Sha: $GitSha$</summary>
31+
public const string Sha = @"$GitSha$";
3232

33-
/// <summary>Commit date: $GitCommitDate$</summary>
34-
public const string CommitDate = @"$GitCommitDate$";
33+
/// <summary>Commit date: $GitCommitDate$</summary>
34+
public const string CommitDate = @"$GitCommitDate$";
3535

36-
/// <summary>Commits on top of base version: $GitCommits$</summary>
37-
public const string Commits = @"$GitCommits$";
36+
/// <summary>Commits on top of base version: $GitCommits$</summary>
37+
public const string Commits = @"$GitCommits$";
3838

39-
/// <summary>Tag: $GitTag$</summary>
40-
public const string Tag = @"$GitTag$";
39+
/// <summary>Tag: $GitTag$</summary>
40+
public const string Tag = @"$GitTag$";
4141

42-
/// <summary>Base tag: $GitBaseTag$</summary>
43-
public const string BaseTag = @"$GitBaseTag$";
42+
/// <summary>Base tag: $GitBaseTag$</summary>
43+
public const string BaseTag = @"$GitBaseTag$";
4444

45-
/// <summary>Provides access to the base version information used to determine the <see cref="SemVer" />.</summary>
46-
public partial class BaseVersion
47-
{
48-
/// <summary>Major: $GitBaseVersionMajor$</summary>
49-
public const string Major = @"$GitBaseVersionMajor$";
45+
/// <summary>Provides access to the base version information used to determine the <see cref="SemVer" />.</summary>
46+
public partial class BaseVersion
47+
{
48+
/// <summary>Major: $GitBaseVersionMajor$</summary>
49+
public const string Major = @"$GitBaseVersionMajor$";
5050

51-
/// <summary>Minor: $GitBaseVersionMinor$</summary>
52-
public const string Minor = @"$GitBaseVersionMinor$";
51+
/// <summary>Minor: $GitBaseVersionMinor$</summary>
52+
public const string Minor = @"$GitBaseVersionMinor$";
5353

54-
/// <summary>Patch: $GitBaseVersionPatch$</summary>
55-
public const string Patch = @"$GitBaseVersionPatch$";
56-
}
54+
/// <summary>Patch: $GitBaseVersionPatch$</summary>
55+
public const string Patch = @"$GitBaseVersionPatch$";
56+
}
5757

58-
/// <summary>Provides access to SemVer information for the current assembly.</summary>
59-
public partial class SemVer
60-
{
61-
/// <summary>Major: $GitSemVerMajor$</summary>
62-
public const string Major = @"$GitSemVerMajor$";
58+
/// <summary>Provides access to SemVer information for the current assembly.</summary>
59+
public partial class SemVer
60+
{
61+
/// <summary>Major: $GitSemVerMajor$</summary>
62+
public const string Major = @"$GitSemVerMajor$";
6363

64-
/// <summary>Minor: $GitSemVerMinor$</summary>
65-
public const string Minor = @"$GitSemVerMinor$";
64+
/// <summary>Minor: $GitSemVerMinor$</summary>
65+
public const string Minor = @"$GitSemVerMinor$";
6666

67-
/// <summary>Patch: $GitSemVerPatch$</summary>
68-
public const string Patch = @"$GitSemVerPatch$";
67+
/// <summary>Patch: $GitSemVerPatch$</summary>
68+
public const string Patch = @"$GitSemVerPatch$";
6969

70-
/// <summary>Label: $GitSemVerLabel$</summary>
71-
public const string Label = @"$GitSemVerLabel$";
70+
/// <summary>Label: $GitSemVerLabel$</summary>
71+
public const string Label = @"$GitSemVerLabel$";
7272

73-
/// <summary>Label with dash prefix: $GitSemVerDashLabel$</summary>
74-
public const string DashLabel = @"$GitSemVerDashLabel$";
73+
/// <summary>Label with dash prefix: $GitSemVerDashLabel$</summary>
74+
public const string DashLabel = @"$GitSemVerDashLabel$";
7575

76-
/// <summary>Source: $GitSemVerSource$</summary>
77-
public const string Source = @"$GitSemVerSource$";
78-
}
76+
/// <summary>Source: $GitSemVerSource$</summary>
77+
public const string Source = @"$GitSemVerSource$";
78+
}
79+
}
7980
}
80-
}
8181
#if LOCALNAMESPACE
8282
}
8383
#endif

src/GitInfo/build/GitInfo.fs.pp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// <auto-generated />
22
/// <summary>Provides access to the current assembly information.</summary>
3-
module ThisAssembly
3+
module ThisAssembly
44

55
/// <summary>Provides access to the git information for the current assembly.</summary>
66
module Git =
@@ -34,7 +34,7 @@
3434
/// <summary>Base tag: $GitBaseTag$</summary>
3535
let [<Literal>] BaseTag = @"$GitBaseTag$"
3636

37-
/// <summary>Provides access to the base version information used to determine the <see cref="SemVer" />.</summary>
37+
/// <summary>Provides access to the base version information used to determine the <see cref="SemVer" />.</summary>
3838
module BaseVersion =
3939
/// <summary>Major: $GitBaseVersionMajor$</summary>
4040
let [<Literal>] Major = @"$GitBaseVersionMajor$"
@@ -45,7 +45,6 @@
4545
/// <summary>Patch: $GitBaseVersionPatch$</summary>
4646
let [<Literal>] Patch = @"$GitBaseVersionPatch$"
4747

48-
4948
/// <summary>Provides access to SemVer information for the current assembly.</summary>
5049
module SemVer =
5150
/// <summary>Major: $GitSemVerMajor$</summary>

0 commit comments

Comments
 (0)