Skip to content

Commit d980913

Browse files
committed
remove fody dependency
1 parent 0a11a56 commit d980913

25 files changed

+607
-328
lines changed

GitFlowVersion.sln

+8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj
77
EndProject
88
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitFlowVersionFody", "GitFlowVersionFody\GitFlowVersionFody.csproj", "{A9FCD24C-9BE0-46D3-B7E9-6F4552C04A33}"
99
EndProject
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitFlowVersionTask", "GitFlowVersionTask\GitFlowVersionTask.csproj", "{F7AC0E71-3E9A-4F6D-B986-E004825A48E1}"
11+
EndProject
1012
Global
1113
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1214
Debug|Any CPU = Debug|Any CPU
@@ -33,6 +35,12 @@ Global
3335
{A9FCD24C-9BE0-46D3-B7E9-6F4552C04A33}.Release|Any CPU.ActiveCfg = Release|Any CPU
3436
{A9FCD24C-9BE0-46D3-B7E9-6F4552C04A33}.Release|Any CPU.Build.0 = Release|Any CPU
3537
{A9FCD24C-9BE0-46D3-B7E9-6F4552C04A33}.Release|x86.ActiveCfg = Release|Any CPU
38+
{F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39+
{F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
40+
{F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Debug|x86.ActiveCfg = Debug|Any CPU
41+
{F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
42+
{F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Release|Any CPU.Build.0 = Release|Any CPU
43+
{F7AC0E71-3E9A-4F6D-B986-E004825A48E1}.Release|x86.ActiveCfg = Release|Any CPU
3644
EndGlobalSection
3745
GlobalSection(SolutionProperties) = preSolution
3846
HideSolutionNode = FALSE
File renamed without changes.

GitFlowVersion/DirectoryDateFinder.cs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
namespace GitFlowVersion
2+
{
3+
using System;
4+
using System.IO;
5+
6+
public static class DirectoryDateFinder
7+
{
8+
public static long GetLastDirectoryWrite(string path)
9+
{
10+
var lastHigh = DateTime.MinValue;
11+
foreach (var file in Directory.EnumerateDirectories(path, "*.*", SearchOption.AllDirectories))
12+
{
13+
var lastWriteTime = File.GetLastWriteTime(file);
14+
if (lastWriteTime > lastHigh)
15+
{
16+
lastHigh = lastWriteTime;
17+
}
18+
}
19+
return lastHigh.Ticks;
20+
}
21+
}
22+
}

GitFlowVersion/ErrorException.cs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace GitFlowVersion
2+
{
3+
using System;
4+
5+
public class ErrorException : Exception
6+
{
7+
public ErrorException(string message)
8+
: base(message)
9+
{
10+
11+
}
12+
}
13+
}

GitFlowVersion/GitDirFinder.cs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
namespace GitFlowVersion
2+
{
3+
using System.IO;
4+
5+
public class GitDirFinder
6+
{
7+
8+
public static string TreeWalkForGitDir(string currentDirectory)
9+
{
10+
while (true)
11+
{
12+
var gitDir = Path.Combine(currentDirectory, @".git");
13+
if (Directory.Exists(gitDir))
14+
{
15+
return gitDir;
16+
}
17+
var parent = Directory.GetParent(currentDirectory);
18+
if (parent == null)
19+
{
20+
break;
21+
}
22+
currentDirectory = parent.FullName;
23+
}
24+
return null;
25+
}
26+
}
27+
}

GitFlowVersion/GitFlowVersion.csproj

+8
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
<Compile Include="BranchFinders\HotfixVersionFinder.cs" />
4747
<Compile Include="BranchFinders\VersionOnMasterFinder.cs" />
4848
<Compile Include="BranchType.cs" />
49+
<Compile Include="CachedVersion.cs" />
50+
<Compile Include="DirectoryDateFinder.cs" />
51+
<Compile Include="GitDirFinder.cs" />
4952
<Compile Include="InformationalVersionBuilder.cs" />
5053
<Compile Include="Logger.cs" />
5154
<Compile Include="MergeMessageParser.cs" />
@@ -57,11 +60,16 @@
5760
<Compile Include="BranchFinders\MasterVersionFinder.cs" />
5861
<Compile Include="MissingBranchException.cs" />
5962
<Compile Include="Program.cs" />
63+
<Compile Include="RepositoryLoader.cs" />
64+
<Compile Include="SearchPath.cs" />
6065
<Compile Include="TeamCity.cs" />
6166
<Compile Include="SemanticVersion.cs" />
6267
<Compile Include="Stability.cs" />
68+
<Compile Include="VersionAndBranch.cs" />
69+
<Compile Include="VersionCache.cs" />
6370
<Compile Include="VersionForDirectoryFinder.cs" />
6471
<Compile Include="VersionPoint.cs" />
72+
<Compile Include="ErrorException.cs" />
6573
</ItemGroup>
6674
<ItemGroup>
6775
<None Include="packages.config">
+69-66
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,93 @@
1-
using System;
2-
using GitFlowVersion;
3-
4-
public static class VersionInformationalConverter
1+
namespace GitFlowVersion
52
{
6-
public static string ToLongString(this VersionAndBranch versionAndBranch)
7-
{
8-
var version = versionAndBranch.Version;
9-
var versionPrefix = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Patch);
3+
using System;
104

11-
if (versionAndBranch.BranchType == BranchType.Feature)
5+
public static class VersionInformationalConverter
6+
{
7+
public static string ToLongString(this VersionAndBranch versionAndBranch)
128
{
13-
var shortSha = versionAndBranch.Sha.Substring(0, 8);
14-
return string.Format("{0}-unstable.feature-{1} Branch:'{2}' Sha:'{3}'", versionPrefix, shortSha, versionAndBranch.BranchName, versionAndBranch.Sha);
15-
}
9+
var version = versionAndBranch.Version;
10+
var versionPrefix = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Patch);
1611

17-
if (versionAndBranch.BranchType == BranchType.PullRequest)
18-
{
19-
return string.Format("{0}-unstable.pull-request-{1} Branch:'{2}' Sha:'{3}'", versionPrefix, version.PreReleaseNumber, versionAndBranch.BranchName, versionAndBranch.Sha);
20-
}
12+
if (versionAndBranch.BranchType == BranchType.Feature)
13+
{
14+
var shortSha = versionAndBranch.Sha.Substring(0, 8);
15+
return string.Format("{0}-unstable.feature-{1} Branch:'{2}' Sha:'{3}'", versionPrefix, shortSha, versionAndBranch.BranchName, versionAndBranch.Sha);
16+
}
2117

22-
if (versionAndBranch.BranchType == BranchType.Develop)
23-
{
24-
return string.Format("{0}-unstable{1} Branch:'{2}' Sha:'{3}'", versionPrefix, version.PreReleaseNumber, versionAndBranch.BranchName, versionAndBranch.Sha);
25-
}
18+
if (versionAndBranch.BranchType == BranchType.PullRequest)
19+
{
20+
return string.Format("{0}-unstable.pull-request-{1} Branch:'{2}' Sha:'{3}'", versionPrefix, version.PreReleaseNumber, versionAndBranch.BranchName, versionAndBranch.Sha);
21+
}
2622

27-
if (versionAndBranch.BranchType == BranchType.Release)
28-
{
29-
if (version.Stability == Stability.ReleaseCandidate)
23+
if (versionAndBranch.BranchType == BranchType.Develop)
3024
{
31-
return string.Format("{0}-rc{1} Branch:'{2}' Sha:'{3}'", versionPrefix, version.PreReleaseNumber, versionAndBranch.BranchName, versionAndBranch.Sha);
25+
return string.Format("{0}-unstable{1} Branch:'{2}' Sha:'{3}'", versionPrefix, version.PreReleaseNumber, versionAndBranch.BranchName, versionAndBranch.Sha);
3226
}
33-
return string.Format("{0}-beta{1} Branch:'{2}' Sha:'{3}'", versionPrefix, version.PreReleaseNumber, versionAndBranch.BranchName, versionAndBranch.Sha);
34-
}
3527

36-
if (versionAndBranch.BranchType == BranchType.Hotfix)
37-
{
38-
return string.Format("{0}-beta{1} Branch:'{2}' Sha:'{3}'", versionPrefix, version.PreReleaseNumber, versionAndBranch.BranchName, versionAndBranch.Sha);
39-
}
28+
if (versionAndBranch.BranchType == BranchType.Release)
29+
{
30+
if (version.Stability == Stability.ReleaseCandidate)
31+
{
32+
return string.Format("{0}-rc{1} Branch:'{2}' Sha:'{3}'", versionPrefix, version.PreReleaseNumber, versionAndBranch.BranchName, versionAndBranch.Sha);
33+
}
34+
return string.Format("{0}-beta{1} Branch:'{2}' Sha:'{3}'", versionPrefix, version.PreReleaseNumber, versionAndBranch.BranchName, versionAndBranch.Sha);
35+
}
4036

41-
if (versionAndBranch.BranchType == BranchType.Master)
42-
{
43-
return string.Format("{0} Sha:'{1}'", versionPrefix, versionAndBranch.Sha);
44-
}
37+
if (versionAndBranch.BranchType == BranchType.Hotfix)
38+
{
39+
return string.Format("{0}-beta{1} Branch:'{2}' Sha:'{3}'", versionPrefix, version.PreReleaseNumber, versionAndBranch.BranchName, versionAndBranch.Sha);
40+
}
4541

46-
throw new Exception(string.Format("Invalid branch type '{0}'.", versionAndBranch.BranchType));
47-
}
48-
public static string ToShortString(this VersionAndBranch versionAndBranch)
49-
{
50-
var version = versionAndBranch.Version;
51-
var versionPrefix = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Patch);
42+
if (versionAndBranch.BranchType == BranchType.Master)
43+
{
44+
return string.Format("{0} Sha:'{1}'", versionPrefix, versionAndBranch.Sha);
45+
}
5246

53-
if (versionAndBranch.BranchType == BranchType.Feature)
54-
{
55-
var shortSha = versionAndBranch.Sha.Substring(0, 8);
56-
return string.Format("{0}-unstable.feature-{1}", versionPrefix, shortSha);
47+
throw new Exception(string.Format("Invalid branch type '{0}'.", versionAndBranch.BranchType));
5748
}
5849

59-
if (versionAndBranch.BranchType == BranchType.PullRequest)
50+
public static string ToShortString(this VersionAndBranch versionAndBranch)
6051
{
61-
return string.Format("{0}-unstable.pull-request-{1}", versionPrefix, version.PreReleaseNumber);
62-
}
52+
var version = versionAndBranch.Version;
53+
var versionPrefix = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Patch);
6354

64-
if (versionAndBranch.BranchType == BranchType.Develop)
65-
{
66-
return string.Format("{0}-unstable{1}", versionPrefix, version.PreReleaseNumber);
67-
}
55+
if (versionAndBranch.BranchType == BranchType.Feature)
56+
{
57+
var shortSha = versionAndBranch.Sha.Substring(0, 8);
58+
return string.Format("{0}-unstable.feature-{1}", versionPrefix, shortSha);
59+
}
6860

69-
if (versionAndBranch.BranchType == BranchType.Release)
70-
{
71-
if (version.Stability == Stability.ReleaseCandidate)
61+
if (versionAndBranch.BranchType == BranchType.PullRequest)
7262
{
73-
return string.Format("{0}-rc{1}", versionPrefix, version.PreReleaseNumber);
63+
return string.Format("{0}-unstable.pull-request-{1}", versionPrefix, version.PreReleaseNumber);
7464
}
75-
return string.Format("{0}-beta{1}", versionPrefix, version.PreReleaseNumber);
76-
}
7765

78-
if (versionAndBranch.BranchType == BranchType.Hotfix)
79-
{
80-
return string.Format("{0}-beta{1}", versionPrefix, version.PreReleaseNumber);
81-
}
66+
if (versionAndBranch.BranchType == BranchType.Develop)
67+
{
68+
return string.Format("{0}-unstable{1}", versionPrefix, version.PreReleaseNumber);
69+
}
8270

83-
if (versionAndBranch.BranchType == BranchType.Master)
84-
{
85-
return versionPrefix;
86-
}
71+
if (versionAndBranch.BranchType == BranchType.Release)
72+
{
73+
if (version.Stability == Stability.ReleaseCandidate)
74+
{
75+
return string.Format("{0}-rc{1}", versionPrefix, version.PreReleaseNumber);
76+
}
77+
return string.Format("{0}-beta{1}", versionPrefix, version.PreReleaseNumber);
78+
}
79+
80+
if (versionAndBranch.BranchType == BranchType.Hotfix)
81+
{
82+
return string.Format("{0}-beta{1}", versionPrefix, version.PreReleaseNumber);
83+
}
84+
85+
if (versionAndBranch.BranchType == BranchType.Master)
86+
{
87+
return versionPrefix;
88+
}
8789

88-
throw new Exception(string.Format("Invalid branch type '{0}'.", versionAndBranch.BranchType));
90+
throw new Exception(string.Format("Invalid branch type '{0}'.", versionAndBranch.BranchType));
91+
}
8992
}
9093
}

GitFlowVersion/RepositoryLoader.cs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
namespace GitFlowVersion
2+
{
3+
using System;
4+
using LibGit2Sharp;
5+
6+
public class RepositoryLoader
7+
{
8+
public static Repository GetRepo(string gitDirectory)
9+
{
10+
try
11+
{
12+
return new Repository(gitDirectory);
13+
}
14+
catch (Exception exception)
15+
{
16+
if (exception.Message.Contains("LibGit2Sharp.Core.NativeMethods") || exception.Message.Contains("FilePathMarshaler"))
17+
{
18+
throw new ErrorException("Restart of Visual Studio required due to update of 'GitFlowVersion.Fody'.");
19+
}
20+
throw;
21+
}
22+
}
23+
}
24+
}

GitFlowVersion/SearchPath.cs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
namespace GitFlowVersion
2+
{
3+
using System;
4+
using System.IO;
5+
6+
public class SearchPath
7+
{
8+
static bool isPathSet;
9+
10+
public static void SetSearchPath(string addinDirectoryPath)
11+
{
12+
if (isPathSet)
13+
{
14+
return;
15+
}
16+
isPathSet = true;
17+
var nativeBinaries = Path.Combine(addinDirectoryPath, "NativeBinaries", GetProcessorArchitecture());
18+
var existingPath = Environment.GetEnvironmentVariable("PATH");
19+
var newPath = string.Concat(nativeBinaries, Path.PathSeparator, existingPath);
20+
Environment.SetEnvironmentVariable("PATH", newPath);
21+
}
22+
23+
static string GetProcessorArchitecture()
24+
{
25+
if (Environment.Is64BitProcess)
26+
{
27+
return "amd64";
28+
}
29+
return "x86";
30+
}
31+
}
32+
}

GitFlowVersion/SemanticVersion.cs

-8
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@ namespace GitFlowVersion
33
using System;
44
using System.Linq;
55

6-
public class VersionAndBranch
7-
{
8-
public SemanticVersion Version;
9-
public BranchType? BranchType;
10-
public string BranchName;
11-
public string Sha;
12-
}
136
public class SemanticVersion
147
{
158
public string Suffix;
@@ -19,7 +12,6 @@ public class SemanticVersion
1912
public int? PreReleaseNumber;
2013
public Stability Stability;
2114

22-
2315
public static SemanticVersion FromMajorMinorPatch(string versionString)
2416
{
2517
var parts = versionString.Split('-');

0 commit comments

Comments
 (0)