Skip to content

Commit 2107bb5

Browse files
authored
Bug in Chaneset Mapping (#2546)
Fix #2521 reported by @nirkal \n\n ✨ (ServiceCollectionExtensions.cs, TfsGitRepositoryTool.cs): add TfsChangeSetMappingTool to service collection and ensure required service retrieval Add `TfsChangeSetMappingTool` to the service collection to enable its configuration and usage within the application. Change the retrieval method of `TfsChangeSetMappingTool` from `GetService` to `GetRequiredService` to ensure that the service is available and to prevent potential null reference exceptions. This change enhances the robustness and configurability of the application by ensuring necessary services are properly registered and retrieved.
2 parents 0af6562 + e4e5865 commit 2107bb5

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/MigrationTools.Clients.TfsObjectModel/ServiceCollectionExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public static void AddMigrationToolServicesForClientTfs_Tools(this IServiceColle
3030
context.AddSingleton<TfsNodeStructureTool>().AddMigrationToolsOptions<TfsNodeStructureToolOptions, TfsNodeStructureToolOptionsValidator>(configuration);
3131
context.AddSingleton<TfsRevisionManagerTool>().AddMigrationToolsOptions<TfsRevisionManagerToolOptions>(configuration);
3232
context.AddSingleton<TfsTeamSettingsTool>().AddMigrationToolsOptions<TfsTeamSettingsToolOptions>(configuration);
33+
context.AddSingleton< TfsChangeSetMappingTool>().AddMigrationToolsOptions<TfsChangeSetMappingToolOptions>(configuration);
3334
}
3435

3536
public static void AddMigrationToolServicesForClientTfs_Processors(this IServiceCollection context)
@@ -93,4 +94,4 @@ public static void AddMigrationToolServicesForClientLegacyAzureDevOpsObjectModel
9394
context.AddTransient<IWorkItemQuery, TfsWorkItemQuery>();
9495
}
9596
}
96-
}
97+
}

src/MigrationTools.Clients.TfsObjectModel/Tools/TfsGitRepositoryTool.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public int Enrich(TfsProcessor processor, WorkItemData sourceWorkItem, WorkItem
8484
}
8585

8686
Log.LogInformation("GitRepositoryEnricher: Enriching {Id} To fix Git Repo Links", targetWorkItem.Id);
87-
var changeSetMappings = Services.GetService<TfsChangeSetMappingTool>();
87+
var changeSetMappings = Services.GetRequiredService<TfsChangeSetMappingTool>();
8888
List<ExternalLink> newEL = new List<ExternalLink>();
8989
List<ExternalLink> removeEL = new List<ExternalLink>();
9090
int count = 0;

0 commit comments

Comments
 (0)