From 105cdcd8fcf0a4e3128f6f6b099fb928b9c7274a Mon Sep 17 00:00:00 2001 From: Alexander Hjelm Date: Tue, 5 Dec 2023 17:04:21 +0100 Subject: [PATCH] Add support for the new Parent field --- .../RevisionUtils/LinkMapperUtils.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/WorkItemMigrator/JiraExport/RevisionUtils/LinkMapperUtils.cs b/src/WorkItemMigrator/JiraExport/RevisionUtils/LinkMapperUtils.cs index 7f743d34..59c93509 100644 --- a/src/WorkItemMigrator/JiraExport/RevisionUtils/LinkMapperUtils.cs +++ b/src/WorkItemMigrator/JiraExport/RevisionUtils/LinkMapperUtils.cs @@ -55,6 +55,8 @@ public static void AddRemoveSingleLink(JiraRevision r, List links, strin if (r.Fields.TryGetValue(field, out object value)) { + value = NumericCheckOnLinkTypeField(r, field, value); + var changeType = value == null ? ReferenceChangeType.Removed : ReferenceChangeType.Added; var linkType = (from t in config.LinkMap.Links where t.Source == type select t.Target).FirstOrDefault(); @@ -62,6 +64,11 @@ public static void AddRemoveSingleLink(JiraRevision r, List links, strin if (r.Index != 0) { var prevLinkValue = r.ParentItem.Revisions[r.Index - 1].GetFieldValue(field); + var prevLinkValueUnchecked = NumericCheckOnLinkTypeField(r, field, prevLinkValue); + if(prevLinkValueUnchecked != null) + { + prevLinkValue = prevLinkValueUnchecked.ToString(); + } // if previous value is not null, add removal of previous link if (!string.IsNullOrWhiteSpace(prevLinkValue)) { @@ -94,6 +101,24 @@ public static void AddRemoveSingleLink(JiraRevision r, List links, strin } } + private static object NumericCheckOnLinkTypeField(JiraRevision r, string field, object value) + { + // 2023-12-05: For later versions pf Jira cloud, the parent link/epic link fields have been replaced by a single + // field named "Parent". This is represented by the ParentItem field and r.field["parent"] instead holds the numeric ID. + // Here we ensure that what we get is the issue key + + if (value != null) + { + bool isNumeric = int.TryParse(value.ToString(), out int n); + if (isNumeric && field == "parent" && r.ParentItem != null && r.ParentItem.Parent != null) + { + value = r.ParentItem.Parent; + } + } + + return value; + } + public static void AddSingleLink(JiraRevision r, List links, string field, string type, ConfigJson config) { if (String.IsNullOrWhiteSpace(field))