1
1
using System . Globalization ;
2
- using System . IO ;
3
- using System . Linq ;
4
- using System . Reflection ;
5
2
using LibGit2Sharp . Core ;
6
3
7
4
namespace LibGit2Sharp
@@ -11,8 +8,6 @@ namespace LibGit2Sharp
11
8
/// </summary>
12
9
public class Version
13
10
{
14
- private readonly Assembly assembly = typeof ( Repository ) . Assembly ;
15
-
16
11
/// <summary>
17
12
/// Needed for mocking purposes.
18
13
/// </summary>
@@ -42,23 +37,15 @@ public virtual BuiltInFeatures Features
42
37
/// <summary>
43
38
/// Returns the SHA hash for the libgit2 library.
44
39
/// </summary>
45
- public virtual string LibGit2CommitSha
46
- {
47
- get { return RetrieveAbbrevShaFrom ( "libgit2_hash.txt" ) ; }
48
- }
40
+ public virtual string LibGit2CommitSha => RetrieveAbbrevShaFrom ( AssemblyCommitIds . LibGit2CommitSha ) ;
49
41
50
42
/// <summary>
51
43
/// Returns the SHA hash for the LibGit2Sharp library.
52
44
/// </summary>
53
- public virtual string LibGit2SharpCommitSha
54
- {
55
- get { return RetrieveAbbrevShaFrom ( "libgit2sharp_hash.txt" ) ; }
56
- }
45
+ public virtual string LibGit2SharpCommitSha => RetrieveAbbrevShaFrom ( AssemblyCommitIds . LibGit2SharpCommitSha ) ;
57
46
58
- private string RetrieveAbbrevShaFrom ( string name )
47
+ private string RetrieveAbbrevShaFrom ( string sha )
59
48
{
60
- string sha = ReadContentFromResource ( assembly , name ) ?? "unknown" ;
61
-
62
49
var index = sha . Length > 7 ? 7 : sha . Length ;
63
50
return sha . Substring ( 0 , index ) ;
64
51
}
@@ -68,7 +55,7 @@ private string RetrieveAbbrevShaFrom(string name)
68
55
/// </summary>
69
56
/// <para>
70
57
/// The format of the version number is as follows:
71
- /// <para>Major.Minor.Patch- LibGit2Sharp_abbrev_hash- libgit2_abbrev_hash (x86|x64 - features)</para>
58
+ /// <para>Major.Minor.Patch+g{ LibGit2Sharp_abbrev_hash}.libgit2-{ libgit2_abbrev_hash} (x86|x64 - features)</para>
72
59
/// </para>
73
60
/// <returns></returns>
74
61
public override string ToString ( )
@@ -86,14 +73,5 @@ private string RetrieveVersion()
86
73
Platform . ProcessorArchitecture ,
87
74
features ) ;
88
75
}
89
-
90
- private string ReadContentFromResource ( Assembly assembly , string partialResourceName )
91
- {
92
- string name = string . Format ( CultureInfo . InvariantCulture , "LibGit2Sharp.{0}" , partialResourceName ) ;
93
- using ( var sr = new StreamReader ( assembly . GetManifestResourceStream ( name ) ) )
94
- {
95
- return sr . ReadLine ( ) ;
96
- }
97
- }
98
76
}
99
77
}
0 commit comments