@@ -23,6 +23,7 @@ internal class VmrDiffOperation(
23
23
IVersionDetailsParser versionDetailsParser ,
24
24
IVmrPatchHandler patchHandler ,
25
25
IRemoteFactory remoteFactory ,
26
+ ISourceMappingParser sourceMappingParser ,
26
27
ILocalGitRepoFactory localGitRepoFactory ) : Operation
27
28
{
28
29
private const string GitDirectory = ".git" ;
@@ -43,8 +44,9 @@ public override async Task<int> ExecuteAsync()
43
44
( NativePath tmpProductRepo , NativePath tmpVmrProductRepo , string mapping ) = repo1 . IsVmr ?
44
45
await PrepareReposAsync ( repo2 , repo1 , tmpPath ) :
45
46
await PrepareReposAsync ( repo1 , repo2 , tmpPath ) ;
46
-
47
- await AddRemoteAndGenerateDiffAsync ( tmpProductRepo , tmpVmrProductRepo , repo2 . Ref , await GetDiffFilters ( mapping ) ) ;
47
+
48
+ IReadOnlyCollection < string > exclusionFilters = await GetDiffFilters ( tmpVmrProductRepo / ".." / ".." , repo1 . IsVmr ? repo1 . Ref : repo2 . Ref , mapping ) ;
49
+ await AddRemoteAndGenerateDiffAsync ( tmpProductRepo , tmpVmrProductRepo , repo2 . Ref , exclusionFilters ) ;
48
50
}
49
51
finally
50
52
{
@@ -143,11 +145,15 @@ await processManager.ExecuteGit(tmpProductRepo, [
143
145
return ( repo1 , repo2 ) ;
144
146
}
145
147
146
- private async Task < IReadOnlyCollection < string > > GetDiffFilters ( string mapping )
148
+ private async Task < IReadOnlyCollection < string > > GetDiffFilters ( NativePath vmrPath , string commit , string mapping )
147
149
{
148
- var remote = await remoteFactory . CreateRemoteAsync ( DarcLib . Constants . DefaultVmrUri ) ;
149
- return ( await remote . GetSourceMappingsAsync ( DarcLib . Constants . DefaultVmrUri , "main" ) )
150
- . First ( m => m . Name == mapping ) . Exclude ;
150
+ var vmr = localGitRepoFactory . Create ( vmrPath ) ;
151
+ var sourceMappings = await vmr . GetFileFromGitAsync ( VmrInfo . DefaultRelativeSourceMappingsPath , commit )
152
+ ?? throw new FileNotFoundException ( $ "Failed to find { VmrInfo . DefaultRelativeSourceMappingsPath } in { vmrPath } at { commit } ") ;
153
+
154
+ return sourceMappingParser . ParseMappingsFromJson ( sourceMappings )
155
+ . First ( m => m . Name == mapping )
156
+ . Exclude ;
151
157
}
152
158
153
159
/// <summary>
@@ -304,7 +310,8 @@ await processManager.ExecuteGit(repoPath, [
304
310
$ "--initial-branch={ branch } "
305
311
] ) ;
306
312
await processManager . ExecuteGit ( repoPath , [
307
- "add" , "--all"
313
+ // We need --force because some repos have files in them which are .gitignore-ed so if you'd copy their contents, some of the files would not be re-added
314
+ "add" , "--all" , "--force"
308
315
] ) ;
309
316
await processManager . ExecuteGit ( repoPath , [
310
317
"commit" ,
0 commit comments