Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3874dda

Browse files
committed
Allow Version class to deal with HEAD as a version hash
The Version code expects a commit Hash to be used to specifiy the version of code in use in the library. However this can also be HEAD. If it is HEAD the current code will crash as it tries to extract 7 characters out of 4.
1 parent 2a8b1f0 commit 3874dda

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

LibGit2Sharp/Version.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ private string RetrieveAbbrevShaFrom(string name)
6969
{
7070
string sha = ReadContentFromResource(assembly, name) ?? "unknown";
7171

72-
return sha.Substring(0, 7);
72+
var index = sha.Length > 7 ? 7 : sha.Length;
73+
return sha.Substring(0, index);
7374
}
7475

7576
/// <summary>

LibGit2Sharp/libgit2sharp_hash.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
unknown
1+
HEAD

0 commit comments

Comments
 (0)