Skip to content

Commit

Permalink
Merge pull request #811 from solidify/bugfix/fix-for-removed-labels
Browse files Browse the repository at this point in the history
Fix for removed or replaced WIFields
  • Loading branch information
Alexander-Hjelm authored Jul 23, 2023
2 parents a71689a + 868d297 commit ebe3cae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ public static JsonPatchOperation CreateJsonFieldPatchOp(Operation op, string key
throw new ArgumentException(nameof(key));
}

if (value == null)
{
throw new ArgumentException(nameof(value));
}

return new JsonPatchOperation()
{
Operation = op,
Expand Down
15 changes: 12 additions & 3 deletions src/WorkItemMigrator/WorkItemImport/WitClient/WitClientUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,18 @@ public void SaveWorkItemFields(WorkItem wi)

object val = wi.Fields[key];

patchDocument.Add(
JsonPatchDocUtils.CreateJsonFieldPatchOp(Operation.Add, key, val)
);
if (val == null || val.ToString() == "")
{
patchDocument.Add(
JsonPatchDocUtils.CreateJsonFieldPatchOp(Operation.Remove, key, null)
);
}
else
{
patchDocument.Add(
JsonPatchDocUtils.CreateJsonFieldPatchOp(Operation.Replace, key, val)
);
}
}

try
Expand Down

0 comments on commit ebe3cae

Please sign in to comment.