desktop: Add compare options to the revision picker

Right-clicking a revision in the Changes tab picker offers the same
comparisons as the activity tab's compare menu, so you don't have to
leave the Changes tab to compare revisions.
This commit is contained in:
Rūdolfs Ošiņš
2026-11-13 10:37:41 +01:00
parent f28442fd5c
commit c5957b32f4
10 changed files with 375 additions and 84 deletions
+32 -17
View File
@@ -77,9 +77,11 @@
// The revision and commit the patch is marked merged at, if any.
merge?: { revision: string; commit: string };
onViewRevision?: (revisionId: string) => void;
// The commit to diff the revision's head against instead of its base, such
// as the previous revision's head. Read when the tab opens and cleared here
// once the diff on screen is anything else: another revision or a commit.
// The commit to diff the revision's head against when the tab opens,
// instead of its base.
initialCompareFrom?: string;
// Output: the commit the diff on screen compares the revision's head
// against, while that is not its base.
compareFrom?: string;
}
@@ -105,6 +107,7 @@
revisions = [],
merge,
onViewRevision,
initialCompareFrom,
compareFrom = $bindable(),
}: Props = $props();
/* eslint-enable prefer-const */
@@ -117,7 +120,7 @@
// Parent reuses this component across patch revisions; a sibling $effect
// resets base and head when patchId changes.
// svelte-ignore state_referenced_locally
let base = $state(compareFrom ?? revision.base);
let base = $state(initialCompareFrom ?? revision.base);
// svelte-ignore state_referenced_locally
let head = $state(revision.head);
@@ -138,7 +141,6 @@
selectedCommitData = undefined;
editingDescription = false;
base = nextBase;
compareFrom = undefined;
head = nextHead;
});
});
@@ -158,7 +160,6 @@
}) {
head = headId;
base = baseId;
compareFrom = undefined;
selectedCommit = commitId;
selectedCommitData = commit;
filesExpanded = showFiles;
@@ -177,6 +178,21 @@
}
});
// A comparison is the revision's head diffed against another commit than its
// base, which only `compare` sets up.
const comparedFrom = $derived(
selectedCommit === undefined &&
head === revision.head &&
base !== revision.base
? base
: undefined,
);
$effect(() => {
if (compareFrom !== comparedFrom) {
compareFrom = comparedFrom;
}
});
// A `CodeLocation` records the commit a comment was written against but not
// the base it was diffed from, and placement matches on path and line alone,
// so a narrowed view carries no comment layer at all.
@@ -344,7 +360,7 @@
// A comparison is another range: an empty revision still differs from the
// one before it.
const emptyRevision = $derived(
compareFrom === undefined &&
comparedFrom === undefined &&
commitListRange === `${revision.base}..${revision.head}` &&
commitList.length === 0,
);
@@ -363,7 +379,7 @@
selectedCommit,
);
// A comparison is a range of its own, which selecting the commit would end.
if (only && compareFrom === undefined) {
if (only && comparedFrom === undefined) {
selectRevision({
headId: revision.head,
baseId: revision.base,
@@ -420,10 +436,11 @@
diffView?.scrollToFilesTop();
}
/// Go back to the revision's own changes, which ends a comparison. Driven
/// from the tab bar, which the patch view renders.
export function showRevisionChanges() {
selectRevision({ headId: revision.head, baseId: revision.base });
/// Diff the revision's head against `from`, or against its base when absent,
/// which ends a comparison. Driven from the patch view's tab bar and revision
/// picker.
export function compare(from?: string) {
selectRevision({ headId: revision.head, baseId: from ?? revision.base });
void scrollToDiff();
}
@@ -479,8 +496,7 @@
useShortcuts(
{
shortcut: "previousCommit",
// The commits column is hidden during a comparison.
enabled: () => commitList.length > 1 && compareFrom === undefined,
enabled: () => commitList.length > 1 && comparedFrom === undefined,
run: () => {
const current = commitList.findIndex(c => c.id === selectedCommit);
selectCommitAt(stepCommitIndex(current, commitList.length, -1));
@@ -488,8 +504,7 @@
},
{
shortcut: "nextCommit",
// The commits column is hidden during a comparison.
enabled: () => commitList.length > 1 && compareFrom === undefined,
enabled: () => commitList.length > 1 && comparedFrom === undefined,
run: () => {
const current = commitList.findIndex(c => c.id === selectedCommit);
selectCommitAt(stepCommitIndex(current, commitList.length, 1));
@@ -1000,7 +1015,7 @@
codeComments={diffCodeComments}
commentCommit={isRevisionDiff ? head : undefined}
header={diffHeader}
overlayLeft={emptyRevision || compareFrom !== undefined
overlayLeft={emptyRevision || comparedFrom !== undefined
? undefined
: commitsColumn}
{filesHeader}
+4 -1
View File
@@ -34,9 +34,11 @@
target?: HTMLElement;
onclose: () => void;
children: Snippet;
// Raises the menu above a popover it is opened from.
styleZIndex?: string;
}
const { x, y, target, onclose, children }: Props = $props();
const { x, y, target, onclose, children, styleZIndex }: Props = $props();
const getViewport = getScrollViewport();
@@ -214,6 +216,7 @@
use:portal
bind:this={menuEl}
class="menu"
style:z-index={styleZIndex}
role="menu"
tabindex="-1"
onclick={onMenuClick}
@@ -5,6 +5,7 @@
children: Snippet;
selected: boolean;
onclick?: () => void;
oncontextmenu?: (event: MouseEvent) => void;
disabled?: boolean;
title?: string;
styleGap?: string;
@@ -14,6 +15,7 @@
const {
onclick,
oncontextmenu,
children,
selected,
disabled = false,
@@ -76,6 +78,7 @@
return;
}
onclick();
}}>
}}
{oncontextmenu}>
{@render children()}
</div>
+27 -24
View File
@@ -36,6 +36,7 @@
} from "@app/lib/invoke";
import type { PatchActivityData } from "@app/lib/patchTimeline";
import { patchTimeline } from "@app/lib/patchTimeline";
import { revisionRange } from "@app/lib/revisionCompare";
import {
groupCommitsByAuthor,
isCommitListDescription,
@@ -112,8 +113,11 @@
// Opens the Changes tab on a revision; `compareFrom` diffs its head against
// that commit instead of its base.
onViewChanges?: (revisionId: string, compareFrom?: string) => void;
// The commit the Changes tab diffs the revision's head against, when it is
// not the base. Cleared here once the diff on screen is another range.
// The commit the Changes tab diffs the revision's head against when it
// opens, instead of its base.
initialCompareFrom?: string;
// Output: the commit the Changes tab diffs the revision's head against,
// while that is not its base.
compareFrom?: string;
// The revision and commit the patch is marked merged at, if any.
merge?: { revision: string; commit: string };
@@ -145,6 +149,7 @@
hiddenCommentSources = [],
filesExpanded = $bindable(true),
onViewChanges,
initialCompareFrom,
compareFrom = $bindable(),
merge,
chrome,
@@ -160,9 +165,10 @@
changes?.setAllFilesCollapsed(collapsed);
}
/// Forwarded to the Changes tab so the tab bar can end a comparison.
export function showRevisionChanges() {
changes?.showRevisionChanges();
/// Forwarded to the Changes tab so the tab bar and revision picker can start
/// or end a comparison.
export function compare(from?: string) {
changes?.compare(from);
}
/// Forwarded to the Changes tab so the tab bar's stepper can walk the comments
@@ -186,21 +192,17 @@
const latestRevisionId = $derived(revisions.at(-1)?.id);
const firstRevisionId = $derived(revisions[0]?.id);
// What each revision's compare menu offers, by revision id: its own base and
// the revision before it. Empty when there is no Changes tab to open them in.
const compareMenus = $derived(
Object.fromEntries(
(onViewChanges ? revisions : []).map((rev, index) => [
rev.id,
{
base: rev.base,
head: rev.head,
previous: revisions[index - 1],
onCompare: (from?: string) => onViewChanges?.(rev.id, from),
},
]),
),
);
// What a revision's compare menu offers: its own base and the revision
// before it. Nothing when there is no Changes tab to open them in.
function compareMenu(revId: string) {
const range = onViewChanges && revisionRange(revisions, revId);
return (
range && {
...range,
onCompare: (from?: string) => onViewChanges?.(revId, from),
}
);
}
const targetBranch = $derived(
patchTargetBranch === undefined
@@ -1182,7 +1184,7 @@
onOpenChanges={onViewChanges
? () => onViewChanges?.(revId)
: undefined}
compare={compareMenus[revId]}
compare={compareMenu(revId)}
{expanded}
hideAuthor={opts.hideAuthor}
bodyExternal
@@ -1436,7 +1438,7 @@
onOpenChanges={onViewChanges
? () => onViewChanges?.(revId)
: undefined}
compare={compareMenus[revId]} />
compare={compareMenu(revId)} />
</div>
{:else}
<PatchActivityItem
@@ -1449,7 +1451,7 @@
onOpenChanges={onViewChanges
? () => onViewChanges?.(revId)
: undefined}
compare={compareMenus[revId]} />
compare={compareMenu(revId)} />
{/if}
{:else if data.op.type === "review"}
{@const opId = data.op.id}
@@ -1539,7 +1541,7 @@
firstRevision
openedAsDraft={data.openedAsDraft}
hideAuthor={opts.hideAuthor}
compare={compareMenus[data.op.id]} />
compare={compareMenu(data.op.id)} />
{:else if data.kind === "olderRevisions"}
<!-- svelte-ignore a11y_click_events_have_key_events -->
<div
@@ -1615,6 +1617,7 @@
onViewRevision={onViewChanges}
{chrome}
{tabs}
{initialCompareFrom}
bind:compareFrom
bind:showingRevisionDiff
bind:filesExpanded
@@ -0,0 +1,59 @@
<script lang="ts">
import type { RevisionRange } from "@app/lib/revisionCompare";
import { compareRange, previousOption } from "@app/lib/revisionCompare";
import { formatOid } from "@app/lib/utils";
import ContextMenu from "@app/components/ContextMenu.svelte";
interface Props extends RevisionRange {
x: number;
y: number;
target?: HTMLElement;
// Called with the commit to diff `head` against, or with nothing for the
// revision's own base.
onCompare: (from?: string) => void;
onclose: () => void;
}
const { x, y, target, base, head, previous, onCompare, onclose }: Props =
$props();
const prev = $derived(previousOption({ base, head, previous }));
</script>
<style>
.item {
gap: 0.25rem;
}
.item.item:disabled {
color: var(--color-text-disabled);
cursor: not-allowed;
background-color: transparent;
}
.previous-id {
color: var(--color-text-brand);
}
</style>
<!-- Opened from the revision picker, a popover. -->
<ContextMenu {x} {y} {target} {onclose} styleZIndex="500">
<button
class="menu-item item"
role="menuitem"
title={compareRange(base, head)}
onclick={() => onCompare()}>
Compare to base:
<span class="txt-id">{formatOid(base)}</span>
</button>
{#if prev}
<button
class="menu-item item"
role="menuitem"
disabled={prev.disabled}
title={prev.title}
onclick={() => onCompare(prev.from)}>
Compare to previous revision:
<span class="txt-id previous-id">{formatOid(prev.id)}</span>
</button>
{/if}
</ContextMenu>
@@ -1,4 +1,6 @@
<script lang="ts">
import type { RevisionRange } from "@app/lib/revisionCompare";
import { compareRange, previousOption } from "@app/lib/revisionCompare";
import { formatOid } from "@app/lib/utils";
import Button from "@app/components/Button.svelte";
@@ -7,11 +9,7 @@
import Icon from "@app/components/Icon.svelte";
import Popover, { closeFocused } from "@app/components/Popover.svelte";
interface Props {
base: string;
head: string;
// The revision before this one, absent for the first.
previous?: { id: string; base: string; head: string };
interface Props extends RevisionRange {
// Called with the commit to diff `head` against, or with nothing for the
// revision's own base.
onCompare: (from?: string) => void;
@@ -21,14 +19,7 @@
let expanded = $state(false);
// Diffing two heads on different bases would mix in every change between the
// bases, so the previous revision is only offered on the same base.
const baseMoved = $derived(previous !== undefined && previous.base !== base);
// Nothing changed between two revisions on the same commit.
const sameHead = $derived(previous?.head === head);
const range = (from: string) => `${formatOid(from)}..${formatOid(head)}`;
const prev = $derived(previousOption({ base, head, previous }));
function compare(from?: string) {
closeFocused();
@@ -71,34 +62,28 @@
style:border-radius="var(--border-radius-md)"
style:background-color="var(--color-surface-canvas)"
style:padding="0.25rem">
<DropdownList items={previous ? ["base", "previous"] : ["base"]}>
<DropdownList items={prev ? ["base", "previous"] : ["base"]}>
{#snippet item(entry)}
{#if entry === "base"}
<DropdownListItem
selected={false}
title={range(base)}
title={compareRange(base, head)}
onclick={() => compare()}>
<span class="item">
Compare to base:
<span class="txt-id">{formatOid(base)}</span>
</span>
</DropdownListItem>
{:else if previous}
{:else if prev}
<DropdownListItem
selected={false}
disabled={baseMoved || sameHead}
title={baseMoved
? "Previous revision has different base"
: sameHead
? "Same commit as the previous revision"
: range(previous.head)}
onclick={() =>
// An empty previous revision's head is this one's base.
compare(previous.head === base ? undefined : previous.head)}>
disabled={prev.disabled}
title={prev.title}
onclick={() => compare(prev.from)}>
<span class="item">
Compare to previous revision:
<span class="txt-id previous-id">
{formatOid(previous.id)}
{formatOid(prev.id)}
</span>
</span>
</DropdownListItem>
+64
View File
@@ -0,0 +1,64 @@
import { formatOid } from "@app/lib/utils";
interface RevisionCommits {
id: string;
base: string;
head: string;
}
export interface RevisionRange {
base: string;
head: string;
// The revision before this one, absent for the first.
previous?: RevisionCommits;
}
export function compareRange(from: string, head: string): string {
return `${formatOid(from)}..${formatOid(head)}`;
}
/// The range of the revision `revisionId` and the revision before it in
/// `revisions`, which are in timeline order, or nothing if it isn't there.
export function revisionRange(
revisions: RevisionCommits[],
revisionId: string,
): RevisionRange | undefined {
const index = revisions.findIndex(r => r.id === revisionId);
if (index < 0) return undefined;
const { base, head } = revisions[index];
return { base, head, previous: revisions[index - 1] };
}
/// The "compare to previous revision" option, or nothing for the first
/// revision.
export function previousOption({ base, head, previous }: RevisionRange):
| {
id: string;
disabled: boolean;
title: string;
// The commit to diff `head` against.
from: string;
}
| undefined {
if (!previous) return undefined;
// Diffing two heads on different bases would mix in every change between the
// bases, so the previous revision is only offered on the same base.
const baseMoved = previous.base !== base;
// Nothing changed between two revisions on the same commit.
const sameHead = previous.head === head;
// An empty previous revision's head is this one's base, so comparing to it
// would be comparing to the base.
const previousEmpty = previous.head === base;
return {
id: previous.id,
disabled: baseMoved || sameHead || previousEmpty,
title: baseMoved
? "Previous revision has different base"
: sameHead
? "Same commit as the previous revision"
: previousEmpty
? "Previous revision has no changes"
: compareRange(previous.head, head),
from: previous.head,
};
}
+52 -10
View File
@@ -13,6 +13,7 @@
import UserAvatar from "@radicle-gui/ui/components/UserAvatar.svelte";
import countBy from "lodash/countBy";
import { tick } from "svelte";
import { SvelteSet } from "svelte/reactivity";
import { commentSourcesOf } from "@app/lib/commentSources";
@@ -29,6 +30,7 @@
import { setPatchActivitySource } from "@app/lib/patchActivityContext";
import { patchContributions } from "@app/lib/patchContributions";
import type { ReviewEntry } from "@app/lib/reviewSummary";
import { compareRange, revisionRange } from "@app/lib/revisionCompare";
import { revisionTitle } from "@app/lib/revisionDescription";
import { orderRevisions, revisionNumbers } from "@app/lib/revisionList";
import { revisionListSettings } from "@app/lib/revisionListSettings";
@@ -38,7 +40,6 @@
absoluteTimestamp,
authorForNodeId,
didFromPublicKey,
formatOid,
formatTimestamp,
patchStatusLabel,
publicKeyFromDid,
@@ -61,6 +62,7 @@
import ReviewProgressChip from "@app/components/ReviewProgressChip.svelte";
import ReviewSummary from "@app/components/ReviewSummary.svelte";
import RevisionComponent from "@app/components/Revision.svelte";
import RevisionCompareContextMenu from "@app/components/RevisionCompareContextMenu.svelte";
import ScrollArea from "@app/components/ScrollArea.svelte";
import ShareButton from "@app/components/ShareButton.svelte";
import Spinner from "@app/components/Spinner.svelte";
@@ -187,10 +189,10 @@
// When opening a specific revision's changes from the timeline, the target
// survives the view switch (the reset effect below honours it once).
let pendingRevisionId: string | undefined;
let pendingCompareFrom: string | undefined;
// The commit the Changes tab diffs the selected revision's head against, when
// it is not the base: the previous revision's head, from the compare menu.
// Set here only on the way into the tab; the tab ends the comparison itself.
// The comparison the Changes tab opens with, read once when it mounts.
let pendingCompareFrom: string | undefined = $state();
// The commit the Changes tab diffs the selected revision's head against,
// while that is not its base. The tab keeps this up to date.
let compareFrom: string | undefined = $state();
// Warm the Changes-tab data for the selected revision in the background, so
@@ -448,7 +450,7 @@
if (patchView !== lastPatchView) {
lastPatchView = patchView;
selectedRevisionId = pendingRevisionId ?? revisions.slice(-1)[0].id;
compareFrom = pendingCompareFrom;
compareFrom = undefined;
pendingRevisionId = undefined;
pendingCompareFrom = undefined;
}
@@ -535,6 +537,26 @@
function selectRevision(revId: string) {
selectedRevisionId = revId;
}
// The revision picker row that was right-clicked, for its compare menu.
let revisionContextMenu:
{ x: number; y: number; target: HTMLElement; revId: string } | undefined =
$state();
const revisionContextMenuRange = $derived.by(() => {
if (!revisionContextMenu) return undefined;
return revisionRange(orderedRevisions, revisionContextMenu.revId);
});
async function compareRevision(revId: string, from?: string) {
closeFocused();
if (revId !== selectedRevisionId) {
selectedRevisionId = revId;
// Let the Changes tab take the new revision before starting the
// comparison, as switching revisions ends one.
await tick();
}
revisionComponent?.compare(from);
}
const hasOwnPublishedReviewOnSelected = $derived(
selectedRevision.reviews?.some(r => r.author.did === ownDid) ?? false,
);
@@ -974,7 +996,7 @@
);
// A review is written on the revision's own changes.
if (compareFrom !== undefined) {
revisionComponent?.showRevisionChanges();
revisionComponent?.compare();
}
setView("changes");
}}
@@ -1167,10 +1189,10 @@
<Button
variant="outline"
title="Show the revision's own changes"
onclick={() => revisionComponent?.showRevisionChanges()}>
onclick={() => revisionComponent?.compare()}>
Compare
<span class="txt-id">
{formatOid(compareFrom)}..{formatOid(selectedRevision.head)}
{compareRange(compareFrom, selectedRevision.head)}
</span>
<Icon name="close" />
</Button>
@@ -1322,6 +1344,15 @@
onclick={() => {
void selectRevision(rev.id);
closeFocused();
}}
oncontextmenu={event => {
event.preventDefault();
revisionContextMenu = {
x: event.clientX,
y: event.clientY,
target: event.currentTarget as HTMLElement,
revId: rev.id,
};
}}>
{#if listSettings.showNumber}
<span class="revision-number">
@@ -1436,12 +1467,12 @@
pendingCompareFrom = from;
}
selectedRevisionId = revisionId;
compareFrom = from;
setView("changes");
}}
merge={patch.state.status === "merged" ? patch.state : undefined}
chrome={patchHeader}
{tabs}
initialCompareFrom={pendingCompareFrom}
bind:compareFrom
bind:showingRevisionDiff
bind:filesExpanded
@@ -1559,3 +1590,14 @@
{/if}
</div>
</Layout>
{#if revisionContextMenu && revisionContextMenuRange}
{@const { revId, x, y, target } = revisionContextMenu}
<RevisionCompareContextMenu
{x}
{y}
{target}
{...revisionContextMenuRange}
onCompare={from => void compareRevision(revId, from)}
onclose={() => (revisionContextMenu = undefined)} />
{/if}
+63 -5
View File
@@ -153,17 +153,38 @@ test("a comment-only review needs a summary", async ({ page, peer }) => {
await expect(publish).toBeEnabled();
});
test("the revision picker counts a revision's commits as the Changes view does", async ({
page,
peer,
}) => {
// A second revision that keeps the first one's commit and adds another.
async function createTwoRevisionPatch(peer: RadiclePeer) {
const { rid, patchId, repoFolder } = await createPatch(peer);
// A second revision that keeps the first one's commit and adds another.
await Fs.appendFile(Path.join(repoFolder, "notes.txt"), "six\n");
await peer.git(["commit", "-am", "Add a sixth line"], { cwd: repoFolder });
await peer.git(["push", "rad", `HEAD:refs/heads/patches/${patchId}`], {
cwd: repoFolder,
});
return { rid, patchId };
}
function addedLine(page: Page, text: string) {
return page.locator('[data-line-type="change-addition"]', { hasText: text });
}
// The second revision diffed against the first only adds the sixth line.
async function expectComparedToPrevious(page: Page) {
await expect(addedLine(page, "six")).toBeVisible();
await expect(addedLine(page, "THREE")).toHaveCount(0);
}
async function endComparison(page: Page) {
await page.getByTitle("Show the revision's own changes").click();
await expect(addedLine(page, "THREE")).toBeVisible();
await expect(page.getByTitle("Show the revision's own changes")).toBeHidden();
}
test("the revision picker counts a revision's commits as the Changes view does", async ({
page,
peer,
}) => {
const { rid, patchId } = await createTwoRevisionPatch(peer);
await page.goto(`/repos/${rid}/patches/${patchId}?view=changes`);
await expect(page.getByText("2 commits on base")).toBeVisible();
@@ -174,6 +195,43 @@ test("the revision picker counts a revision's commits as the Changes view does",
).toBeVisible();
});
test("compares a revision with the previous one from the activity tab", async ({
page,
peer,
}) => {
const { rid, patchId } = await createTwoRevisionPatch(peer);
await page.goto(`/repos/${rid}/patches/${patchId}`);
// The timeline lists the second revision last.
await page.getByTitle("Compare revision").last().click();
await page
.getByRole("button", { name: /^Compare to previous revision/ })
.click();
await expect(page).toHaveURL(/view=changes/);
await expectComparedToPrevious(page);
await endComparison(page);
});
test("compares a revision with the previous one from the revision picker", async ({
page,
peer,
}) => {
const { rid, patchId } = await createTwoRevisionPatch(peer);
await page.goto(`/repos/${rid}/patches/${patchId}?view=changes`);
await page.getByRole("button", { name: /Revision 2 of 2/ }).click();
await page
.getByRole("button", { name: /Add a sixth line/ })
.click({ button: "right" });
await page
.getByRole("menuitem", { name: /^Compare to previous revision/ })
.click();
await expectComparedToPrevious(page);
await endComparison(page);
});
test("shows reviews from other peers", async ({ page }) => {
await page.goto(`/repos/${cobRid}/patches`);
await page.getByText("Taking another stab at the README").click();
@@ -0,0 +1,59 @@
import { describe, expect, test } from "vitest";
import { previousOption, revisionRange } from "@app/lib/revisionCompare";
import { revision } from "./support/cobs";
const r1 = revision({ id: "r1", base: "base", head: "one" });
const r2 = revision({ id: "r2", base: "base", head: "two" });
const r3 = revision({ id: "r3", base: "base", head: "three" });
describe("revisionRange", () => {
test("pairs a revision with the one before it in timeline order", () => {
expect(revisionRange([r1, r2, r3], "r3")).toEqual({
base: "base",
head: "three",
previous: r2,
});
});
test("the first revision has no previous one", () => {
expect(revisionRange([r1, r2], "r1")?.previous).toBeUndefined();
});
test("a revision that isn't listed has no range", () => {
expect(revisionRange([r1, r2], "r4")).toBeUndefined();
expect(revisionRange([], "r1")).toBeUndefined();
});
});
describe("previousOption", () => {
test("is absent for the first revision", () => {
expect(previousOption({ base: "base", head: "one" })).toBeUndefined();
});
test("diffs against the previous head on the same base", () => {
const option = previousOption({ base: "base", head: "two", previous: r1 });
expect(option).toMatchObject({ id: "r1", disabled: false, from: "one" });
});
test("is disabled when the base moved", () => {
const previous = revision({ id: "r1", base: "old", head: "one" });
expect(
previousOption({ base: "base", head: "two", previous })?.disabled,
).toBe(true);
});
test("is disabled when both revisions are the same commit", () => {
expect(
previousOption({ base: "base", head: "one", previous: r1 })?.disabled,
).toBe(true);
});
test("is disabled when the previous revision is empty", () => {
const previous = revision({ id: "r1", base: "base", head: "base" });
expect(
previousOption({ base: "base", head: "two", previous })?.disabled,
).toBe(true);
});
});