File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 2
2
// Licensed under the MIT License. See the LICENSE.
3
3
4
4
using LibGit2Sharp ;
5
- using System ;
6
5
using Files . App . Filesystem . StorageItems ;
7
6
8
7
namespace Files . App . Helpers
@@ -22,9 +21,16 @@ public static class GitHelpers
22
21
)
23
22
return null ;
24
23
25
- return Repository . IsValid ( path )
26
- ? path
27
- : GetGitRepositoryPath ( PathNormalization . GetParentDir ( path ) , root ) ;
24
+ try
25
+ {
26
+ return Repository . IsValid ( path )
27
+ ? path
28
+ : GetGitRepositoryPath ( PathNormalization . GetParentDir ( path ) , root ) ;
29
+ }
30
+ catch ( LibGit2SharpException )
31
+ {
32
+ return null ;
33
+ }
28
34
}
29
35
}
30
36
}
Original file line number Diff line number Diff line change @@ -181,8 +181,8 @@ public string GitBranchName
181
181
if ( IsGitRepository )
182
182
{
183
183
using var repository = new Repository ( gitRepositoryPath ) ;
184
- return repository . Branches . First ( branch =>
185
- branch . IsCurrentRepositoryHead ) . FriendlyName ;
184
+ return repository . Branches . FirstOrDefault ( branch =>
185
+ branch . IsCurrentRepositoryHead ) ? . FriendlyName ?? string . Empty ;
186
186
}
187
187
188
188
return string . Empty ;
You can’t perform that action at this time.
0 commit comments