Skip to content

Commit 913250a

Browse files
Don't fall over if there is no git repo.
Fixes #103.
1 parent bdfbdce commit 913250a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/NerdBank.GitVersioning/VersionOracle.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ private static LibGit2Sharp.Repository OpenGitRepo(string repoRoot)
278278

279279
private static Version GetAssemblyVersion(Version version, VersionOptions versionOptions)
280280
{
281+
// If there is no repo, "version" could have uninitialized components (-1).
282+
version = version.EnsureNonNegativeComponents();
283+
281284
var assemblyVersion = versionOptions?.AssemblyVersion?.Version ?? new System.Version(version.Major, version.Minor);
282285
assemblyVersion = new System.Version(
283286
assemblyVersion.Major,

0 commit comments

Comments
 (0)