From ce11b180d52c437e7364331fcea0b3694a9f5e6b Mon Sep 17 00:00:00 2001 From: "Martin Hinshelwood nkdAgility.com" Date: Mon, 5 Feb 2024 17:07:13 +0000 Subject: [PATCH] [Preview] Truncate LongText fields to 1m (#1903) This should truncate longTest fields to the max length and resolve #1861 --- .../MigrationContext/WorkItemMigrationContext.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/VstsSyncMigrator.Core/Execution/MigrationContext/WorkItemMigrationContext.cs b/src/VstsSyncMigrator.Core/Execution/MigrationContext/WorkItemMigrationContext.cs index ea0d56a64..2fa8d3441 100644 --- a/src/VstsSyncMigrator.Core/Execution/MigrationContext/WorkItemMigrationContext.cs +++ b/src/VstsSyncMigrator.Core/Execution/MigrationContext/WorkItemMigrationContext.cs @@ -14,6 +14,7 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.TeamFoundation.Common; +using Microsoft.TeamFoundation.TestManagement; using Microsoft.TeamFoundation.WorkItemTracking.Client; using Microsoft.TeamFoundation.WorkItemTracking.Proxy; using Microsoft.TeamFoundation.WorkItemTracking.WebApi; @@ -511,10 +512,14 @@ private void PopulateWorkItem(WorkItemData oldWi, WorkItemData newwit, string de Log.LogDebug("PopulateWorkItem:FieldUpdate: {ReferenceName} | Source:{OldReferenceValue} Target:{NewReferenceValue}", f.ReferenceName, oldWorkItem.Fields[f.ReferenceName].Value, newWorkItem.Fields[f.ReferenceName].Value); newWorkItem.Fields[f.ReferenceName].Value = oldWorkItem.Fields[f.ReferenceName].Value; - } else - { - } + if (newWorkItem.Fields[f.ReferenceName].FieldDefinition.IsLongText) + { + // Truncate field to max length + newWorkItem.Fields[f.ReferenceName].Value = newWorkItem.Fields[f.ReferenceName].Value.ToString().Substring(0, 1000000); + } + + } } if (_nodeStructureEnricher.Options.Enabled)