This repository was archived by the owner on Nov 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 199
Support custom ado fields that mark work items as duplicate #3467
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f7d876b
Add field to ado config for checking duplicate work items
kananb 4628b7e
Make duplicate fields nullable and add it to python models
kananb b975c5f
Update broken tests
kananb 67ab515
Update docs to include new ado_duplicate_fields property
kananb b3d604a
Merge branch 'main' into kanan/dup-fields
kananb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -239,7 +239,7 @@ private static async Async.Task ProcessNotification(IOnefuzzContext context, Con | |
|
|
||
| var renderedConfig = RenderAdoTemplate(logTracer, renderer, config, instanceUrl); | ||
| var ado = new AdoConnector(renderedConfig, project!, client, instanceUrl, logTracer, await GetValidFields(client, project)); | ||
| await ado.Process(notificationInfo); | ||
| await ado.Process(notificationInfo, config.AdoDuplicateFields); | ||
| } | ||
|
|
||
| public static RenderedAdoTemplate RenderAdoTemplate(ILogger logTracer, Renderer renderer, AdoTemplate original, Uri instanceUrl) { | ||
|
|
@@ -291,6 +291,7 @@ public static RenderedAdoTemplate RenderAdoTemplate(ILogger logTracer, Renderer | |
| original.UniqueFields, | ||
| adoFields, | ||
| onDuplicate, | ||
| original.AdoDuplicateFields, | ||
| original.Comment != null ? Render(renderer, original.Comment, instanceUrl, logTracer) : null | ||
| ); | ||
| } | ||
|
|
@@ -525,7 +526,7 @@ private async Async.Task<WorkItem> CreateNew() { | |
| return (taskType, document); | ||
| } | ||
|
|
||
| public async Async.Task Process(IList<(string, string)> notificationInfo) { | ||
| public async Async.Task Process(IList<(string, string)> notificationInfo, Dictionary<string, string>? duplicateFields) { | ||
| var updated = false; | ||
| WorkItem? oldestWorkItem = null; | ||
| await foreach (var workItem in ExistingWorkItems(notificationInfo)) { | ||
|
|
@@ -535,7 +536,7 @@ public async Async.Task Process(IList<(string, string)> notificationInfo) { | |
| _logTracer.AddTags(new List<(string, string)> { ("MatchingWorkItemIds", $"{workItem.Id}") }); | ||
| _logTracer.LogInformation("Found matching work item"); | ||
| } | ||
| if (IsADODuplicateWorkItem(workItem)) { | ||
| if (IsADODuplicateWorkItem(workItem, duplicateFields)) { | ||
kananb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| continue; | ||
| } | ||
|
|
||
|
|
@@ -575,13 +576,17 @@ public async Async.Task Process(IList<(string, string)> notificationInfo) { | |
| } | ||
| } | ||
|
|
||
| private static bool IsADODuplicateWorkItem(WorkItem wi) { | ||
| private static bool IsADODuplicateWorkItem(WorkItem wi, Dictionary<string, string>? duplicateFields) { | ||
| // A work item could have System.State == Resolve && System.Reason == Duplicate | ||
| // OR it could have System.State == Closed && System.Reason == Duplicate | ||
| // I haven't found any other combinations where System.Reason could be duplicate but just to be safe | ||
| // we're explicitly _not_ checking the state of the work item to determine if it's duplicate | ||
| return wi.Fields.ContainsKey("System.Reason") && string.Equals(wi.Fields["System.Reason"].ToString(), "Duplicate", StringComparison.OrdinalIgnoreCase) | ||
| || wi.Fields.ContainsKey("Microsoft.VSTS.Common.ResolvedReason") && string.Equals(wi.Fields["Microsoft.VSTS.Common.ResolvedReason"].ToString(), "Duplicate", StringComparison.OrdinalIgnoreCase) | ||
| || duplicateFields?.Any(fieldPair => { | ||
| var (field, value) = fieldPair; | ||
| return wi.Fields.ContainsKey(field) && string.Equals(wi.Fields[field].ToString(), value, StringComparison.OrdinalIgnoreCase); | ||
| }) == true | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have to add the |
||
| // Alternatively, the work item can also specify a 'relation' to another work item. | ||
| // This is typically used to create parent/child relationships between work items but can also | ||
| // Be used to mark duplicates so we should check this as well. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.