From e5c8ba19189afb50be824b1869a246ad7afb9788 Mon Sep 17 00:00:00 2001 From: Alexander Hjelm Date: Fri, 6 Oct 2023 12:04:13 +0200 Subject: [PATCH] ignore-empty-revisions flag --- docs/Samples/config-agile.json | 1 + docs/Samples/config-basic.json | 1 + docs/Samples/config-cmmi.json | 1 + docs/Samples/config-scrum.json | 1 + docs/config.md | 1 + .../Migration.Common/Config/ConfigJson.cs | 4 ++++ .../WorkItemImport/ImportCommandLine.cs | 11 +++++++++++ 7 files changed, 20 insertions(+) diff --git a/docs/Samples/config-agile.json b/docs/Samples/config-agile.json index f7d74f5d..bef9dee4 100644 --- a/docs/Samples/config-agile.json +++ b/docs/Samples/config-agile.json @@ -16,6 +16,7 @@ "ignore-failed-links": true, "include-link-comments": false, "include-jira-css-styles": false, + "ignore-empty-revisions": false, "sleep-time-between-revision-import-milliseconds": 0, "process-template": "Agile", "link-map": { diff --git a/docs/Samples/config-basic.json b/docs/Samples/config-basic.json index 94c5f1af..64732c20 100644 --- a/docs/Samples/config-basic.json +++ b/docs/Samples/config-basic.json @@ -16,6 +16,7 @@ "ignore-failed-links": true, "include-link-comments": false, "include-jira-css-styles": false, + "ignore-empty-revisions": false, "sleep-time-between-revision-import-milliseconds": 0, "process-template": "Basic", "link-map": { diff --git a/docs/Samples/config-cmmi.json b/docs/Samples/config-cmmi.json index f9d75b88..43a8ce33 100644 --- a/docs/Samples/config-cmmi.json +++ b/docs/Samples/config-cmmi.json @@ -16,6 +16,7 @@ "ignore-failed-links": true, "include-link-comments": false, "include-jira-css-styles": false, + "ignore-empty-revisions": false, "sleep-time-between-revision-import-milliseconds": 0, "process-template": "CMMI", "link-map": { diff --git a/docs/Samples/config-scrum.json b/docs/Samples/config-scrum.json index 4e543727..035481ac 100644 --- a/docs/Samples/config-scrum.json +++ b/docs/Samples/config-scrum.json @@ -16,6 +16,7 @@ "ignore-failed-links": true, "include-link-comments": false, "include-jira-css-styles": false, + "ignore-empty-revisions": false, "sleep-time-between-revision-import-milliseconds": 0, "process-template": "Scrum", "link-map": { diff --git a/docs/config.md b/docs/config.md index 3a4fdf83..088c0ffd 100644 --- a/docs/config.md +++ b/docs/config.md @@ -34,6 +34,7 @@ The migration configuration file is defined in a json file with the properties d |**ignore-failed-links**|False|boolean|Set to True if failed links are to be ignored. Default = False.| |**include-link-comments**|False|boolean|Set to True to get a verbose comment on the work item for every work item link created. Default = True.| |**include-jira-css-styles**|True|boolean|Set to True to generate and include confluence CSS Stylesheets for description, repro steps and comments. Default = True.| +|**ignore-empty-revisions**|False|boolean|Set to True to ignore importing empty revisions. Empty revisions will be created if you have historical revisions where none of the changed fields or links have been mapped. This may indicate that you have unmapped data, which will not be migrated. Default = False.| |**sleep-time-between-revision-import-milliseconds**|False|integer|How many milliseconds to sleep between each revision import. Use this if throttling is an issue for ADO Services. Default = 0 (no sleep).| |**process-template**|False|string|Process template in the target DevOps project. Supported values: Scrum, Agile or CMMI. Default = "Scrum".| |**link-map**|True|json|List of **links** to map between Jira and Azure DevOps/TFS work item link types.| diff --git a/src/WorkItemMigrator/Migration.Common/Config/ConfigJson.cs b/src/WorkItemMigrator/Migration.Common/Config/ConfigJson.cs index 8c02f499..7902326b 100644 --- a/src/WorkItemMigrator/Migration.Common/Config/ConfigJson.cs +++ b/src/WorkItemMigrator/Migration.Common/Config/ConfigJson.cs @@ -77,7 +77,11 @@ public class ConfigJson [JsonProperty(PropertyName = "include-commits")] public bool IncludeCommits { get; set; } = false; + [JsonProperty(PropertyName = "include-jira-css-styles")] public bool IncludeJiraCssStyles { get; set; } = true; + + [JsonProperty(PropertyName = "ignore-empty-revisions")] + public bool IgnoreEmptyRevisions { get; set; } = false; } } diff --git a/src/WorkItemMigrator/WorkItemImport/ImportCommandLine.cs b/src/WorkItemMigrator/WorkItemImport/ImportCommandLine.cs index 57ebd6c6..49d81c69 100644 --- a/src/WorkItemMigrator/WorkItemImport/ImportCommandLine.cs +++ b/src/WorkItemMigrator/WorkItemImport/ImportCommandLine.cs @@ -117,7 +117,18 @@ private void ExecuteMigration(CommandOption token, CommandOption url, CommandOpt try { if (!forceFresh && context.Journal.IsItemMigrated(executionItem.OriginId, executionItem.Revision.Index)) + { + continue; + } + + if (config.IgnoreEmptyRevisions && + executionItem.Revision.Fields.Count == 0 && + executionItem.Revision.Links.Count == 0 && + executionItem.Revision.Attachments.Count == 0) + { + Logger.Log(LogLevel.Info, $"Skipped processing empty revision: {executionItem.OriginId}, rev {executionItem.Revision.Index}"); continue; + } WorkItem wi = null;