Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHinsh committed Mar 19, 2024
2 parents 11f8bd2 + 58954f1 commit adc54fa
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 7 deletions.
5 changes: 4 additions & 1 deletion configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@
"CommonEnrichersConfig": [
{
"$type": "TfsNodeStructureOptions",
"Enabled": false,
"NodeBasePaths": [],
"AreaMaps": {
"^migrationSource1([\\\\]?.*)$": "MigrationTest5$1",
"^nkdProducts([\\\\]?.*)$": "MigrationTest5$1",
"^Skypoint Cloud$": "MigrationTest5"
},
"IterationMaps": {
"^migrationSource1([\\\\]?.*)$": "MigrationTest5$1",
"^nkdProducts([\\\\]?.*)$": "MigrationTest5$1",
"^Skypoint Cloud\\\\Sprint 1$": "MigrationTest5\\Sprint 1"
},
Expand Down Expand Up @@ -120,7 +123,7 @@
"Version": "15.0",
"workaroundForQuerySOAPBugEnabled": false,
"WorkItemTypeDefinition": {
"sourceWorkItemTypeName": "targetWorkItemTypeName"
"User Story": "Product Backlog Item"
},
"Endpoints": {
"InMemoryWorkItemEndpoints": [
Expand Down
25 changes: 25 additions & 0 deletions src/MigrationTools/ConfigException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Runtime.Serialization;

namespace MigrationTools
{
[Serializable]
internal class ConfigException : Exception
{
public ConfigException()
{
}

public ConfigException(string message) : base(message)
{
}

public ConfigException(string message, Exception innerException) : base(message, innerException)
{
}

protected ConfigException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Runtime.Serialization;

namespace VstsSyncMigrator.Engine
{
[Serializable]
internal class ConfigException : Exception
{
public ConfigException()
{
}

public ConfigException(string message) : base(message)
{
}

public ConfigException(string message, Exception innerException) : base(message, innerException)
{
}

protected ConfigException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,14 @@ protected override void InternalExecute()
embededImagesEnricher = Services.GetRequiredService<TfsEmbededImagesEnricher>();
gitRepositoryEnricher = Services.GetRequiredService<TfsGitRepositoryEnricher>();


_nodeStructureEnricher.ProcessorExecutionBegin(null);
if (_nodeStructureEnricher.Options.Enabled)
{
_nodeStructureEnricher.ProcessorExecutionBegin(null);
} else
{
Log.LogWarning("WorkItemMigrationContext::InternalExecute: nodeStructureEnricher is disabled! This may cause work item migration errors! ");
}


var stopwatch = Stopwatch.StartNew();
_itemsInError = new List<string>();
Expand Down Expand Up @@ -284,11 +290,21 @@ private void ValidateAllUsersExistOrAreMapped(List<WorkItemData> sourceWorkItems
private void ValidateAllNodesExistOrAreMapped(List<WorkItemData> sourceWorkItems)
{
contextLog.Information("Validating::Check that all Area & Iteration paths from Source have a valid mapping on Target");
List<NodeStructureItem> nodeStructureMissingItems = _nodeStructureEnricher.GetMissingRevisionNodes(sourceWorkItems);
if (_nodeStructureEnricher.ValidateTargetNodesExist(nodeStructureMissingItems))
if (!_nodeStructureEnricher.Options.Enabled && Engine.Target.Config.AsTeamProjectConfig().Project != Engine.Source.Config.AsTeamProjectConfig().Project)
{
throw new Exception("Missing Iterations in Target preventing progress, check log for list. To continue you MUST configure IterationMaps or AreaMaps that matches the missing paths..");
throw new ConfigException("Source and Target projects have different names, but NodeStructureEnricher is not enabled. Cant continue... please enable nodeStructureEnricher in the config and restart.");
}
if ( _nodeStructureEnricher.Options.Enabled)
{
List<NodeStructureItem> nodeStructureMissingItems = _nodeStructureEnricher.GetMissingRevisionNodes(sourceWorkItems);
if (_nodeStructureEnricher.ValidateTargetNodesExist(nodeStructureMissingItems))
{
throw new Exception("Missing Iterations in Target preventing progress, check log for list. To continue you MUST configure IterationMaps or AreaMaps that matches the missing paths..");
}
} else
{
contextLog.Error("nodeStructureEnricher is disabled! Please enable it in the config.");
}
}

private void ValidateAllWorkItemTypesHaveReflectedWorkItemIdField(List<WorkItemData> sourceWorkItems)
Expand Down Expand Up @@ -477,9 +493,14 @@ private void PopulateWorkItem(WorkItemData oldWorkItemData, WorkItemData newWork

if (_nodeStructureEnricher.Options.Enabled)
{

newWorkItem.AreaPath = _nodeStructureEnricher.GetNewNodeName(oldWorkItem.AreaPath, TfsNodeStructureType.Area);
newWorkItem.IterationPath = _nodeStructureEnricher.GetNewNodeName(oldWorkItem.IterationPath, TfsNodeStructureType.Iteration);
}
else
{
Log.LogWarning("WorkItemMigrationContext::PopulateWorkItem::nodeStructureEnricher::Disabled! This needs to be set to true!");
}

switch (destType)
{
Expand Down Expand Up @@ -544,7 +565,7 @@ private async Task ProcessWorkItemAsync(WorkItemData sourceWorkItem, int retryLi
{ "sourceWorkItemRev", sourceWorkItem.Rev },
{ "ReplayRevisions", _revisionManager.Options.ReplayRevisions }}
);
List<RevisionItem> revisionsToMigrate = _revisionManager.GetRevisionsToMigrate(sourceWorkItem.Revisions.Values.ToList(), targetWorkItem.Revisions.Values.ToList());
List<RevisionItem> revisionsToMigrate = _revisionManager.GetRevisionsToMigrate(sourceWorkItem.Revisions.Values.ToList(), targetWorkItem?.Revisions.Values.ToList());
if (targetWorkItem == null)
{
targetWorkItem = ReplayRevisions(revisionsToMigrate, sourceWorkItem, null);
Expand Down

0 comments on commit adc54fa

Please sign in to comment.