Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Polyphony/Commands/BranchCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,11 @@ private static IReadOnlyList<int> ExtractPredecessors(JsonNode item)

private static (string State, string Title) ExtractStateAndTitle(JsonNode item)
{
var fields = item["fields"];
var state = fields?["System.State"]?.GetValue<string>() ?? string.Empty;
var title = fields?["System.Title"]?.GetValue<string>() ?? string.Empty;
// twig >= v0.81.0 promotes state/title to top-level cells on
// `twig show --output json`. The fields[] subobject no longer
// redundantly carries System.State / System.Title.
var state = item["state"]?.GetValue<string>() ?? string.Empty;
var title = item["title"]?.GetValue<string>() ?? string.Empty;
return (state, title);
}

Expand Down
4 changes: 3 additions & 1 deletion src/Polyphony/Commands/PrCommands.OpenEvidencePr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,9 @@ private async Task<string> ResolveEvidencePrTitleAsync(int workItem, Cancellatio
try
{
var tree = await twig.ShowTreeAsync(workItem, ct).ConfigureAwait(false);
var workItemTitle = tree?["title"]?.GetValue<string>();
// twig >= v0.81.0 tree root is {parentChain, focus, children, …};
// the active item's title lives under `focus`.
var workItemTitle = tree?["focus"]?["title"]?.GetValue<string>();
return string.IsNullOrWhiteSpace(workItemTitle)
? fallback
: $"Evidence: {workItemTitle} (#{workItem})";
Expand Down
4 changes: 3 additions & 1 deletion src/Polyphony/Commands/PrCommands.OpenImplPr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,9 @@ private async Task<string> ResolveImplPrTitleAsync(int itemId, CancellationToken
try
{
var tree = await twig.ShowTreeAsync(itemId, ct).ConfigureAwait(false);
var workItemTitle = tree?["title"]?.GetValue<string>();
// twig >= v0.81.0 tree root is {parentChain, focus, children, …};
// the active item's title lives under `focus`.
var workItemTitle = tree?["focus"]?["title"]?.GetValue<string>();
return string.IsNullOrWhiteSpace(workItemTitle) ? fallback : $"{workItemTitle} AB#{itemId}";
}
catch
Expand Down
4 changes: 3 additions & 1 deletion src/Polyphony/Commands/PrCommands.OpenPlanPr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,9 @@ private async Task<string> ResolvePlanPrTitleAsync(int itemId, bool isRootPlan,
try
{
var tree = await twig.ShowTreeAsync(itemId, ct).ConfigureAwait(false);
var workItemTitle = tree?["title"]?.GetValue<string>();
// twig >= v0.81.0 tree root is {parentChain, focus, children, …};
// the active item's title lives under `focus`.
var workItemTitle = tree?["focus"]?["title"]?.GetValue<string>();
if (string.IsNullOrWhiteSpace(workItemTitle)) return fallback;
return $"plan: {workItemTitle} AB#{itemId}";
}
Expand Down
4 changes: 3 additions & 1 deletion src/Polyphony/Commands/PrCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ private async Task<string> ResolvePrTitleAsync(int workItem, CancellationToken c
try
{
var tree = await twig.ShowTreeAsync(workItem, ct).ConfigureAwait(false);
var title = tree?["title"]?.GetValue<string>();
// twig >= v0.81.0 tree root is {parentChain, focus, children, …};
// the active item's title lives under `focus`.
var title = tree?["focus"]?["title"]?.GetValue<string>();
return string.IsNullOrWhiteSpace(title) ? fallback : $"feat: {title} AB#{workItem}";
}
catch
Expand Down
12 changes: 6 additions & 6 deletions tests/Polyphony.Tests/Commands/BranchCommandsCheckDepsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public async Task CheckDeps_AllPredecessorsTerminal_EmitsNotBlocked()
]
}
""");
StubShow(runner, 200, """{"id":200,"fields":{"System.State":"Done","System.Title":"Pred A"}}""");
StubShow(runner, 201, """{"id":201,"fields":{"System.State":"Closed","System.Title":"Pred B"}}""");
StubShow(runner, 200, """{"id":200,"state":"Done","title":"Pred A"}""");
StubShow(runner, 201, """{"id":201,"state":"Closed","title":"Pred B"}""");

var (exit, output) = await CaptureConsoleAsync(() => cmd.CheckDeps(100));

Expand Down Expand Up @@ -103,9 +103,9 @@ public async Task CheckDeps_PartiallyBlocked_EmitsBlockedListWithPendingItems()
]
}
""");
StubShow(runner, 200, """{"id":200,"fields":{"System.State":"Done","System.Title":"Pred A"}}""");
StubShow(runner, 201, """{"id":201,"fields":{"System.State":"Doing","System.Title":"Pred B"}}""");
StubShow(runner, 202, """{"id":202,"fields":{"System.State":"To Do","System.Title":"Pred C"}}""");
StubShow(runner, 200, """{"id":200,"state":"Done","title":"Pred A"}""");
StubShow(runner, 201, """{"id":201,"state":"Doing","title":"Pred B"}""");
StubShow(runner, 202, """{"id":202,"state":"To Do","title":"Pred C"}""");

var (exit, output) = await CaptureConsoleAsync(() => cmd.CheckDeps(100));

Expand Down Expand Up @@ -133,7 +133,7 @@ public async Task CheckDeps_PredecessorsByAttributesName_AlsoCounted()
]
}
""");
StubShow(runner, 300, """{"id":300,"fields":{"System.State":"Done","System.Title":"Pred X"}}""");
StubShow(runner, 300, """{"id":300,"state":"Done","title":"Pred X"}""");

var (_, output) = await CaptureConsoleAsync(() => cmd.CheckDeps(100));
var result = Deserialize(output);
Expand Down
2 changes: 1 addition & 1 deletion tests/Polyphony.Tests/Commands/PrCommandsJournalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ private static void StubLsRemoteHas(FakeProcessRunner runner, string remote, str

private static void StubTwigShowTree(FakeProcessRunner runner, int id, string? title)
{
var json = title is null ? "" : $$"""{"title":"{{title}}","id":{{id}}}""";
var json = title is null ? "" : $$$"""{"focus":{"title":"{{{title}}}","id":{{{id}}}}}""";
runner.WhenExact("twig", ["show", id.ToString(), "--tree", "--output", "json"],
new ProcessResult(title is null ? 1 : 0, json, ""));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private static void StubLsRemoteHas(FakeProcessRunner runner, string pattern, bo

private static void StubTwigShowTree(FakeProcessRunner runner, int id, string? title)
{
var json = title is null ? "" : $$"""{"title":"{{title}}","id":{{id}}}""";
var json = title is null ? "" : $$$"""{"focus":{"title":"{{{title}}}","id":{{{id}}}}}""";
runner.WhenExact("twig", ["show", id.ToString(), "--tree", "--output", "json"],
new ProcessResult(title is null ? 1 : 0, json, ""));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private static void StubManifestMissing(FakeProcessRunner runner, int rootId, st

private static void StubTwigShow(FakeProcessRunner runner, int id, string? title)
{
var json = title is null ? "" : $$"""{"title":"{{title}}","id":{{id}}}""";
var json = title is null ? "" : $$$"""{"focus":{"title":"{{{title}}}","id":{{{id}}}}}""";
runner.WhenExact("twig", ["show", id.ToString(), "--tree", "--output", "json"],
new ProcessResult(title is null ? 1 : 0, json, ""));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private static void StubGitOriginUrl(FakeProcessRunner runner, string url)

private static void StubTwigShow(FakeProcessRunner runner, int id, string? title)
{
var json = title is null ? "" : $$"""{"title":"{{title}}","id":{{id}}}""";
var json = title is null ? "" : $$$"""{"focus":{"title":"{{{title}}}","id":{{{id}}}}}""";
runner.WhenExact("twig", ["show", id.ToString(), "--tree", "--output", "json"],
new ProcessResult(title is null ? 1 : 0, json, ""));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Polyphony.Tests/Commands/PrCommandsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private static void StubLsRemoteHas(FakeProcessRunner runner, string remote, str

private static void StubTwigShowTree(FakeProcessRunner runner, int id, string? title)
{
var json = title is null ? "" : $$"""{"title":"{{title}}","id":{{id}}}""";
var json = title is null ? "" : $$$"""{"focus":{"title":"{{{title}}}","id":{{{id}}}}}""";
runner.WhenExact("twig", new[] { "show", id.ToString(), "--tree", "--output", "json" },
new ProcessResult(title is null ? 1 : 0, json, ""));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Polyphony.Tests/Commands/PrOpenEvidenceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private static void StubLsRemoteHas(FakeProcessRunner runner, string pattern, bo

private static void StubTwigShowTree(FakeProcessRunner runner, int id, string? title)
{
var json = title is null ? "" : $$"""{"title":"{{title}}","id":{{id}}}""";
var json = title is null ? "" : $$$"""{"focus":{"title":"{{{title}}}","id":{{{id}}}}}""";
runner.WhenExact("twig", ["show", id.ToString(), "--tree", "--output", "json"],
new ProcessResult(title is null ? 1 : 0, json, ""));
}
Expand Down
Loading