Skip to content

Commit a288634

Browse files
committed
PR 52: Added Area Path switch and fixed bug #4905 +semver:major
- Added ability to use the area path prefix (Much easier than regex) and fixed Related work items: #4905, #4893
1 parent e06fec6 commit a288634

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

TfsWitMigrator.Core/Configuration/EngineConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public static EngineConfiguration GetDefault()
8888
{ "Product Backlog Item", "Product Backlog Item" }
8989
};
9090
ec.Processors = new List<ITfsProcessingConfig>();
91-
ec.Processors.Add(new WorkItemMigrationConfig() { Enabled = false, UpdateCreatedBy=true, UpdateCreatedDate=true, UpdateSoureReflectedId=true, QueryBit = @"AND [TfsMigrationTool.ReflectedWorkItemId] = '' AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] IN ('Shared Steps', 'Shared Parameter', 'Test Case', 'Requirement', 'Task', 'User Story', 'Bug')" });
91+
ec.Processors.Add(new WorkItemMigrationConfig() { Enabled = false, UpdateCreatedBy=true, PrefixProjectToNodes = true, UpdateCreatedDate=true, UpdateSoureReflectedId=true, QueryBit = @"AND [TfsMigrationTool.ReflectedWorkItemId] = '' AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] IN ('Shared Steps', 'Shared Parameter', 'Test Case', 'Requirement', 'Task', 'User Story', 'Bug')" });
9292
ec.Processors.Add(new WorkItemUpdateConfig() { Enabled = false, QueryBit = @"AND [TfsMigrationTool.ReflectedWorkItemId] = '' AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] IN ('Shared Steps', 'Shared Parameter', 'Test Case', 'Requirement', 'Task', 'User Story', 'Bug')" });
9393
ec.Processors.Add(new NodeStructuresMigrationConfig() { Enabled = false });
9494
ec.Processors.Add(new LinkMigrationConfig() { Enabled = false, QueryBit= @"AND [System.ExternalLinkCount] > 0 AND [System.RelatedLinkCount] > 0" });

TfsWitMigrator.Core/Configuration/Processing/WorkItemMigrationConfig.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace VSTS.DataBulkEditor.Engine.Configuration.Processing
99
public class WorkItemMigrationConfig : ITfsProcessingConfig
1010
{
1111
public bool Enabled { get; set; }
12+
public bool PrefixProjectToNodes { get; set; }
1213
public bool UpdateCreatedDate { get; set; }
1314
public bool UpdateCreatedBy { get; set; }
1415
public bool UpdateSoureReflectedId { get; set; }

TfsWitMigrator.Core/Execution/MigrationContext/LinkMigrationContext.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ where l is RelatedLink
215215
private WorkItem GetRightHandSideTargitWi(WorkItem wiSourceL, WorkItem wiSourceR, WorkItem wiTargetL, WorkItemStoreContext targetStore)
216216
{
217217
WorkItem wiTargetR;
218-
if (!(wiTargetL == null) && wiSourceR.Project.Name == wiTargetL.Project.Name)
218+
if (!(wiTargetL == null)
219+
&& wiSourceR.Project.Name == wiTargetL.Project.Name
220+
&& wiSourceR.Project.Store.TeamProjectCollection.Uri.ToString() == wiTargetL.Project.Store.TeamProjectCollection.Uri.ToString())
219221
{
220222
// Moving to same team project as SourceR
221223
wiTargetR = wiSourceR;

TfsWitMigrator.Core/Execution/MigrationContext/WorkItemMigrationContext.cs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ internal override void InternalExecute()
6363
// Deside on WIT
6464
if (me.WorkItemTypeDefinitions.ContainsKey(sourceWI.Type.Name))
6565
{
66-
newwit = CreateAndPopulateWorkItem(sourceWI, destProject, me.WorkItemTypeDefinitions[sourceWI.Type.Name].Map(sourceWI));
66+
newwit = CreateAndPopulateWorkItem(_config,sourceWI, destProject, me.WorkItemTypeDefinitions[sourceWI.Type.Name].Map(sourceWI));
6767
if (newwit.Fields.Contains(me.ReflectedWorkItemIdFieldName))
6868
{
6969
newwit.Fields[me.ReflectedWorkItemIdFieldName].Value = sourceStore.CreateReflectedWorkItemId(sourceWI);
@@ -135,7 +135,7 @@ private static bool HasChildPBI(WorkItem sourceWI)
135135
return sourceWI.Title.ToLower().StartsWith("epic") || sourceWI.Title.ToLower().StartsWith("theme");
136136
}
137137

138-
private static WorkItem CreateAndPopulateWorkItem(WorkItem oldWi, Project destProject, String destType)
138+
private static WorkItem CreateAndPopulateWorkItem(WorkItemMigrationConfig config , WorkItem oldWi, Project destProject, String destType)
139139
{
140140
var fieldMappingStartTime = DateTime.UtcNow;
141141
Stopwatch fieldMappingTimer = new Stopwatch();
@@ -198,8 +198,17 @@ private static WorkItem CreateAndPopulateWorkItem(WorkItem oldWi, Project destPr
198198
newwit.Fields[f.ReferenceName].Value = oldWi.Fields[f.ReferenceName].Value;
199199
}
200200
}
201-
newwit.AreaPath = string.Format(@"{0}\{1}", newwit.Project.Name, oldWi.AreaPath);
202-
newwit.IterationPath = string.Format(@"{0}\{1}", newwit.Project.Name, oldWi.IterationPath);
201+
if (config.PrefixProjectToNodes)
202+
{
203+
newwit.AreaPath = string.Format(@"{0}\{1}", newwit.Project.Name, oldWi.AreaPath);
204+
newwit.IterationPath = string.Format(@"{0}\{1}", newwit.Project.Name, oldWi.IterationPath);
205+
} else
206+
{
207+
var regex = new Regex(Regex.Escape(oldWi.Project.Name));
208+
newwit.AreaPath = regex.Replace(oldWi.AreaPath, "newwit.Project.Name", 1);
209+
newwit.IterationPath = regex.Replace(oldWi.IterationPath, "newwit.Project.Name", 1);
210+
}
211+
203212
newwit.Fields["System.ChangedDate"].Value = oldWi.Fields["System.ChangedDate"].Value;
204213

205214
switch (destType)

0 commit comments

Comments
 (0)