File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -10,9 +10,21 @@ namespace Elastic.Markdown.IO;
1010
1111public record GitConfiguration
1212{
13- [ JsonPropertyName ( "branch" ) ] public required string Branch { get ; init ; }
14- [ JsonPropertyName ( "remote" ) ] public required string Remote { get ; init ; }
15- [ JsonPropertyName ( "ref" ) ] public required string Ref { get ; init ; }
13+ private static GitConfiguration Unavailable { get ; } = new ( )
14+ {
15+ Branch = "unavailable" ,
16+ Remote = "unavailable" ,
17+ Ref = "unavailable"
18+ } ;
19+
20+ [ JsonPropertyName ( "branch" ) ]
21+ public required string Branch { get ; init ; }
22+
23+ [ JsonPropertyName ( "remote" ) ]
24+ public required string Remote { get ; init ; }
25+
26+ [ JsonPropertyName ( "ref" ) ]
27+ public required string Ref { get ; init ; }
1628
1729 // manual read because libgit2sharp is not yet AOT ready
1830 public static GitConfiguration Create ( IFileSystem fileSystem )
@@ -26,7 +38,7 @@ public static GitConfiguration Create(IFileSystem fileSystem)
2638
2739 var gitConfig = Git ( ".git/config" ) ;
2840 if ( ! gitConfig . Exists )
29- throw new Exception ( $ " { Paths . Root . FullName } is not a git repository." ) ;
41+ return Unavailable ;
3042
3143 var head = Read ( ".git/HEAD" ) ;
3244 var gitRef = head ;
You can’t perform that action at this time.
0 commit comments