Skip to content

Commit 85e83e4

Browse files
authored
Fix issue with default parent (#573)
When an item wasn't in a semester, and it had no tag for a given section, the parent defaulted to 0, not the default parent ID in the config. Update tests to catch that, then update code to match the new behavior.
1 parent 06d8e15 commit 85e83e4

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

actions/sequester/ImportIssues/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ private static async Task<QuestGitHubService> CreateService(ImportOptions option
119119
options.ImportedLabel,
120120
options.UnlinkLabel,
121121
options.ParentNodes,
122+
options.DefaultParentNode,
122123
options.WorkItemTags,
123124
options.TeamGitHubLogins,
124125
options.CopilotIssueTag);

actions/sequester/Quest2GitHub.Tests/BuildExtendedPropertiesTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ public static void BuildExtensionForOpenIssueSinglePastProject()
671671
Assert.Equal("Content\\Future", extendedProperties.IterationPath);
672672
Assert.Equal("New", extendedProperties.WorkItemState);
673673
Assert.Empty(extendedProperties.Tags);
674-
Assert.Equal(0, extendedProperties.ParentNodeId);
674+
Assert.Equal(33, extendedProperties.ParentNodeId);
675675
}
676676

677677
[Fact]
@@ -698,7 +698,7 @@ public static void BuildExtensionForOpenIssueMultiplePastProject()
698698
Assert.Equal("Content\\Future", extendedProperties.IterationPath);
699699
Assert.Equal("New", extendedProperties.WorkItemState);
700700
Assert.Equal(["content-curation"], extendedProperties.Tags);
701-
Assert.Equal(0, extendedProperties.ParentNodeId);
701+
Assert.Equal(33, extendedProperties.ParentNodeId);
702702
}
703703

704704
[Fact]
@@ -712,7 +712,7 @@ public static void BuildExtensionForNoProject()
712712
Assert.Equal("Content\\Future", extendedProperties.IterationPath);
713713
Assert.Equal("New", extendedProperties.WorkItemState);
714714
Assert.Empty(extendedProperties.Tags);
715-
Assert.Equal(0, extendedProperties.ParentNodeId);
715+
Assert.Equal(33, extendedProperties.ParentNodeId);
716716
}
717717

718718
[Fact]
@@ -726,7 +726,7 @@ public static void BuildExtensionForNoProjectClosed()
726726
Assert.Equal("Content\\Future", extendedProperties.IterationPath);
727727
Assert.Equal("Closed", extendedProperties.WorkItemState);
728728
Assert.Empty(extendedProperties.Tags);
729-
Assert.Equal(0, extendedProperties.ParentNodeId);
729+
Assert.Equal(33, extendedProperties.ParentNodeId);
730730
}
731731

732732
private static WorkItemProperties CreateIssueObject(string jsonDocument)
@@ -738,7 +738,7 @@ private static WorkItemProperties CreateIssueObject(string jsonDocument)
738738
issueNumber = 1111
739739
};
740740
JsonElement element = JsonDocument.Parse(jsonDocument).RootElement;
741-
return new WorkItemProperties(QuestIssue.FromJsonElement(element, variables), _allIterations, _tagMap, _parentMap, "copilotTag");
741+
return new WorkItemProperties(QuestIssue.FromJsonElement(element, variables), _allIterations, _tagMap, _parentMap, _defaultParentId, "copilotTag");
742742
}
743743

744744
}

actions/sequester/Quest2GitHub/Models/WorkItemProperties.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public WorkItemProperties (QuestIssueOrPullRequest issue,
2222
IEnumerable<QuestIteration> iterations,
2323
IEnumerable<LabelToTagMap> tags,
2424
IEnumerable<ParentForLabel> parentNodes,
25+
int defaultParentNodeId,
2526
string copilotTag)
2627
{
2728
StoryPointSize? storySize = LatestStoryPointSize(issue);
@@ -41,7 +42,7 @@ public WorkItemProperties (QuestIssueOrPullRequest issue,
4142
};
4243
IterationPath = latestIteration.Path;
4344

44-
ParentNodeId = 0;
45+
ParentNodeId = defaultParentNodeId;
4546

4647
if (WorkItemState is not "New")
4748
{

actions/sequester/Quest2GitHub/Options/ImportOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ public sealed record class ImportOptions
7272
/// </remarks>
7373
public List<ParentForLabel> ParentNodes { get; init; } = [];
7474

75+
/// <summary>
76+
/// The default parent node ID to use when no other parent has been configured.
77+
/// </summary>
78+
public int DefaultParentNode { get; init; } = 0;
79+
7580
/// <summary>
7681
/// A map of GitHub labels to Azure DevOps tags.
7782
/// </summary>

actions/sequester/Quest2GitHub/QuestGitHubService.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class QuestGitHubService(
4040
string importedLabelText,
4141
string removeLinkItemText,
4242
List<ParentForLabel> parentNodes,
43+
int defaultParentNodeId,
4344
IEnumerable<LabelToTagMap> tagMap,
4445
IEnumerable<string> gitHubLogins,
4546
string copilotTag) : IDisposable
@@ -97,7 +98,7 @@ async Task ProcessItems(IAsyncEnumerable<QuestIssueOrPullRequest> items)
9798
QuestWorkItem? questItem = (request || sequestered || vanquished)
9899
? await FindLinkedWorkItemAsync(item)
99100
: null;
100-
var issueProperties = new WorkItemProperties(item, _allIterations, tagMap, parentNodes, copilotTag);
101+
var issueProperties = new WorkItemProperties(item, _allIterations, tagMap, parentNodes, defaultParentNodeId, copilotTag);
101102

102103
Console.WriteLine($"{item.Number}: {item.Title}, {issueProperties.IssueLogString}");
103104
Task workDone = (request, sequestered, vanquished, questItem) switch
@@ -184,7 +185,7 @@ public async Task ProcessIssue(string gitHubOrganization, string gitHubRepositor
184185
? await FindLinkedWorkItemAsync(ghIssue)
185186
: null;
186187

187-
var issueProperties = new WorkItemProperties(ghIssue, _allIterations, tagMap, parentNodes, copilotTag);
188+
var issueProperties = new WorkItemProperties(ghIssue, _allIterations, tagMap, parentNodes, defaultParentNodeId, copilotTag);
188189

189190
Task workDone = (request, sequestered, vanquished, questItem) switch
190191
{

0 commit comments

Comments
 (0)