Skip to content

Commit 0eab2fb

Browse files
Copilotpremun
andcommitted
Make EnsureSourceMappingExistsAsync private and call it from InitializeRepository
Co-authored-by: premun <[email protected]>
1 parent c1ba0ee commit 0eab2fb

File tree

3 files changed

+4
-22
lines changed

3 files changed

+4
-22
lines changed

src/Microsoft.DotNet.Darc/Darc/Operations/VirtualMonoRepo/AddRepoOperation.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@ protected override async Task ExecuteInternalAsync(
4444
}
4545

4646
var sourceMappingsPath = _vmrInfo.VmrPath / VmrInfo.DefaultRelativeSourceMappingsPath;
47-
48-
// Ensure source mapping exists (will add if not present and stage the file)
49-
await _vmrInitializer.EnsureSourceMappingExistsAsync(
50-
repoName,
51-
defaultRemote: null, // Will default to https://github.com/dotnet/{repoName}
52-
sourceMappingsPath,
53-
cancellationToken);
5447

5548
await _vmrInitializer.InitializeRepository(
5649
repoName,

src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/IVmrInitializer.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,6 @@ namespace Microsoft.DotNet.DarcLib.VirtualMonoRepo;
1111

1212
public interface IVmrInitializer
1313
{
14-
/// <summary>
15-
/// Adds a new source mapping to the source-mappings.json file if it doesn't already exist.
16-
/// </summary>
17-
/// <param name="repoName">Name of the repository</param>
18-
/// <param name="defaultRemote">Default remote URL for the repository</param>
19-
/// <param name="sourceMappingsPath">Path to the source-mappings.json file</param>
20-
/// <param name="cancellationToken">Cancellation token</param>
21-
/// <returns>True if a new mapping was added, false if it already existed</returns>
22-
Task<bool> EnsureSourceMappingExistsAsync(
23-
string repoName,
24-
string? defaultRemote,
25-
LocalPath sourceMappingsPath,
26-
CancellationToken cancellationToken);
27-
2814
/// <summary>
2915
/// Initializes new repo that hasn't been synchronized into the VMR yet.
3016
/// </summary>

src/Microsoft.DotNet.Darc/DarcLib/VirtualMonoRepo/VmrInitializer.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public VmrInitializer(
8484
_sourceManifest = sourceManifest;
8585
}
8686

87-
public async Task<bool> EnsureSourceMappingExistsAsync(
87+
private async Task<bool> EnsureSourceMappingExistsAsync(
8888
string repoName,
8989
string? defaultRemote,
9090
LocalPath sourceMappingsPath,
@@ -147,6 +147,9 @@ public async Task InitializeRepository(
147147
CodeFlowParameters codeFlowParameters,
148148
CancellationToken cancellationToken)
149149
{
150+
// Ensure source mapping exists before initializing
151+
await EnsureSourceMappingExistsAsync(mappingName, defaultRemote: null, sourceMappingsPath, cancellationToken);
152+
150153
await _dependencyTracker.RefreshMetadataAsync(sourceMappingsPath);
151154
var mapping = _dependencyTracker.GetMapping(mappingName);
152155

0 commit comments

Comments
 (0)