@@ -8,13 +8,19 @@ namespace GitUI
8
8
{
9
9
public sealed class UserEnvironmentInformation
10
10
{
11
- public static void CopyInformation ( )
12
- {
13
- Clipboard . SetText ( GetInformation ( ) ) ;
14
- }
11
+ private static bool _alreadySet ;
12
+ private static bool _dirty ;
13
+ private static string _sha ;
14
+
15
+ public static void CopyInformation ( ) => Clipboard . SetText ( GetInformation ( ) ) ;
15
16
16
17
public static string GetInformation ( )
17
18
{
19
+ if ( ! _alreadySet )
20
+ {
21
+ throw new InvalidOperationException ( $ "{ nameof ( Initialise ) } must be called first") ;
22
+ }
23
+
18
24
string gitVer ;
19
25
try
20
26
{
@@ -27,12 +33,24 @@ public static string GetInformation()
27
33
28
34
StringBuilder sb = new StringBuilder ( ) ;
29
35
30
- sb . AppendFormat ( "- Git Extensions {0}{1}" , AppSettings . ProductVersion , Environment . NewLine ) ;
31
- sb . AppendFormat ( "- {0 } {1}{2}" , ThisAssembly . Git . Sha , ThisAssembly . Git . IsDirty ? " (Dirty)" : "" , Environment . NewLine ) ;
32
- sb . AppendFormat ( "- Git {0}{1}" , gitVer , Environment . NewLine ) ;
33
- sb . AppendFormat ( "- {0}{1}" , Environment . OSVersion , Environment . NewLine ) ;
34
- sb . AppendFormat ( "- {0}" , RuntimeInformation . FrameworkDescription ) ;
36
+ sb . Append ( $ "- Git Extensions { AppSettings . ProductVersion } { Environment . NewLine } " ) ;
37
+ sb . Append ( $ "- { _sha } { ( _dirty ? " (Dirty)" : "" ) } { Environment . NewLine } " ) ;
38
+ sb . Append ( $ "- Git { gitVer } { Environment . NewLine } " ) ;
39
+ sb . Append ( $ "- { Environment . OSVersion } { Environment . NewLine } " ) ;
40
+ sb . Append ( $ "- { RuntimeInformation . FrameworkDescription } " ) ;
35
41
return sb . ToString ( ) ;
36
42
}
43
+
44
+ public static void Initialise ( string sha , bool isDirty )
45
+ {
46
+ if ( _alreadySet )
47
+ {
48
+ return ;
49
+ }
50
+
51
+ _alreadySet = true ;
52
+ _sha = sha ;
53
+ _dirty = isDirty ;
54
+ }
37
55
}
38
56
}
0 commit comments