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
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,72 @@ describe("pull request dependency navigation", () => {
possibleParents: [{ number: 41 }],
});
});
it("keeps warnings on another retained branch out of the focused path", () => {
const navigation = view(
context({
coverage: "partial",
edges: [
{ parent: 41, child: 42, certainty: "confirmed" },
{ parent: 41, child: 43, certainty: "confirmed" },
{ parent: 44, child: 43, certainty: "candidate" },
{ parent: 43, child: 44, certainty: "candidate" },
],
issues: [
{ number: 43, reason: "ambiguous-parent" },
{ number: 43, reason: "cycle" },
{ number: 44, reason: "cycle" },
],
}),
);

expect(navigation).toMatchObject({
status: "ready",
path: [{ number: 41 }, { number: 42 }],
rootBase: "main",
parentAmbiguous: false,
cycleBefore: false,
cycleAfter: false,
siblings: [{ number: 43 }],
coverage: "partial",
});
});

it.each([41, 42])("retains ambiguous-parent warnings for ancestor or focus #%s", (number) => {
expect(
view(
context({
edges: [{ parent: 41, child: 42, certainty: "confirmed" }],
issues: [{ number, reason: "ambiguous-parent" }],
}),
),
).toMatchObject({ status: "ready", rootBase: null, parentAmbiguous: number === 42 });
});

it("retains cycle warnings for nodes on the focused path", () => {
expect(
view(
context({
edges: [{ parent: 41, child: 42, certainty: "confirmed" }],
issues: [{ number: 42, reason: "cycle" }],
}),
),
).toMatchObject({ status: "ready", cycleAfter: true });
});

it("does not hide the root base for an ambiguous descendant", () => {
expect(
view(
context({
edges: [
{ parent: 41, child: 42, certainty: "confirmed" },
{ parent: 42, child: 43, certainty: "confirmed" },
],
issues: [{ number: 43, reason: "ambiguous-parent" }],
}),
),
).toMatchObject({ status: "ready", rootBase: "main", parentAmbiguous: false });
});

it("keeps native membership navigable when a member was not loaded", () => {
const navigation = view(
context({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ export function pullRequestDependencyNavigation(input: {
const confirmedParents = incoming.get(focus) ?? [];
const parent = unique(confirmedParents);
const child = unique(outgoing.get(focus) ?? []);
const parentAmbiguous = context.issues.some((issue) => issue.reason === "ambiguous-parent");
const parentAmbiguous = context.issues.some(
(issue) =>
issue.reason === "ambiguous-parent" && (issue.number === undefined || issue.number === focus),
);
const possibleParents = toChips([
...new Set([
...(confirmedParents.length > 1 ? confirmedParents : []),
Expand Down Expand Up @@ -147,6 +150,11 @@ export function pullRequestDependencyNavigation(input: {
const unresolvedRoot =
truncatedBefore ||
cycleBefore ||
context.issues.some(
(issue) =>
issue.reason === "ambiguous-parent" &&
(issue.number === undefined || beforeSeen.has(issue.number)),
) ||
(candidateIncoming.get(path[0]?.number ?? focus)?.length ?? 0) > 0 ||
(incoming.get(path[0]?.number ?? focus)?.length ?? 0) > 1 ||
context.coverage === "unavailable";
Expand All @@ -164,9 +172,17 @@ export function pullRequestDependencyNavigation(input: {
: context.native?.status === "unavailable"
? { status: "unavailable" as const }
: { status: "hidden" as const };
// The transport intentionally records only that a cycle was found, not an invented direction.
// When traversal did not encounter it itself, place the stop after the known path.
if (context.issues.some((issue) => issue.reason === "cycle") && !cycleBefore && !cycleAfter) {
// Numbered diagnostics can describe another retained branch. Only mark this path for its own
// cycle (or an unscoped host warning); traversal already locates cycles it encounters directly.
const pathNumbers = new Set(path.map((node) => node.number));
if (
context.issues.some(
(issue) =>
issue.reason === "cycle" && (issue.number === undefined || pathNumbers.has(issue.number)),
) &&
!cycleBefore &&
!cycleAfter
) {
cycleAfter = true;
}
const hasGraph =
Expand Down