File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ public static RepositorySettings Get(string gitCommonDir)
8181
8282 if ( ! File . Exists ( fullpath ) )
8383 {
84- setting = new RepositorySettings ( ) ;
84+ setting = new ( ) ;
8585 }
8686 else
8787 {
@@ -92,12 +92,18 @@ public static RepositorySettings Get(string gitCommonDir)
9292 }
9393 catch
9494 {
95- setting = new RepositorySettings ( ) ;
95+ setting = new ( ) ;
9696 }
9797 }
9898
99+ // Serialize setting again to make sure there are no unnecessary whitespaces.
100+ Task . Run ( ( ) =>
101+ {
102+ var formatted = JsonSerializer . Serialize ( setting , JsonCodeGen . Default . RepositorySettings ) ;
103+ setting . _orgHash = HashContent ( formatted ) ;
104+ } ) ;
105+
99106 setting . _file = fullpath ;
100- setting . _orgHash = HashContent ( JsonSerializer . Serialize ( setting , JsonCodeGen . Default . RepositorySettings ) ) ;
101107 _cache . Add ( fullpath , setting ) ;
102108 return setting ;
103109 }
@@ -106,8 +112,8 @@ public async Task SaveAsync()
106112 {
107113 try
108114 {
109- string content = JsonSerializer . Serialize ( this , JsonCodeGen . Default . RepositorySettings ) ;
110- string hash = HashContent ( content ) ;
115+ var content = JsonSerializer . Serialize ( this , JsonCodeGen . Default . RepositorySettings ) ;
116+ var hash = HashContent ( content ) ;
111117 if ( ! hash . Equals ( _orgHash , StringComparison . Ordinal ) )
112118 {
113119 await File . WriteAllTextAsync ( _file , content ) ;
You can’t perform that action at this time.
0 commit comments