@@ -46,7 +46,7 @@ await PrepareReposAsync(repo2, repo1, tmpPath) :
46
46
await PrepareReposAsync ( repo1 , repo2 , tmpPath ) ;
47
47
48
48
IReadOnlyCollection < string > exclusionFilters = await GetDiffFilters ( tmpVmrProductRepo / ".." / ".." , repo1 . IsVmr ? repo1 . Ref : repo2 . Ref , mapping ) ;
49
- await AddRemoteAndGenerateDiffAsync ( tmpProductRepo , tmpVmrProductRepo , repo2 . Ref , exclusionFilters ) ;
49
+ await GenerateDiff ( tmpProductRepo , tmpVmrProductRepo , repo2 . Ref , exclusionFilters ) ;
50
50
}
51
51
finally
52
52
{
@@ -242,7 +242,7 @@ private async Task VerifyInput(Repo repo1, Repo repo2)
242
242
private async Task < bool > IsRepoVmrAsync ( string uri , string branch )
243
243
=> await gitRepoFactory . CreateClient ( uri ) . IsRepoVmrAsync ( uri , branch ) ;
244
244
245
- private async Task AddRemoteAndGenerateDiffAsync ( string repo1 , string repo2 , string repo2Branch , IReadOnlyCollection < string > filters )
245
+ private async Task GenerateDiff ( string repo1 , string repo2 , string repo2Branch , IReadOnlyCollection < string > filters )
246
246
{
247
247
string remoteName = Guid . NewGuid ( ) . ToString ( ) ;
248
248
@@ -285,10 +285,52 @@ await processManager.ExecuteGit(repo1, [
285
285
includeAdditionalMappings : false ,
286
286
CancellationToken . None ) ;
287
287
288
- // If tmpDirectory is not null, it means the output path was not provided, so we just want to
289
- // print out the whole diff
290
- if ( ! string . IsNullOrEmpty ( tmpDirectory ) )
288
+ try
289
+ {
290
+ await OutputDiff ( patches ) ;
291
+ }
292
+ finally
293
+ {
294
+ if ( ! string . IsNullOrEmpty ( tmpDirectory ) )
295
+ {
296
+ fileSystem . DeleteDirectory ( tmpDirectory , true ) ;
297
+ }
298
+ }
299
+ }
300
+
301
+ private async Task OutputDiff ( List < VmrIngestionPatch > patches )
302
+ {
303
+ if ( options . NameOnly )
304
+ {
305
+ var files = new List < UnixPath > ( ) ;
306
+
307
+ // For name-only mode, we'll print the filenames directly from the git patch summary lines
308
+ foreach ( var patch in patches )
309
+ {
310
+ files . AddRange ( await patchHandler . GetPatchedFiles ( patch . Path , CancellationToken . None ) ) ;
311
+ }
312
+
313
+ var list = files
314
+ . Select ( f => f . Path )
315
+ . OrderBy ( f => f ) ;
316
+
317
+ // If the output path was provided, the list will be stored there
318
+ // Otherwise we want to print it
319
+ if ( string . IsNullOrEmpty ( options . OutputPath ) )
320
+ {
321
+ foreach ( var file in list )
322
+ {
323
+ Console . WriteLine ( file ) ;
324
+ }
325
+ }
326
+ else
327
+ {
328
+ await File . WriteAllLinesAsync ( options . OutputPath , list ) ;
329
+ }
330
+ }
331
+ else
291
332
{
333
+ // For regular diff mode, we print the full diff content
292
334
foreach ( var patch in patches )
293
335
{
294
336
using FileStream fs = new ( patch . Path , FileMode . Open , FileAccess . Read ) ;
@@ -299,7 +341,6 @@ await processManager.ExecuteGit(repo1, [
299
341
Console . WriteLine ( line ) ;
300
342
}
301
343
}
302
- fileSystem . DeleteDirectory ( tmpDirectory , true ) ;
303
344
}
304
345
}
305
346
0 commit comments