Skip to content

Commit 8ddd745

Browse files
authored
Set initial AzDo state to "Committed" (#390)
Fixes #389
1 parent 68f2cbf commit 8ddd745

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

actions/sequester/Quest2GitHub/Models/QuestWorkItem.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,14 @@ public static async Task<QuestWorkItem> CreateWorkItemAsync(QuestIssueOrPullRequ
282282
Path = "/fields/System.State",
283283
Value = "Closed",
284284
});
285+
} else
286+
{
287+
patchDocument.Add(new JsonPatchDocument
288+
{
289+
Operation = Op.Add,
290+
Path = "/fields/System.State",
291+
Value = (iterationSize?.IsPastIteration == true) ? "New" : "Committed",
292+
});
285293
}
286294
JsonElement result = default;
287295
QuestWorkItem? newItem;

actions/sequester/Quest2GitHub/QuestGitHubService.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ private async Task RetrieveLabelIdsAsync(string org, string repo)
336336
int parentId = parentIdFromIssue(ghIssue);
337337
string? ghAssigneeEmailAddress = await ghIssue.QueryAssignedMicrosoftEmailAddressAsync(_ospoClient);
338338
AzDoIdentity? questAssigneeID = default;
339+
var proposedQuestState = questItem.State;
339340
if (ghAssigneeEmailAddress?.EndsWith("@microsoft.com") == true)
340341
{
341342
questAssigneeID = await _azdoClient.GetIDFromEmail(ghAssigneeEmailAddress);
@@ -385,13 +386,7 @@ private async Task RetrieveLabelIdsAsync(string org, string repo)
385386
bool questItemOpen = questItem.State is not "Closed";
386387
if (ghIssue.IsOpen != questItemOpen)
387388
{
388-
// build patch document for state.
389-
patchDocument.Add(new JsonPatchDocument
390-
{
391-
Operation = Op.Add,
392-
Path = "/fields/System.State",
393-
Value = ghIssue.IsOpen ? "Active" : "Closed",
394-
});
389+
proposedQuestState = ghIssue.IsOpen ? "Committed" : "Closed";
395390

396391
// When the issue is opened or closed,
397392
// update the description. That picks up any new
@@ -413,12 +408,22 @@ private async Task RetrieveLabelIdsAsync(string org, string repo)
413408
{
414409
Console.WriteLine($"Moving to the backlog / future iteration.");
415410
iteration = QuestIteration.FutureIteration(allIterations);
411+
proposedQuestState = "New";
416412
}
417413
}
418414
else
419415
{
420416
Console.WriteLine("No GitHub sprint project found - using current iteration.");
421417
}
418+
if (proposedQuestState != questItem.State)
419+
{
420+
patchDocument.Add(new JsonPatchDocument
421+
{
422+
Operation = Op.Add,
423+
Path = "/fields/System.State",
424+
Value = proposedQuestState,
425+
});
426+
}
422427
if ((iteration is not null) && (iteration.Path != questItem.IterationPath))
423428
{
424429
patchDocument.Add(new JsonPatchDocument

0 commit comments

Comments
 (0)