Skip to content

Commit

Permalink
Bug in Chaneset Mapping (#2546)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MrHinsh authored Dec 3, 2024
2 parents 0af6562 + e4e5865 commit 2107bb5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static void AddMigrationToolServicesForClientTfs_Tools(this IServiceColle
context.AddSingleton<TfsNodeStructureTool>().AddMigrationToolsOptions<TfsNodeStructureToolOptions, TfsNodeStructureToolOptionsValidator>(configuration);
context.AddSingleton<TfsRevisionManagerTool>().AddMigrationToolsOptions<TfsRevisionManagerToolOptions>(configuration);
context.AddSingleton<TfsTeamSettingsTool>().AddMigrationToolsOptions<TfsTeamSettingsToolOptions>(configuration);
context.AddSingleton< TfsChangeSetMappingTool>().AddMigrationToolsOptions<TfsChangeSetMappingToolOptions>(configuration);
}

public static void AddMigrationToolServicesForClientTfs_Processors(this IServiceCollection context)
Expand Down Expand Up @@ -93,4 +94,4 @@ public static void AddMigrationToolServicesForClientLegacyAzureDevOpsObjectModel
context.AddTransient<IWorkItemQuery, TfsWorkItemQuery>();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public int Enrich(TfsProcessor processor, WorkItemData sourceWorkItem, WorkItem
}

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

0 comments on commit 2107bb5

Please sign in to comment.