feat(pull-requests): quick actions follow each host's capabilities, not GitHub (#17774)
Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
b0249ac871
commit
9b40d37463
24 files changed
+254
-83
No files matched your search
@@ -572,6 +572,35 @@ it.effect("lists GitHub Enterprise PRs for a stored unknown repository after hos
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("reports each host's actions with its summary, so rows can offer them unread", () =>
|
||||
Effect.gen(function* () {
|
||||
const service = yield* makeService({
|
||||
projects: [
|
||||
project({
|
||||
id: "p1",
|
||||
title: "web",
|
||||
workspaceRoot: "/repo",
|
||||
repository: "acme/web",
|
||||
provider: SourceControlProviderKind.make("bitbucket"),
|
||||
host: "bitbucket.org",
|
||||
}),
|
||||
],
|
||||
providers: [
|
||||
fakeProvider(SourceControlProviderKind.make("bitbucket"), {
|
||||
capabilities: {
|
||||
...fakeProvider(SourceControlProviderKind.make("bitbucket")).capabilities,
|
||||
actions: ["merge", "close"],
|
||||
},
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
const result = yield* service.list({ state: "open" });
|
||||
|
||||
assert.deepStrictEqual(result.providers[0]?.actions, ["merge", "close"]);
|
||||
}),
|
||||
);
|
||||
|
||||
it.effect("refines unknown self-hosted GitLab projects before listing merge requests", () =>
|
||||
Effect.gen(function* () {
|
||||
let refinementCalls = 0;
|
||||
|
||||
@@ -1252,20 +1252,24 @@ export const make = Effect.gen(function* () {
|
||||
// One summary per host, which is what the viewer lookup already answers for: two GitHub
|
||||
// hosts sign in separately, so collapsing them by kind would report one as the other.
|
||||
const providers: ReadonlyArray<PullRequestProviderSummary> = [
|
||||
...viewerResults.map((result) => ({
|
||||
host: result.host,
|
||||
kind: result.kind,
|
||||
searchesOnHost:
|
||||
projects.find((project) => project.host === result.host)?.api.capabilities.search ??
|
||||
false,
|
||||
projectCount: projectCounts.get(result.host) ?? 1,
|
||||
configured: result.viewer !== null,
|
||||
detail: result.error === null ? null : providerDetail(result.error),
|
||||
})),
|
||||
...viewerResults.map((result) => {
|
||||
const capabilities = projects.find((project) => project.host === result.host)?.api
|
||||
.capabilities;
|
||||
return {
|
||||
host: result.host,
|
||||
kind: result.kind,
|
||||
searchesOnHost: capabilities?.search ?? false,
|
||||
actions: capabilities?.actions ?? [],
|
||||
projectCount: projectCounts.get(result.host) ?? 1,
|
||||
configured: result.viewer !== null,
|
||||
detail: result.error === null ? null : providerDetail(result.error),
|
||||
};
|
||||
}),
|
||||
...[...unimplemented].map(([host, { kind, projectCount }]) => ({
|
||||
host,
|
||||
kind,
|
||||
searchesOnHost: false,
|
||||
actions: [],
|
||||
projectCount,
|
||||
configured: false,
|
||||
detail: "This host cannot be browsed here yet.",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { PullRequestAction } from "@t3tools/contracts";
|
||||
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
|
||||
import { SearchIcon } from "lucide-react";
|
||||
import { PullRequestStackPopover } from "./PullRequestStackPopover";
|
||||
@@ -91,6 +92,7 @@ function PullRequestRowImpl({
|
||||
statsRef,
|
||||
onSelect,
|
||||
speedMode,
|
||||
hostActions,
|
||||
onActed,
|
||||
closing = false,
|
||||
sweeping = false,
|
||||
@@ -113,6 +115,8 @@ function PullRequestRowImpl({
|
||||
statsRef?: RefCallback<HTMLDivElement>;
|
||||
onSelect: (entry: PullRequestRowTarget) => void;
|
||||
speedMode: boolean;
|
||||
/** What this row's host can do, which is what speed mode offers. */
|
||||
hostActions: ReadonlySet<PullRequestAction>;
|
||||
onActed: (result: PullRequestSpeedActionResult) => void;
|
||||
closing?: boolean;
|
||||
sweeping?: boolean;
|
||||
@@ -256,9 +260,10 @@ function PullRequestRowImpl({
|
||||
updatedAt={entry.updatedAt}
|
||||
/>
|
||||
</button>
|
||||
{entry.state !== "merged" && entry.provider === "github" ? (
|
||||
{hostActions.size > 0 ? (
|
||||
<PullRequestSpeedActions
|
||||
entry={entry}
|
||||
hostActions={hostActions}
|
||||
visible={speedMode}
|
||||
onActed={onActed}
|
||||
closing={closing}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Spinner } from "../ui/spinner";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
|
||||
import { resolvePullRequestMergeMethod } from "./pullRequestDetail.logic";
|
||||
import { PullRequestGlyph } from "./pullRequestIcons";
|
||||
import type { EnvironmentPullRequestEntry } from "./pullRequestList.logic";
|
||||
import { pullRequestQuickActions, type EnvironmentPullRequestEntry } from "./pullRequestList.logic";
|
||||
import {
|
||||
usePullRequestActionRunner,
|
||||
usePullRequestDefaultMergeMethodResolver,
|
||||
@@ -26,6 +26,7 @@ export interface PullRequestSpeedActionResult<Entry = EnvironmentPullRequestEntr
|
||||
/** No detail or stack reads until a merge is clicked, even on a long list. */
|
||||
export function PullRequestSpeedActions<Entry extends PullRequestSpeedActionEntry>({
|
||||
entry,
|
||||
hostActions,
|
||||
visible,
|
||||
onActed,
|
||||
closing = false,
|
||||
@@ -33,6 +34,8 @@ export function PullRequestSpeedActions<Entry extends PullRequestSpeedActionEntr
|
||||
onCloseSweepStart,
|
||||
}: {
|
||||
entry: Entry;
|
||||
/** What the row's host can do; actions it cannot are not offered. */
|
||||
hostActions: ReadonlySet<PullRequestAction>;
|
||||
visible: boolean;
|
||||
onActed?: (result: PullRequestSpeedActionResult<Entry>) => void;
|
||||
closing?: boolean;
|
||||
@@ -70,13 +73,9 @@ export function PullRequestSpeedActions<Entry extends PullRequestSpeedActionEntr
|
||||
);
|
||||
},
|
||||
});
|
||||
const actions =
|
||||
entry.state === "closed"
|
||||
? (["reopen"] as const)
|
||||
: entry.isDraft
|
||||
? (["close", "ready"] as const)
|
||||
: (["close", "merge"] as const);
|
||||
const actions = pullRequestQuickActions(entry, hostActions);
|
||||
const busy = actionPending || closing || sweeping;
|
||||
if (actions.length === 0) return null;
|
||||
return (
|
||||
<div
|
||||
className="shrink-0 items-center gap-1 pr-3"
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import type { ProjectId, ScopedThreadRef, ThreadPullRequestLink } from "@t3tools/contracts";
|
||||
import { detectSourceControlProviderFromRemoteUrl } from "@t3tools/shared/sourceControl";
|
||||
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
|
||||
import {
|
||||
sourceControlClients,
|
||||
UNKNOWN_SOURCE_CONTROL_CLIENT,
|
||||
} from "@t3tools/client-runtime/source-control-clients";
|
||||
import {
|
||||
resolveThreadPullRequestChains,
|
||||
visibleThreadPullRequests,
|
||||
@@ -45,6 +47,7 @@ import {
|
||||
pullRequestChecksStatePresentation,
|
||||
} from "./pullRequestPresentation";
|
||||
import { PullRequestGlyph } from "./pullRequestIcons";
|
||||
import { pullRequestQuickActions } from "./pullRequestList.logic";
|
||||
import { PullRequestSpeedActions } from "./PullRequestSpeedActions";
|
||||
|
||||
const SOURCE_LABELS: Record<ThreadPullRequestLink["source"], string> = {
|
||||
@@ -105,11 +108,12 @@ function LinkRow({
|
||||
const snapshot = link.snapshot;
|
||||
const open = snapshot === null || snapshot.state === "open";
|
||||
const watching = link.watch !== undefined;
|
||||
// A link carries no host summary, so the host's own definition says what it can do.
|
||||
const linkHostActions = (
|
||||
sourceControlClients.findByChangeRequestUrl(link.url) ?? UNKNOWN_SOURCE_CONTROL_CLIENT
|
||||
).changeRequestActions;
|
||||
const actionEntry =
|
||||
projectId !== null &&
|
||||
snapshot !== null &&
|
||||
snapshot.state !== "merged" &&
|
||||
detectSourceControlProviderFromRemoteUrl(link.url)?.kind === "github"
|
||||
projectId !== null && snapshot !== null && snapshot.state !== "merged"
|
||||
? {
|
||||
environmentId: threadRef.environmentId,
|
||||
projectId,
|
||||
@@ -121,6 +125,9 @@ function LinkRow({
|
||||
...(link.stack === null ? {} : { stack: link.stack }),
|
||||
}
|
||||
: null;
|
||||
// Speed mode swaps the menu for quick actions only where a row has some to offer.
|
||||
const hasQuickActions =
|
||||
actionEntry !== null && pullRequestQuickActions(actionEntry, linkHostActions).length > 0;
|
||||
return (
|
||||
<div
|
||||
className={cn(PULL_REQUEST_ROW_CLASS, "relative hover:bg-accent/60")}
|
||||
@@ -246,7 +253,11 @@ function LinkRow({
|
||||
/>
|
||||
</a>
|
||||
{actionEntry !== null ? (
|
||||
<PullRequestSpeedActions entry={actionEntry} visible={speedMode} />
|
||||
<PullRequestSpeedActions
|
||||
entry={actionEntry}
|
||||
hostActions={linkHostActions}
|
||||
visible={speedMode}
|
||||
/>
|
||||
) : null}
|
||||
{/* Out of the row's flow, so no row reserves a column for a button only the hovered one
|
||||
shows. It sits over the right end of the second line on the row's own hover color,
|
||||
@@ -261,7 +272,7 @@ function LinkRow({
|
||||
"has-[[data-popup-open]]:pointer-events-auto has-[[data-popup-open]]:opacity-100",
|
||||
"has-[:focus-visible]:pointer-events-auto has-[:focus-visible]:opacity-100",
|
||||
"group-has-[[data-pull-request-action-pending=true]]/pr-row:hidden",
|
||||
speedMode && actionEntry !== null && "hidden",
|
||||
speedMode && hasQuickActions && "hidden",
|
||||
)}
|
||||
>
|
||||
<span aria-hidden className="absolute inset-0 bg-accent/60" />
|
||||
|
||||
@@ -103,6 +103,7 @@ function row(overrides: Partial<EnvironmentPullRequestEntry>): ReactNode {
|
||||
showProvider: false,
|
||||
onSelect: () => {},
|
||||
speedMode: false,
|
||||
hostActions: new Set(),
|
||||
onActed: () => {},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
import { SourceControlProviderKind } from "@t3tools/contracts";
|
||||
import type { EnvironmentId, ProjectId, PullRequestListEntry } from "@t3tools/contracts";
|
||||
import type {
|
||||
EnvironmentId,
|
||||
ProjectId,
|
||||
PullRequestAction,
|
||||
PullRequestListEntry,
|
||||
} from "@t3tools/contracts";
|
||||
import { describe, expect, it } from "vite-plus/test";
|
||||
|
||||
import {
|
||||
pullRequestHostActions,
|
||||
pullRequestQuickActions,
|
||||
filterPullRequestsByInvolvement,
|
||||
findScopedProject,
|
||||
mergePullRequestLists,
|
||||
@@ -1720,3 +1727,35 @@ describe("pull request list override settlement", () => {
|
||||
expect(swapped.map((row) => row.number)).toEqual([2, 1]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("pull request quick actions", () => {
|
||||
const summary = (host: string, kind: string, actions?: ReadonlyArray<PullRequestAction>) => ({
|
||||
host,
|
||||
kind: SourceControlProviderKind.make(kind),
|
||||
searchesOnHost: true,
|
||||
projectCount: 1,
|
||||
configured: true,
|
||||
detail: null,
|
||||
...(actions === undefined ? {} : { actions }),
|
||||
});
|
||||
|
||||
it("offers what each host reports, and GitHub's legacy set when a server reports none", () => {
|
||||
const actionsOf = pullRequestHostActions([
|
||||
summary("bitbucket.org", "bitbucket", ["merge", "close"]),
|
||||
summary("github.com", "github"),
|
||||
]);
|
||||
const bitbucket = actionsOf({
|
||||
host: "bitbucket.org",
|
||||
provider: SourceControlProviderKind.make("bitbucket"),
|
||||
});
|
||||
expect(pullRequestQuickActions({ state: "closed", isDraft: false }, bitbucket)).toEqual([]);
|
||||
const github = actionsOf({
|
||||
host: "github.com",
|
||||
provider: SourceControlProviderKind.make("github"),
|
||||
});
|
||||
expect(pullRequestQuickActions({ state: "open", isDraft: true }, github)).toEqual([
|
||||
"close",
|
||||
"ready",
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -1262,3 +1262,45 @@ export function settlePullRequestOverrides<Entry extends PullRequestListEntry>(
|
||||
}
|
||||
return kept.size === overrides.size ? overrides : kept;
|
||||
}
|
||||
|
||||
/** The row actions speed mode offers, in the order they are drawn. */
|
||||
export type PullRequestQuickAction = "close" | "merge" | "ready" | "reopen";
|
||||
|
||||
/**
|
||||
* Which actions each host can take on a listed row, before any row's detail is read. Hosts are
|
||||
* matched by the host summary; a server that does not report actions per host only ever offered
|
||||
* these on GitHub, so that is what it keeps getting.
|
||||
*/
|
||||
export function pullRequestHostActions(
|
||||
providers: ReadonlyArray<PullRequestListResult["providers"][number]>,
|
||||
): (
|
||||
entry: Pick<EnvironmentPullRequestEntry, "host" | "provider">,
|
||||
) => ReadonlySet<PullRequestAction> {
|
||||
const byHost = new Map(
|
||||
providers.flatMap((provider) =>
|
||||
provider.actions === undefined
|
||||
? []
|
||||
: [[provider.host.toLowerCase(), new Set(provider.actions)] as const],
|
||||
),
|
||||
);
|
||||
const legacy = new Set<PullRequestAction>(["close", "merge", "ready", "reopen"]);
|
||||
const none = new Set<PullRequestAction>();
|
||||
return (entry) =>
|
||||
byHost.get(entry.host.toLowerCase()) ?? (entry.provider === "github" ? legacy : none);
|
||||
}
|
||||
|
||||
/** The quick actions a row offers: what its state allows, narrowed to what its host can do. */
|
||||
export function pullRequestQuickActions(
|
||||
entry: Pick<EnvironmentPullRequestEntry, "state" | "isDraft">,
|
||||
hostActions: ReadonlySet<PullRequestAction>,
|
||||
): ReadonlyArray<PullRequestQuickAction> {
|
||||
const forState: ReadonlyArray<PullRequestQuickAction> =
|
||||
entry.state === "merged"
|
||||
? []
|
||||
: entry.state === "closed"
|
||||
? ["reopen"]
|
||||
: entry.isDraft
|
||||
? ["close", "ready"]
|
||||
: ["close", "merge"];
|
||||
return forState.filter((action) => hostActions.has(action));
|
||||
}
|
||||
@@ -186,8 +186,8 @@ export function usePullRequestCloseBatch(onClosed: (entry: EnvironmentPullReques
|
||||
async (entries: readonly EnvironmentPullRequestEntry[]) => {
|
||||
const batch = entries.filter((entry) => {
|
||||
const key = pullRequestEntryKey(entry);
|
||||
if (entry.state !== "open" || entry.provider !== "github" || pending.current.has(key))
|
||||
return false;
|
||||
// The sweep only gathers rows whose host can close them, so state is all that is left.
|
||||
if (entry.state !== "open" || pending.current.has(key)) return false;
|
||||
pending.current.add(key);
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -88,6 +88,7 @@ import {
|
||||
pullRequestOverrideAfterAction,
|
||||
reusePullRequestEntries,
|
||||
settlePullRequestOverrides,
|
||||
pullRequestHostActions,
|
||||
} from "../components/pullRequest/pullRequestList.logic";
|
||||
import {
|
||||
pullRequestListPreferences,
|
||||
@@ -1592,6 +1593,22 @@ function PullRequestsRouteView() {
|
||||
]);
|
||||
/** What is actually on screen once the reader's pending answers are on the rows. */
|
||||
const shownCount = displayGroups.reduce((count, group) => count + group.entries.length, 0);
|
||||
// The provider list is the workspace's hosts, not the filtered ones, so switching to a host
|
||||
// cannot make the switcher that got you there disappear.
|
||||
const [hosts, setHosts] = useState<PullRequestListResult["providers"]>([]);
|
||||
useEffect(() => {
|
||||
// Only from an answer to these filters. Rows carried over from the previous ones bring the
|
||||
// host summaries of the question they answered, and coming back from one host to all of them
|
||||
// would take the switcher's other hosts out of it on the strength of the narrowed answer.
|
||||
if (answered === null) return;
|
||||
// An unfiltered response is the full set of hosts. A filtered one only seeds the switcher
|
||||
// when there is nothing to seed it with, which is a link that arrived already scoped.
|
||||
setHosts((previous) =>
|
||||
search.host === undefined || previous.length === 0 ? answered.providers : previous,
|
||||
);
|
||||
}, [answered, search.host]);
|
||||
const showProvider = hosts.length > 1;
|
||||
const hostActionsOf = useMemo(() => pullRequestHostActions(hosts), [hosts]);
|
||||
const [closeSweepKeys, setCloseSweepKeys] = useState<ReadonlySet<string>>(() => new Set());
|
||||
const closeSensorRef = useRef<SidebarPointerSensor | null>(null);
|
||||
const closeSweepRows = useMemo(
|
||||
@@ -1605,8 +1622,14 @@ function PullRequestsRouteView() {
|
||||
),
|
||||
[displayGroups],
|
||||
);
|
||||
const closeSweepRef = useRef({ displayGroups, closeSweepRows, closingKeys, closeBatch });
|
||||
closeSweepRef.current = { displayGroups, closeSweepRows, closingKeys, closeBatch };
|
||||
const closeSweepRef = useRef({
|
||||
displayGroups,
|
||||
closeSweepRows,
|
||||
closingKeys,
|
||||
closeBatch,
|
||||
hostActionsOf,
|
||||
});
|
||||
closeSweepRef.current = { displayGroups, closeSweepRows, closingKeys, closeBatch, hostActionsOf };
|
||||
useEffect(() => () => closeSensorRef.current?.cancel(), [filterKey, search.q, sort]);
|
||||
useEffect(() => {
|
||||
const onKeyDown = (event: KeyboardEvent) => {
|
||||
@@ -1632,7 +1655,7 @@ function PullRequestsRouteView() {
|
||||
return (
|
||||
row?.groupKey === group.key &&
|
||||
row.entry.state === "open" &&
|
||||
row.entry.provider === "github" &&
|
||||
closeSweepRef.current.hostActionsOf(row.entry).has("close") &&
|
||||
!closeSweepRef.current.closingKeys.has(key) &&
|
||||
!scrollRef.current?.querySelector(
|
||||
`[data-pull-request-key="${CSS.escape(key)}"] [data-pull-request-action-pending="true"]`,
|
||||
@@ -1766,21 +1789,6 @@ function PullRequestsRouteView() {
|
||||
selectSurfaceInUrl(selectedPullRequestSurface);
|
||||
};
|
||||
|
||||
// The provider list is the workspace's hosts, not the filtered ones, so switching to a host
|
||||
// cannot make the switcher that got you there disappear.
|
||||
const [hosts, setHosts] = useState<PullRequestListResult["providers"]>([]);
|
||||
useEffect(() => {
|
||||
// Only from an answer to these filters. Rows carried over from the previous ones bring the
|
||||
// host summaries of the question they answered, and coming back from one host to all of them
|
||||
// would take the switcher's other hosts out of it on the strength of the narrowed answer.
|
||||
if (answered === null) return;
|
||||
// An unfiltered response is the full set of hosts. A filtered one only seeds the switcher
|
||||
// when there is nothing to seed it with, which is a link that arrived already scoped.
|
||||
setHosts((previous) =>
|
||||
search.host === undefined || previous.length === 0 ? answered.providers : previous,
|
||||
);
|
||||
}, [answered, search.host]);
|
||||
const showProvider = hosts.length > 1;
|
||||
// The workspace's own projects already name their hosts, so the row's shape is known before
|
||||
// the list is. Only its shape: which hosts can actually be read still comes from the server.
|
||||
const expectedHosts = useMemo(() => {
|
||||
@@ -1942,6 +1950,7 @@ function PullRequestsRouteView() {
|
||||
}
|
||||
onSelect={selectEntry}
|
||||
speedMode={speedMode}
|
||||
hostActions={hostActionsOf(entry)}
|
||||
onActed={onSpeedAction}
|
||||
closing={closingKeys.has(entryKey)}
|
||||
sweeping={closeSweepKeys.has(entryKey)}
|
||||
|
||||
@@ -634,6 +634,11 @@ export const PullRequestProviderSummary = Schema.Struct({
|
||||
kind: SourceControlProviderKind,
|
||||
/** False where a search has to be applied to the rows after they arrive. */
|
||||
searchesOnHost: Schema.Boolean,
|
||||
/**
|
||||
* The actions this host can carry out, so a row can offer them before its detail is read.
|
||||
* Absent from servers older than this field; clients then offer what they always did.
|
||||
*/
|
||||
actions: Schema.optional(Schema.Array(PullRequestAction)),
|
||||
projectCount: PositiveInt,
|
||||
/** False when the provider's CLI or credentials are missing, with `detail` saying which. */
|
||||
configured: Schema.Boolean,
|
||||
|
||||
@@ -40,6 +40,15 @@ export const definition = defineSourceControlClient({
|
||||
defaultCloneTransport: "ssh",
|
||||
changeRequestUrl: ({ host, repository, number }) =>
|
||||
`https://${canonicalRepositoryKey(`${host}/${repository}`.toLowerCase())}/pullrequest/${number}`,
|
||||
changeRequestActions: new Set([
|
||||
"merge",
|
||||
"ready",
|
||||
"draft",
|
||||
"close",
|
||||
"reopen",
|
||||
"enable-auto-merge",
|
||||
"disable-auto-merge",
|
||||
] as const),
|
||||
checkoutCommand: ({ number }) => `az repos pr checkout --id ${number}`,
|
||||
authorProfileUrl: () => null,
|
||||
referenceAutolinkRepositoryUrl: () => null,
|
||||
|
||||
@@ -33,6 +33,7 @@ import type {
|
||||
AzureDevOpsPullRequest,
|
||||
AzureDevOpsRepositoryLocation,
|
||||
} from "./azureDevOpsPullRequestJson.ts";
|
||||
import { definition } from "../client/definition.ts";
|
||||
|
||||
/**
|
||||
* How many of a slice's files are read at once. Every file is two `az` invocations, each paying a
|
||||
@@ -60,15 +61,7 @@ const CAPABILITIES: PullRequestCapabilities = {
|
||||
// Reading a conversation is a plain REST read, but posting one is not something this can
|
||||
// claim without having run it, so the composer stays hidden.
|
||||
comment: false,
|
||||
actions: [
|
||||
"merge",
|
||||
"ready",
|
||||
"draft",
|
||||
"close",
|
||||
"reopen",
|
||||
"enable-auto-merge",
|
||||
"disable-auto-merge",
|
||||
],
|
||||
actions: [...definition.changeRequestActions],
|
||||
// Azure squashes as a completion option; it has no rebase strategy of its own.
|
||||
mergeMethods: ["merge", "squash"],
|
||||
// `az repos pr list` filters by status, creator, reviewer and branch, and by no text at all.
|
||||
|
||||
@@ -29,6 +29,9 @@ export const definition = defineSourceControlClient({
|
||||
defaultCloneTransport: "ssh",
|
||||
changeRequestUrl: ({ host, repository, number }) =>
|
||||
`https://${host}/${repository}/pull-requests/${number}`,
|
||||
// No endpoint reopens a declined pull request, and nothing documented moves one in or out of
|
||||
// draft, so neither is offered rather than failing when pressed.
|
||||
changeRequestActions: new Set(["merge", "close"] as const),
|
||||
// Bitbucket has no checkout CLI, so clone the head branch from its own repository.
|
||||
checkoutCommand: ({ number, headBranch, headRepositoryNameWithOwner }) =>
|
||||
headRepositoryNameWithOwner &&
|
||||
|
||||
@@ -12,13 +12,12 @@ import {
|
||||
type PullRequestProviderApi,
|
||||
} from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
import type { BitbucketPullRequest } from "./bitbucketPullRequestJson.ts";
|
||||
import { definition } from "../client/definition.ts";
|
||||
|
||||
const CAPABILITIES: PullRequestCapabilities = {
|
||||
diff: true,
|
||||
comment: true,
|
||||
// Bitbucket has no endpoint that reopens a declined pull request, and nothing documented that
|
||||
// moves one in or out of draft, so neither is offered rather than failing when pressed.
|
||||
actions: ["merge", "close"],
|
||||
actions: [...definition.changeRequestActions],
|
||||
mergeMethods: ["merge", "squash", "rebase"],
|
||||
search: true,
|
||||
// Bitbucket Cloud's API exposes no reaction on a pull request or on a comment, so none is
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
* @module source-control-core/client/definition
|
||||
*/
|
||||
import {
|
||||
type PullRequestAction,
|
||||
pullRequestHostOf,
|
||||
type PullRequestReviewVerdict,
|
||||
type RepositoryIdentity,
|
||||
@@ -77,6 +78,12 @@ export interface SourceControlClientDefinition {
|
||||
readonly defaultCloneTransport: "https" | "ssh";
|
||||
/** The web URL of a change request, or null when this client cannot build one for the host. */
|
||||
readonly changeRequestUrl: (input: ChangeRequestUrlInput) => string | null;
|
||||
/**
|
||||
* The actions this host can take on a change request, the same list its server provider
|
||||
* declares in `capabilities.actions`. Surfaces with no server answer to hand, such as a thread's
|
||||
* linked pull requests, offer actions from this.
|
||||
*/
|
||||
readonly changeRequestActions: ReadonlySet<PullRequestAction>;
|
||||
/** A shell command that checks the change request out, or null when it cannot be built. */
|
||||
readonly checkoutCommand: (changeRequest: ChangeRequestCheckoutInput) => string | null;
|
||||
/** A comment author's profile page, or null where the host has none clients can link. */
|
||||
@@ -219,6 +226,7 @@ export const UNKNOWN_SOURCE_CONTROL_CLIENT: SourceControlClientDefinition = {
|
||||
publishHost: (signedInHost) => signedInHost ?? "your server",
|
||||
defaultCloneTransport: "ssh",
|
||||
changeRequestUrl: () => null,
|
||||
changeRequestActions: new Set(),
|
||||
checkoutCommand: () => null,
|
||||
authorProfileUrl: () => null,
|
||||
referenceAutolinkRepositoryUrl: () => null,
|
||||
|
||||
@@ -63,6 +63,7 @@ export const definition = defineSourceControlClient({
|
||||
}
|
||||
return `https://${host}/${repository}/pulls/${number}`;
|
||||
},
|
||||
changeRequestActions: new Set(["merge", "close", "reopen", "update-branch"] as const),
|
||||
// Neither `fj` nor `tea` checks out by number, so fetch the pull ref from the repository itself.
|
||||
checkoutCommand: ({ number, repositoryUrl }) =>
|
||||
repositoryUrl
|
||||
|
||||
@@ -33,12 +33,13 @@ import {
|
||||
forgejoChecks,
|
||||
forgejoReactions,
|
||||
} from "./forgejoPullRequestJson.ts";
|
||||
import { definition } from "../client/definition.ts";
|
||||
|
||||
const CAPABILITIES: PullRequestCapabilities = {
|
||||
diff: true,
|
||||
viewedFiles: "environment",
|
||||
comment: true,
|
||||
actions: ["merge", "close", "reopen", "update-branch"],
|
||||
actions: [...definition.changeRequestActions],
|
||||
mergeMethods: ["merge", "squash", "rebase"],
|
||||
updateMethods: ["merge", "rebase"],
|
||||
search: false,
|
||||
|
||||
@@ -31,6 +31,14 @@ export const definition = defineSourceControlClient({
|
||||
defaultCloneTransport: "ssh",
|
||||
changeRequestUrl: ({ host, repository, number }) =>
|
||||
`https://${host}/${repository}/pulls/${number}`,
|
||||
changeRequestActions: new Set([
|
||||
"ready",
|
||||
"draft",
|
||||
"close",
|
||||
"reopen",
|
||||
"merge",
|
||||
"update-branch",
|
||||
] as const),
|
||||
checkoutCommand: ({ number }) => `cafe pr checkout ${number}`,
|
||||
authorProfileUrl: () => null,
|
||||
referenceAutolinkRepositoryUrl: () => null,
|
||||
|
||||
@@ -18,11 +18,12 @@ import {
|
||||
import * as GitCafeApi from "./GitCafeApi.ts";
|
||||
import * as GitCafeHosts from "./gitCafeHosts.ts";
|
||||
import * as Json from "./gitCafePullRequestJson.ts";
|
||||
import { definition } from "../client/definition.ts";
|
||||
|
||||
const CAPABILITIES: PullRequestCapabilities = {
|
||||
diff: true,
|
||||
comment: true,
|
||||
actions: ["ready", "draft", "close", "reopen", "merge", "update-branch"],
|
||||
actions: [...definition.changeRequestActions],
|
||||
mergeMethods: ["merge", "squash", "rebase"],
|
||||
// Only through a stack: GitCafe's one branch update restacks every layer above it.
|
||||
updateMethods: ["rebase"],
|
||||
|
||||
@@ -30,6 +30,18 @@ export const definition = defineSourceControlClient({
|
||||
defaultCloneTransport: "https",
|
||||
changeRequestUrl: ({ host, repository, number }) =>
|
||||
`https://${host}/${repository}/pull/${number}`,
|
||||
changeRequestActions: new Set([
|
||||
"merge",
|
||||
"ready",
|
||||
"draft",
|
||||
"close",
|
||||
"reopen",
|
||||
"update-branch",
|
||||
"enable-auto-merge",
|
||||
"disable-auto-merge",
|
||||
"revert",
|
||||
"approve-workflows",
|
||||
] as const),
|
||||
checkoutCommand: ({ number }) => `gh pr checkout ${number}`,
|
||||
authorProfileUrl: (login, repositoryUrl) =>
|
||||
login.endsWith("[bot]")
|
||||
|
||||
@@ -20,22 +20,12 @@ import {
|
||||
type ProviderRepositoryRef,
|
||||
} from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
import type { GitHubViewerAccess, GitHubWorkflowRunApproval } from "./gitHubPullRequestJson.ts";
|
||||
import { definition } from "../client/definition.ts";
|
||||
|
||||
const CAPABILITIES: PullRequestCapabilities = {
|
||||
diff: true,
|
||||
comment: true,
|
||||
actions: [
|
||||
"merge",
|
||||
"ready",
|
||||
"draft",
|
||||
"close",
|
||||
"reopen",
|
||||
"update-branch",
|
||||
"enable-auto-merge",
|
||||
"disable-auto-merge",
|
||||
"revert",
|
||||
"approve-workflows",
|
||||
],
|
||||
actions: [...definition.changeRequestActions],
|
||||
mergeMethods: ["merge", "squash", "rebase"],
|
||||
updateMethods: ["merge", "rebase"],
|
||||
search: true,
|
||||
|
||||
@@ -30,6 +30,16 @@ export const definition = defineSourceControlClient({
|
||||
defaultCloneTransport: "ssh",
|
||||
changeRequestUrl: ({ host, repository, number }) =>
|
||||
`https://${host}/${repository}/-/merge_requests/${number}`,
|
||||
changeRequestActions: new Set([
|
||||
"merge",
|
||||
"ready",
|
||||
"draft",
|
||||
"close",
|
||||
"reopen",
|
||||
"update-branch",
|
||||
"enable-auto-merge",
|
||||
"disable-auto-merge",
|
||||
] as const),
|
||||
checkoutCommand: ({ number }) => `glab mr checkout ${number}`,
|
||||
authorProfileUrl: () => null,
|
||||
referenceAutolinkRepositoryUrl: () => null,
|
||||
|
||||
@@ -14,20 +14,12 @@ import {
|
||||
type ProviderChangeRequestDetail,
|
||||
type PullRequestProviderApi,
|
||||
} from "@t3tools/source-control-core/server/PullRequestProvider";
|
||||
import { definition } from "../client/definition.ts";
|
||||
|
||||
const CAPABILITIES: PullRequestCapabilities = {
|
||||
diff: true,
|
||||
comment: true,
|
||||
actions: [
|
||||
"merge",
|
||||
"ready",
|
||||
"draft",
|
||||
"close",
|
||||
"reopen",
|
||||
"update-branch",
|
||||
"enable-auto-merge",
|
||||
"disable-auto-merge",
|
||||
],
|
||||
actions: [...definition.changeRequestActions],
|
||||
// GitLab offers all three, though a project settles on one; `mergeCapabilities` narrows it.
|
||||
mergeMethods: ["merge", "squash", "rebase"],
|
||||
// Rebase alone: GitLab moves a stale branch onto its target by replaying it, and has nothing
|
||||
|
||||
Reference in new issue
Block a user