Skip to content

Commit 3010f83

Browse files
committed
Merge pull request #1080 from libgit2/ntk/coverity_fixes
Fix some minor issues found by Coverity
2 parents 738c263 + a1406d1 commit 3010f83

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

LibGit2Sharp/Version.cs

+9-8
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,22 @@ public virtual BuiltInFeatures Features
5757
/// </summary>
5858
public virtual string LibGit2CommitSha
5959
{
60-
get
61-
{
62-
return ReadContentFromResource(assembly, "libgit2_hash.txt").Substring(0, 7);
63-
}
60+
get { return RetrieveAbbrevShaFrom("libgit2_hash.txt"); }
6461
}
6562

6663
/// <summary>
6764
/// Returns the SHA hash for the LibGit2Sharp library.
6865
/// </summary>
6966
public virtual string LibGit2SharpCommitSha
7067
{
71-
get
72-
{
73-
return ReadContentFromResource(assembly, "libgit2sharp_hash.txt").Substring(0, 7);
74-
}
68+
get { return RetrieveAbbrevShaFrom("libgit2sharp_hash.txt"); }
69+
}
70+
71+
private string RetrieveAbbrevShaFrom(string name)
72+
{
73+
string sha = ReadContentFromResource(assembly, name) ?? "unknown";
74+
75+
return sha.Substring(0, 7);
7576
}
7677

7778
/// <summary>

0 commit comments

Comments
 (0)