Skip to content

Commit bdfbdce

Browse files
committed
Fix exception thrown when buildNumberOffset is -1 and uncommitted
Closes #102
1 parent d040da7 commit bdfbdce

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/NerdBank.GitVersioning/GitExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ private static Version GetIdAsVersionHelper(Commit commit, VersionOptions versio
438438
: 0;
439439
}
440440

441-
int build = versionHeight.Value + (versionOptions?.BuildNumberOffset ?? 0);
441+
int build = versionHeight.Value == 0 ? 0 : versionHeight.Value + (versionOptions?.BuildNumberOffset ?? 0);
442442
Verify.Operation(build <= MaximumBuildNumberOrRevisionComponent, "Git height is {0}, which is greater than the maximum allowed {0}.", build, MaximumBuildNumberOrRevisionComponent);
443443
int revision = commit != null
444444
? Math.Min(MaximumBuildNumberOrRevisionComponent, commit.GetTruncatedCommitIdAsUInt16())

0 commit comments

Comments
 (0)