@@ -280,18 +280,32 @@ private ITask<NPath[]> CalculateFileDiff(ChangesTreeNode node)
280
280
var tmpDir = Manager . Environment . UnityProjectPath . Combine ( "Temp" , "ghu-diffs" ) . EnsureDirectoryExists ( ) ;
281
281
var leftFile = tmpDir . Combine ( rightFile . FileName + "_" + Repository . CurrentHead + rightFile . ExtensionWithDot ) ;
282
282
return new SimpleProcessTask ( TaskManager . Token , "show HEAD:\" " + rightFile . ToString ( SlashMode . Forward ) + "\" " )
283
- . Configure ( Manager . ProcessManager , false )
284
- . Catch ( _ => true )
285
- . Then ( ( success , txt ) =>
286
- {
287
- if ( success )
288
- leftFile . WriteAllText ( txt ) ;
289
- else
290
- leftFile = NPath . Default ;
291
- if ( ! rightFile . FileExists ( ) )
292
- rightFile = NPath . Default ;
293
- return new NPath [ ] { leftFile , rightFile } ;
294
- } ) ;
283
+ . Configure ( Manager . ProcessManager , false )
284
+ . Catch ( _ => true )
285
+ . Then ( ( success , txt ) =>
286
+ {
287
+ // both files exist, just compare them
288
+ if ( success && rightFile . FileExists ( ) )
289
+ {
290
+ leftFile . WriteAllText ( txt ) ;
291
+ return new NPath [ ] { leftFile , rightFile } ;
292
+ }
293
+
294
+ var leftFolder = tmpDir . Combine ( "left" , leftFile . FileName ) . EnsureDirectoryExists ( ) ;
295
+ var rightFolder = tmpDir . Combine ( "right" , leftFile . FileName ) . EnsureDirectoryExists ( ) ;
296
+ // file was deleted
297
+ if ( ! rightFile . FileExists ( ) )
298
+ {
299
+ leftFolder . Combine ( rightFile ) . WriteAllText ( txt ) ;
300
+ }
301
+
302
+ // file was created
303
+ if ( ! success )
304
+ {
305
+ rightFolder . Combine ( rightFile ) . WriteAllText ( rightFile . ReadAllText ( ) ) ;
306
+ }
307
+ return new NPath [ ] { leftFolder , rightFolder } ;
308
+ } ) ;
295
309
}
296
310
297
311
private void RepositoryOnStatusEntriesChanged ( CacheUpdateEvent cacheUpdateEvent )
0 commit comments