From a1406d13729bf89264211b8db27d489608cb64bd Mon Sep 17 00:00:00 2001 From: nulltoken Date: Mon, 8 Jun 2015 23:27:10 +0200 Subject: [PATCH] Fix some minor issues found by Coverity --- LibGit2Sharp/Version.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/LibGit2Sharp/Version.cs b/LibGit2Sharp/Version.cs index a3f7edb6b..fbc6ef891 100644 --- a/LibGit2Sharp/Version.cs +++ b/LibGit2Sharp/Version.cs @@ -57,10 +57,7 @@ public virtual BuiltInFeatures Features /// public virtual string LibGit2CommitSha { - get - { - return ReadContentFromResource(assembly, "libgit2_hash.txt").Substring(0, 7); - } + get { return RetrieveAbbrevShaFrom("libgit2_hash.txt"); } } /// @@ -68,10 +65,14 @@ public virtual string LibGit2CommitSha /// public virtual string LibGit2SharpCommitSha { - get - { - return ReadContentFromResource(assembly, "libgit2sharp_hash.txt").Substring(0, 7); - } + get { return RetrieveAbbrevShaFrom("libgit2sharp_hash.txt"); } + } + + private string RetrieveAbbrevShaFrom(string name) + { + string sha = ReadContentFromResource(assembly, name) ?? "unknown"; + + return sha.Substring(0, 7); } ///