Skip to content

Commit

Permalink
Defer link import if the revision has any fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-Hjelm authored Dec 20, 2024
1 parent e240a6c commit 3823561
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/WorkItemMigrator/WorkItemImport/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,14 @@ private bool ApplyAndSaveLinks(WiRevision rev, WorkItem wi, Settings settings)
{
bool success = true;

var saveLinkTimestamp = rev.Time;
if(rev.Fields.Count > 0)
{
// If this revision already has any fields, defer the link import by 2 miliseconds. Otherwise the Work Items API will
// send the response: "VS402625: Dates must be increasing with each revision"
saveLinkTimestamp = saveLinkTimestamp.AddMilliseconds(2);
}

foreach (var link in rev.Links)
{
try
Expand All @@ -676,11 +684,11 @@ private bool ApplyAndSaveLinks(WiRevision rev, WorkItem wi, Settings settings)
continue;
}

if (link.Change == ReferenceChangeType.Added && !_witClientUtils.AddAndSaveLink(link, wi, settings, rev.Author, rev.Time))
if (link.Change == ReferenceChangeType.Added && !_witClientUtils.AddAndSaveLink(link, wi, settings, rev.Author, saveLinkTimestamp))
{
success = false;
}
else if (link.Change == ReferenceChangeType.Removed && !_witClientUtils.RemoveAndSaveLink(link, wi, settings, rev.Author, rev.Time))
else if (link.Change == ReferenceChangeType.Removed && !_witClientUtils.RemoveAndSaveLink(link, wi, settings, rev.Author, saveLinkTimestamp))
{
success = false;
}
Expand All @@ -704,4 +712,4 @@ private bool ApplyAndSaveLinks(WiRevision rev, WorkItem wi, Settings settings)
}
#endregion
}
}
}

0 comments on commit 3823561

Please sign in to comment.