ref0-git 0.2.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/apps/github/.dev.vars.example +2 -1
- package/app/apps/github/generated/git-rest.ts +191 -25
- package/app/apps/github/generated/routeTree.gen.ts +21 -0
- package/app/apps/github/package.json +1 -1
- package/app/apps/github/src/branches/branch-list.tsx +8 -4
- package/app/apps/github/src/branches/branches.ts +10 -5
- package/app/apps/github/src/camo/addresses.ts +120 -0
- package/app/apps/github/src/camo/client.ts +125 -0
- package/app/apps/github/src/camo/fetch.ts +201 -0
- package/app/apps/github/src/camo/lookup.ts +23 -0
- package/app/apps/github/src/camo/node.ts +50 -0
- package/app/apps/github/src/camo/proxy.ts +116 -0
- package/app/apps/github/src/camo/sign-images.ts +307 -0
- package/app/apps/github/src/camo/signing.ts +80 -0
- package/app/apps/github/src/clients/allowed.ts +111 -18
- package/app/apps/github/src/clients/clients.ts +76 -61
- package/app/apps/github/src/clients/transport.ts +13 -0
- package/app/apps/github/src/code/code-tree.tsx +3 -1
- package/app/apps/github/src/code/file-view.tsx +15 -6
- package/app/apps/github/src/code/files.ts +26 -19
- package/app/apps/github/src/code/go-to-file.tsx +2 -1
- package/app/apps/github/src/code/load.ts +41 -23
- package/app/apps/github/src/code/markdown-files.ts +13 -2
- package/app/apps/github/src/code/ref-pages.ts +14 -5
- package/app/apps/github/src/code/ref-switcher.tsx +4 -3
- package/app/apps/github/src/code/refs.ts +42 -8
- package/app/apps/github/src/code/repo-home.tsx +6 -2
- package/app/apps/github/src/code/repo.ts +12 -6
- package/app/apps/github/src/code/saved.ts +5 -3
- package/app/apps/github/src/code/trees.ts +11 -9
- package/app/apps/github/src/components/markdown/markdown.css +6 -0
- package/app/apps/github/src/components/markdown/markdown.tsx +95 -10
- package/app/apps/github/src/components/owner-card.tsx +3 -1
- package/app/apps/github/src/components/repos/your-repos.tsx +3 -1
- package/app/apps/github/src/components/shell/owner-repos.tsx +7 -12
- package/app/apps/github/src/components/shell/repo-switcher.tsx +10 -16
- package/app/apps/github/src/components/signin/device-card.tsx +9 -2
- package/app/apps/github/src/components/user-avatar.tsx +2 -1
- package/app/apps/github/src/context/context.ts +13 -0
- package/app/apps/github/src/diffs/blobs.ts +37 -14
- package/app/apps/github/src/diffs/diff-job.ts +53 -0
- package/app/apps/github/src/diffs/diff-worker.ts +6 -0
- package/app/apps/github/src/diffs/diffing.ts +136 -0
- package/app/apps/github/src/diffs/files.ts +4 -3
- package/app/apps/github/src/diffs/hunks.tsx +101 -53
- package/app/apps/github/src/diffs/patch.ts +20 -11
- package/app/apps/github/src/history/commit-diff.ts +10 -5
- package/app/apps/github/src/history/commit-list.tsx +3 -1
- package/app/apps/github/src/history/commit-page.tsx +4 -2
- package/app/apps/github/src/history/history.ts +12 -10
- package/app/apps/github/src/hooks/allowed.ts +9 -9
- package/app/apps/github/src/hooks/avatars.ts +3 -3
- package/app/apps/github/src/hooks/open-counts.ts +5 -4
- package/app/apps/github/src/hooks/profiles.ts +26 -12
- package/app/apps/github/src/hooks/repos.ts +78 -25
- package/app/apps/github/src/inbox/count.ts +30 -29
- package/app/apps/github/src/inbox/inbox-item.tsx +3 -1
- package/app/apps/github/src/inbox/inbox-page.tsx +5 -2
- package/app/apps/github/src/inbox/marks.ts +26 -15
- package/app/apps/github/src/inbox/release-tags.ts +7 -6
- package/app/apps/github/src/inbox/subjects.ts +5 -4
- package/app/apps/github/src/inbox/subscription-controls.tsx +14 -5
- package/app/apps/github/src/inbox/subscriptions.ts +95 -35
- package/app/apps/github/src/inbox/threads.ts +6 -6
- package/app/apps/github/src/issues/changes.ts +40 -16
- package/app/apps/github/src/issues/counts.ts +8 -5
- package/app/apps/github/src/issues/issue-list.tsx +20 -6
- package/app/apps/github/src/issues/issue-page.tsx +30 -14
- package/app/apps/github/src/issues/issues.ts +195 -46
- package/app/apps/github/src/issues/label-dialog.tsx +8 -11
- package/app/apps/github/src/issues/labels-page.tsx +35 -3
- package/app/apps/github/src/issues/milestone-dialog.tsx +197 -0
- package/app/apps/github/src/issues/milestones-page.tsx +269 -0
- package/app/apps/github/src/issues/new-issue.tsx +3 -1
- package/app/apps/github/src/issues/sidebar.tsx +8 -6
- package/app/apps/github/src/markdown/README.md +22 -17
- package/app/apps/github/src/markdown/context.ts +83 -10
- package/app/apps/github/src/markdown/images.ts +3 -2
- package/app/apps/github/src/markdown/lookup.ts +17 -11
- package/app/apps/github/src/markdown/page-budget.ts +50 -0
- package/app/apps/github/src/markdown/patches.ts +74 -32
- package/app/apps/github/src/markdown/query.ts +7 -2
- package/app/apps/github/src/markdown/remote.ts +106 -0
- package/app/apps/github/src/markdown/render.ts +101 -24
- package/app/apps/github/src/markdown/texts.ts +43 -0
- package/app/apps/github/src/markdown/words-module.d.ts +5 -0
- package/app/apps/github/src/markdown/words-plugin.ts +135 -0
- package/app/apps/github/src/names/repos.ts +1 -1
- package/app/apps/github/src/palette/palette.tsx +28 -10
- package/app/apps/github/src/palette/rows.tsx +93 -40
- package/app/apps/github/src/palette/server.ts +10 -7
- package/app/apps/github/src/palette/targets.ts +1 -0
- package/app/apps/github/src/policy.ts +137 -61
- package/app/apps/github/src/private-repos.ts +5 -5
- package/app/apps/github/src/pulls/compare-page.tsx +6 -3
- package/app/apps/github/src/pulls/files-tab.tsx +480 -214
- package/app/apps/github/src/pulls/held-summary.ts +178 -0
- package/app/apps/github/src/pulls/live.ts +6 -4
- package/app/apps/github/src/pulls/merge-box.tsx +17 -10
- package/app/apps/github/src/pulls/pull-list.tsx +6 -3
- package/app/apps/github/src/pulls/pull-page.tsx +19 -10
- package/app/apps/github/src/pulls/pull.ts +68 -40
- package/app/apps/github/src/pulls/pulls.ts +39 -22
- package/app/apps/github/src/pulls/review-drafts.ts +131 -0
- package/app/apps/github/src/pulls/review.ts +374 -99
- package/app/apps/github/src/pulls/threads.tsx +152 -0
- package/app/apps/github/src/queue/queue-page.tsx +15 -8
- package/app/apps/github/src/queue/queue.ts +35 -20
- package/app/apps/github/src/releases/latest-release.tsx +3 -1
- package/app/apps/github/src/releases/overview.tsx +4 -2
- package/app/apps/github/src/releases/release-form.tsx +8 -5
- package/app/apps/github/src/releases/release-list.tsx +8 -5
- package/app/apps/github/src/releases/release-view.tsx +1 -0
- package/app/apps/github/src/releases/releases.ts +33 -23
- package/app/apps/github/src/releases/tag-list.tsx +3 -1
- package/app/apps/github/src/router.tsx +5 -2
- package/app/apps/github/src/routes/$owner/$repo/_code/blob/$.tsx +7 -1
- package/app/apps/github/src/routes/$owner/$repo/_code/tree/$.tsx +6 -1
- package/app/apps/github/src/routes/$owner/$repo/_releases/releases/index.tsx +2 -1
- package/app/apps/github/src/routes/$owner/$repo/_releases/tags.tsx +1 -1
- package/app/apps/github/src/routes/$owner/$repo/branches.tsx +5 -1
- package/app/apps/github/src/routes/$owner/$repo/commit/$sha.tsx +1 -1
- package/app/apps/github/src/routes/$owner/$repo/commits/$.tsx +6 -1
- package/app/apps/github/src/routes/$owner/$repo/index.tsx +1 -1
- package/app/apps/github/src/routes/$owner/$repo/issues/$number.tsx +4 -2
- package/app/apps/github/src/routes/$owner/$repo/issues/index.tsx +2 -2
- package/app/apps/github/src/routes/$owner/$repo/issues/new.tsx +5 -2
- package/app/apps/github/src/routes/$owner/$repo/labels.tsx +2 -1
- package/app/apps/github/src/routes/$owner/$repo/milestones.tsx +36 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/route.tsx +4 -2
- package/app/apps/github/src/routes/$owner/$repo/pulls/index.tsx +2 -2
- package/app/apps/github/src/routes/$owner/$repo/queue.tsx +2 -1
- package/app/apps/github/src/routes/$owner/$repo/releases/edit/$.tsx +5 -2
- package/app/apps/github/src/routes/$owner/$repo/releases/new.tsx +2 -1
- package/app/apps/github/src/routes/$owner/$repo/releases/tag/$.tsx +4 -2
- package/app/apps/github/src/routes/$owner/$repo/route.tsx +9 -5
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/index.tsx +3 -1
- package/app/apps/github/src/routes/$owner/$repo/settings/index.tsx +3 -1
- package/app/apps/github/src/routes/-nav.tsx +10 -2
- package/app/apps/github/src/routes/-root-testing.ts +29 -6
- package/app/apps/github/src/routes/__root.tsx +9 -4
- package/app/apps/github/src/routes/index.tsx +3 -1
- package/app/apps/github/src/routes/orgs/$owner/route.tsx +4 -1
- package/app/apps/github/src/routes/orgs/$owner/settings.tsx +4 -1
- package/app/apps/github/src/seed/acme.ts +1 -1
- package/app/apps/github/src/seed/seed.ts +199 -120
- package/app/apps/github/src/server.ts +24 -15
- package/app/apps/github/src/settings/account-avatar.tsx +4 -1
- package/app/apps/github/src/settings/general-settings.tsx +3 -1
- package/app/apps/github/src/settings/general.ts +4 -4
- package/app/apps/github/src/settings/hook-form.tsx +3 -1
- package/app/apps/github/src/settings/hook-list.tsx +5 -2
- package/app/apps/github/src/settings/hooks.ts +7 -7
- package/app/apps/github/src/settings/org-settings.tsx +3 -1
- package/app/apps/github/src/settings/orgs.ts +21 -11
- package/app/apps/github/src/settings/settings-layout.tsx +3 -1
- package/app/apps/github/src/signin/approval.ts +4 -3
- package/app/apps/github/src/signin/auth.ts +9 -2
- package/app/apps/github/src/signin/device-code.ts +8 -3
- package/app/apps/github/src/signin/device-prompt.ts +28 -3
- package/app/apps/github/src/signin/revoke.ts +36 -0
- package/app/apps/github/tsconfig.json +4 -1
- package/app/apps/github/vite.config.ts +8 -0
- package/app/pnpm-workspace.yaml +9 -5
- package/app/tsconfig.base.json +1 -0
- package/dist/cli/child.mjs +1 -1
- package/dist/cli/credentials.mjs +4 -4
- package/dist/cli/documents.mjs +32 -22
- package/dist/cli/events.mjs +1 -1
- package/dist/cli/failure.mjs +20 -7
- package/dist/cli/folders.mjs +2 -2
- package/dist/cli/git-remote-ref0.mjs +47 -22
- package/dist/cli/git.mjs +26 -5
- package/dist/cli/helpers.mjs +168 -35
- package/dist/cli/hosts.mjs +3 -3
- package/dist/cli/output.mjs +2 -2
- package/dist/cli/prompt.mjs +1 -1
- package/dist/cli/queue.mjs +7 -7
- package/dist/cli/ref0-git.mjs +2 -2
- package/dist/cli/repos.mjs +35 -18
- package/dist/cli/resources.mjs +5 -5
- package/dist/cli/retry-after.mjs +8 -0
- package/dist/cli/setup.mjs +172 -66
- package/dist/cli/sign-in.mjs +65 -23
- package/dist/cli/sign-ins.mjs +70 -13
- package/dist/cli/sqlite.mjs +2 -2
- package/dist/cli/tokens.mjs +3 -3
- package/dist/cli/vendor.mjs +1 -1
- package/dist/init/app.mjs +18 -20
- package/dist/init/choices.mjs +1 -1
- package/dist/init/cloudflare.mjs +15 -19
- package/dist/init/create.mjs +4 -3
- package/dist/init/detect.mjs +4 -4
- package/dist/init/files.mjs +121 -9
- package/dist/init/frameworks.mjs +16 -0
- package/dist/init/git-module.mjs +22 -7
- package/dist/init/jsonc.mjs +9 -7
- package/dist/init/metadata.mjs +9 -3
- package/dist/init/mounts.mjs +13 -10
- package/dist/init/next.mjs +3 -5
- package/dist/init/node-app.mjs +3 -3
- package/dist/init/node.mjs +41 -42
- package/dist/init/nuxt.mjs +153 -27
- package/dist/init/stores.mjs +14 -9
- package/dist/init/sveltekit.mjs +4 -2
- package/dist/init/template.mjs +9 -6
- package/dist/init/templates.mjs +64 -48
- package/dist/init/vercel.mjs +37 -36
- package/dist/init/versions.mjs +3 -3
- package/package.json +6 -5
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import { useRouteContext } from '@tanstack/react-router';
|
|
3
|
+
import { ChevronRightIcon } from 'lucide-react';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
|
|
6
|
+
import { useClients } from '../clients/clients.ts';
|
|
7
|
+
import { Go } from '../code/controls.tsx';
|
|
8
|
+
import type { RepoPlace } from '../code/places.ts';
|
|
9
|
+
import { Button } from '../components/ui/button.tsx';
|
|
10
|
+
import {
|
|
11
|
+
Collapsible,
|
|
12
|
+
CollapsibleContent,
|
|
13
|
+
CollapsibleTrigger,
|
|
14
|
+
} from '../components/ui/collapsible.tsx';
|
|
15
|
+
import { Failed } from '../issues/issue-page.tsx';
|
|
16
|
+
import { pullHref } from './pull-list.tsx';
|
|
17
|
+
import { resolveThread, threadsOf, type ThreadState } from './review.ts';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Resolve conversation, or Unresolve it, for someone the drop-in lets. A click in flight disables
|
|
21
|
+
* it, so a second sends nothing; a refusal of any kind shows under it, the threads are read again,
|
|
22
|
+
* and the button comes back. The drop-in's answer is the thread's state from then on.
|
|
23
|
+
*/
|
|
24
|
+
function ResolveButton({
|
|
25
|
+
place,
|
|
26
|
+
pull,
|
|
27
|
+
thread,
|
|
28
|
+
}: {
|
|
29
|
+
readonly place: RepoPlace;
|
|
30
|
+
readonly pull: number;
|
|
31
|
+
readonly thread: ThreadState;
|
|
32
|
+
}) {
|
|
33
|
+
const clients = useClients();
|
|
34
|
+
const client = useQueryClient();
|
|
35
|
+
const key = threadsOf(clients, place, pull).queryKey;
|
|
36
|
+
const resolve = !thread.resolved;
|
|
37
|
+
const changed = useMutation({
|
|
38
|
+
mutationFn: () => resolveThread(clients, thread, resolve),
|
|
39
|
+
onSuccess: (state) => client.setQueryData(key, (held) => new Map(held).set(state.root, state)),
|
|
40
|
+
onError: () => client.invalidateQueries({ queryKey: key }),
|
|
41
|
+
});
|
|
42
|
+
// A refusal stays shown when the threads read after it takes the viewer's resolve away.
|
|
43
|
+
const allowed = resolve ? thread.canResolve : thread.canUnresolve;
|
|
44
|
+
if (!allowed && changed.error === null) return null;
|
|
45
|
+
|
|
46
|
+
const label = resolve ? 'Resolve conversation' : 'Unresolve conversation';
|
|
47
|
+
const sending = resolve ? 'Resolving…' : 'Unresolving…';
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<div className="flex flex-col gap-2">
|
|
51
|
+
{allowed && (
|
|
52
|
+
<Button
|
|
53
|
+
variant="outline"
|
|
54
|
+
size="sm"
|
|
55
|
+
className="self-start"
|
|
56
|
+
disabled={changed.isPending}
|
|
57
|
+
onClick={() => changed.mutate()}
|
|
58
|
+
>
|
|
59
|
+
{changed.isPending ? sending : label}
|
|
60
|
+
</Button>
|
|
61
|
+
)}
|
|
62
|
+
<Failed error={changed.error} />
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* A review thread with its resolve: open, with Resolve conversation under it, or resolved, folded
|
|
69
|
+
* to one line, `place` and who resolved it, as GitHub folds a resolved conversation. Folded, it's
|
|
70
|
+
* kept in the page for find in page. A thread the drop-in hasn't said the state of shows as it is.
|
|
71
|
+
*/
|
|
72
|
+
export function ResolvableThread({
|
|
73
|
+
repo,
|
|
74
|
+
pull,
|
|
75
|
+
thread,
|
|
76
|
+
place,
|
|
77
|
+
children,
|
|
78
|
+
}: {
|
|
79
|
+
readonly repo: RepoPlace;
|
|
80
|
+
readonly pull: number;
|
|
81
|
+
readonly thread: ThreadState | undefined;
|
|
82
|
+
/** Where the thread is, as its folded line says it: its path and lines. */
|
|
83
|
+
readonly place: string;
|
|
84
|
+
readonly children: ReactNode;
|
|
85
|
+
}) {
|
|
86
|
+
if (thread === undefined) return children;
|
|
87
|
+
|
|
88
|
+
const button = <ResolveButton place={repo} pull={pull} thread={thread} />;
|
|
89
|
+
if (!thread.resolved)
|
|
90
|
+
return (
|
|
91
|
+
<div className="flex flex-col gap-2">
|
|
92
|
+
{children}
|
|
93
|
+
{button}
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<Collapsible
|
|
99
|
+
aria-label={`Resolved thread on ${place}`}
|
|
100
|
+
render={<section />}
|
|
101
|
+
className="border bg-muted/30 font-sans text-sm whitespace-normal"
|
|
102
|
+
>
|
|
103
|
+
<CollapsibleTrigger
|
|
104
|
+
render={<Button variant="ghost" className="group w-full justify-start" />}
|
|
105
|
+
>
|
|
106
|
+
<ChevronRightIcon
|
|
107
|
+
data-icon="inline-start"
|
|
108
|
+
className="transition-transform group-data-panel-open:rotate-90"
|
|
109
|
+
/>
|
|
110
|
+
<span className="font-mono">{place}</span>
|
|
111
|
+
<span className="font-normal text-muted-foreground">
|
|
112
|
+
{thread.resolvedBy === undefined ? 'Resolved' : `Resolved by @${thread.resolvedBy}`}
|
|
113
|
+
</span>
|
|
114
|
+
<span className="ml-auto font-normal group-data-panel-open:hidden">Show resolved</span>
|
|
115
|
+
</CollapsibleTrigger>
|
|
116
|
+
<CollapsibleContent hiddenUntilFound className="flex flex-col gap-2 border-t p-2">
|
|
117
|
+
{children}
|
|
118
|
+
{button}
|
|
119
|
+
</CollapsibleContent>
|
|
120
|
+
</Collapsible>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The Conversation tab's line for a pull request's open review threads, linking to Files changed,
|
|
126
|
+
* where they're read and resolved. None open, none read yet, or a visitor, whom GraphQL doesn't
|
|
127
|
+
* answer, shows nothing.
|
|
128
|
+
*/
|
|
129
|
+
export function UnresolvedThreads({
|
|
130
|
+
place,
|
|
131
|
+
pull,
|
|
132
|
+
}: {
|
|
133
|
+
readonly place: RepoPlace;
|
|
134
|
+
readonly pull: number;
|
|
135
|
+
}) {
|
|
136
|
+
const clients = useClients();
|
|
137
|
+
const { viewer } = useRouteContext({ from: '__root__' });
|
|
138
|
+
const read = useQuery({ ...threadsOf(clients, place, pull), enabled: viewer !== null });
|
|
139
|
+
// A session that ended leaves the page holding what it read: a visitor's page shows none of it.
|
|
140
|
+
const threads = viewer === null ? undefined : read.data;
|
|
141
|
+
const open = [...(threads?.values() ?? [])].filter((thread) => !thread.resolved).length;
|
|
142
|
+
if (open === 0) return null;
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<p className="text-sm text-muted-foreground">
|
|
146
|
+
{open} unresolved {open === 1 ? 'thread' : 'threads'} ·{' '}
|
|
147
|
+
<Go href={`${pullHref(place, pull)}/files`} className="text-primary hover:underline">
|
|
148
|
+
View in Files changed
|
|
149
|
+
</Go>
|
|
150
|
+
</p>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
@@ -3,6 +3,7 @@ import { ListOrderedIcon, PauseIcon } from 'lucide-react';
|
|
|
3
3
|
import { useCallback, useState, type ReactNode } from 'react';
|
|
4
4
|
|
|
5
5
|
import { Go } from '../code/controls.tsx';
|
|
6
|
+
import { useClients } from '../clients/clients.ts';
|
|
6
7
|
import type { RepoPlace } from '../code/places.ts';
|
|
7
8
|
import { ConfirmAction } from '../components/confirm-action.tsx';
|
|
8
9
|
import { Alert, AlertDescription, AlertTitle } from '../components/ui/alert.tsx';
|
|
@@ -89,15 +90,16 @@ function EntryRow({
|
|
|
89
90
|
}) {
|
|
90
91
|
const pull = pullOfEntry(entry);
|
|
91
92
|
const source = entry.source.replace(/^refs\/heads\//, '');
|
|
93
|
+
const clients = useClients();
|
|
92
94
|
const client = useQueryClient();
|
|
93
95
|
// Only a pull request's entry goes through the drop-in; a host's own has no Remove here (Q527).
|
|
94
96
|
const remove = useQueueChange<void>(place, async () => {
|
|
95
|
-
if (pull !== undefined) await removePull(client, place, pull);
|
|
97
|
+
if (pull !== undefined) await removePull(clients, client, place, pull);
|
|
96
98
|
});
|
|
97
99
|
// Only a held entry has holds to read: its own, and those of entries it replaced.
|
|
98
100
|
const isHeld = entry.state === 'held';
|
|
99
101
|
const holds = useQuery({
|
|
100
|
-
...entryHolds(place, entry.id),
|
|
102
|
+
...entryHolds(clients, place, entry.id),
|
|
101
103
|
enabled: isHeld,
|
|
102
104
|
refetchInterval: queuePoll,
|
|
103
105
|
});
|
|
@@ -160,13 +162,16 @@ function EntryRow({
|
|
|
160
162
|
* once the viewer confirms, since with no checks required it can merge at once.
|
|
161
163
|
*/
|
|
162
164
|
function AddPull({ place }: { readonly place: RepoPlace }) {
|
|
165
|
+
const clients = useClients();
|
|
163
166
|
const client = useQueryClient();
|
|
164
167
|
const [number, setNumber] = useState('');
|
|
165
168
|
// Add with no number asks nothing of the drop-in, and says what's missing instead.
|
|
166
169
|
const [missing, setMissing] = useState(false);
|
|
167
|
-
const find = useMutation({
|
|
170
|
+
const find = useMutation({
|
|
171
|
+
mutationFn: (pull: number) => queueable(clients, client, place, pull),
|
|
172
|
+
});
|
|
168
173
|
const add = useQueueChange(place, async (pull: PullDetail) => {
|
|
169
|
-
await addPull(client, place, pull);
|
|
174
|
+
await addPull(clients, client, place, pull);
|
|
170
175
|
});
|
|
171
176
|
const focus = useCallback((button: HTMLButtonElement | null) => button?.focus(), []);
|
|
172
177
|
const found = find.data;
|
|
@@ -285,7 +290,8 @@ function Section({
|
|
|
285
290
|
|
|
286
291
|
/** The commits the queue is trying now, each with its checks as they run. */
|
|
287
292
|
function Candidates({ place }: { readonly place: RepoPlace }) {
|
|
288
|
-
const
|
|
293
|
+
const clients = useClients();
|
|
294
|
+
const candidates = useQuery({ ...queueCandidates(clients, place), refetchInterval: queuePoll });
|
|
289
295
|
if (candidates.error !== null) return <Failed error={candidates.error} />;
|
|
290
296
|
|
|
291
297
|
if (candidates.data === undefined) return <Skeleton className="h-16 w-full" />;
|
|
@@ -320,10 +326,11 @@ function Candidates({ place }: { readonly place: RepoPlace }) {
|
|
|
320
326
|
* and releasing for the host's own sign-in, which no session's token reaches.
|
|
321
327
|
*/
|
|
322
328
|
export function QueuePage({ place }: { readonly place: RepoPlace }) {
|
|
329
|
+
const clients = useClients();
|
|
323
330
|
const allowed = useAllowed(place).has('pull.merge');
|
|
324
|
-
const pages = useInfiniteQuery({ ...queueEntries(place), refetchInterval: queuePoll });
|
|
325
|
-
const holds = useQuery({ ...queueHolds(place), refetchInterval: queuePoll });
|
|
326
|
-
const titles = useQuery(queuedTitles(place)).data;
|
|
331
|
+
const pages = useInfiniteQuery({ ...queueEntries(clients, place), refetchInterval: queuePoll });
|
|
332
|
+
const holds = useQuery({ ...queueHolds(clients, place), refetchInterval: queuePoll });
|
|
333
|
+
const titles = useQuery(queuedTitles(clients, place)).data;
|
|
327
334
|
const entries = pages.data?.pages.flatMap((page) => page.entries) ?? [];
|
|
328
335
|
|
|
329
336
|
return (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { queryOptions, type QueryClient } from '@tanstack/react-query';
|
|
2
2
|
|
|
3
3
|
import type { components } from '../../generated/git-rest.ts';
|
|
4
|
-
import {
|
|
4
|
+
import type { Clients } from '../clients/clients.ts';
|
|
5
5
|
import type { RepoPlace } from '../code/places.ts';
|
|
6
6
|
import { everyNamedPage, everyPage, failure } from '../hooks/answers.ts';
|
|
7
7
|
import {
|
|
@@ -40,11 +40,11 @@ const firstPage: string | undefined = undefined;
|
|
|
40
40
|
* The queue's open entries, a page at a time as the reader asks for more: an empty first page
|
|
41
41
|
* when the host keeps no queue, as Git answers `NOT_FOUND` then.
|
|
42
42
|
*/
|
|
43
|
-
export const queueEntries = (place: RepoPlace) => ({
|
|
43
|
+
export const queueEntries = (clients: Clients, place: RepoPlace) => ({
|
|
44
44
|
queryKey: ['queue', place.owner, place.repo, 'entries'] as const,
|
|
45
45
|
queryFn: async ({ pageParam }: { readonly pageParam: string | undefined }) => {
|
|
46
46
|
const first = { target, limit: `${entriesPerPage}` };
|
|
47
|
-
const answer = await git.GET('/repos/{repo}/-/queue/entries', {
|
|
47
|
+
const answer = await clients.git.GET('/repos/{repo}/-/queue/entries', {
|
|
48
48
|
params: {
|
|
49
49
|
path: { repo: repoId(place) },
|
|
50
50
|
query: pageParam === undefined ? first : { ...first, after: pageParam },
|
|
@@ -65,13 +65,13 @@ export const queueEntries = (place: RepoPlace) => ({
|
|
|
65
65
|
const limit = '100';
|
|
66
66
|
|
|
67
67
|
/** The holds on the whole of the queue, each with why. */
|
|
68
|
-
export const queueHolds = (place: RepoPlace) =>
|
|
68
|
+
export const queueHolds = (clients: Clients, place: RepoPlace) =>
|
|
69
69
|
queryOptions({
|
|
70
70
|
queryKey: ['queue', place.owner, place.repo, 'holds'],
|
|
71
71
|
queryFn: async (): Promise<readonly QueueHold[]> => {
|
|
72
72
|
// Git lists entries' holds here too, each by the entry it was made on.
|
|
73
73
|
const read = await everyNamedPage(async (after) => {
|
|
74
|
-
const answer = await git.GET('/repos/{repo}/-/queue/holds', {
|
|
74
|
+
const answer = await clients.git.GET('/repos/{repo}/-/queue/holds', {
|
|
75
75
|
params: {
|
|
76
76
|
path: { repo: repoId(place) },
|
|
77
77
|
// A hundred a page, so ten pages hold the 1,000 active holds Git keeps at most.
|
|
@@ -94,12 +94,12 @@ export const queueHolds = (place: RepoPlace) =>
|
|
|
94
94
|
* The holds on `entry`, each with why: those made on it, and, while it's its key's, those made on
|
|
95
95
|
* entries it replaced, which a hold follows.
|
|
96
96
|
*/
|
|
97
|
-
export const entryHolds = (place: RepoPlace, entry: string) =>
|
|
97
|
+
export const entryHolds = (clients: Clients, place: RepoPlace, entry: string) =>
|
|
98
98
|
queryOptions({
|
|
99
99
|
queryKey: ['queue', place.owner, place.repo, 'holds', entry],
|
|
100
100
|
queryFn: async (): Promise<readonly QueueHold[]> => {
|
|
101
101
|
const read = await everyNamedPage(async (after) => {
|
|
102
|
-
const answer = await git.GET('/queue/entries/{entry}/holds', {
|
|
102
|
+
const answer = await clients.git.GET('/queue/entries/{entry}/holds', {
|
|
103
103
|
params: { path: { entry }, query: after === undefined ? { limit } : { limit, after } },
|
|
104
104
|
});
|
|
105
105
|
if (answer.data === undefined) throw failure("The entry's holds didn't load", answer);
|
|
@@ -123,12 +123,12 @@ export interface Candidate {
|
|
|
123
123
|
* checks run on: none when the host keeps no queue, as Git answers `NOT_FOUND` then. One still
|
|
124
124
|
* building has no commit yet, so nothing to check.
|
|
125
125
|
*/
|
|
126
|
-
export const queueCandidates = (place: RepoPlace) =>
|
|
126
|
+
export const queueCandidates = (clients: Clients, place: RepoPlace) =>
|
|
127
127
|
queryOptions({
|
|
128
128
|
queryKey: ['queue', place.owner, place.repo, 'candidates'],
|
|
129
129
|
queryFn: async (): Promise<readonly Candidate[]> => {
|
|
130
130
|
const read = await everyNamedPage(async (after) => {
|
|
131
|
-
const answer = await git.GET('/repos/{repo}/-/queue/candidates', {
|
|
131
|
+
const answer = await clients.git.GET('/repos/{repo}/-/queue/candidates', {
|
|
132
132
|
params: {
|
|
133
133
|
path: { repo: repoId(place) },
|
|
134
134
|
query: after === undefined ? { target, limit } : { target, limit, after },
|
|
@@ -159,13 +159,13 @@ export const pullOfEntry = (entry: QueueEntry) => {
|
|
|
159
159
|
* The titles of the open pull requests into the queued branch, by number, for the entries' rows:
|
|
160
160
|
* one list read for the whole queue, since every entry's pull request is open there.
|
|
161
161
|
*/
|
|
162
|
-
export const queuedTitles = (place: RepoPlace) =>
|
|
162
|
+
export const queuedTitles = (clients: Clients, place: RepoPlace) =>
|
|
163
163
|
queryOptions({
|
|
164
164
|
queryKey: ['queue', place.owner, place.repo, 'titles'],
|
|
165
165
|
queryFn: async (): Promise<ReadonlyMap<number, string>> => {
|
|
166
166
|
// `after` is the drop-in's cursor, which GitHub's types don't name: a spread passes it.
|
|
167
167
|
const read = await everyPage(async (after) => {
|
|
168
|
-
const answer = await github.GET('/repos/{owner}/{repo}/pulls', {
|
|
168
|
+
const answer = await clients.github.GET('/repos/{owner}/{repo}/pulls', {
|
|
169
169
|
params: {
|
|
170
170
|
path: place,
|
|
171
171
|
query: { ...{ state: 'open', base: queuedBranch, per_page: 100, after } },
|
|
@@ -194,8 +194,13 @@ export const refreshQueue = (client: QueryClient, place: RepoPlace) =>
|
|
|
194
194
|
* Pull request `number`, read again, if the queue may take it: it must be open, ready rather than
|
|
195
195
|
* a draft, and merge into the queued branch, as its merge box asks.
|
|
196
196
|
*/
|
|
197
|
-
export const queueable = async (
|
|
198
|
-
|
|
197
|
+
export const queueable = async (
|
|
198
|
+
clients: Clients,
|
|
199
|
+
client: QueryClient,
|
|
200
|
+
place: RepoPlace,
|
|
201
|
+
number: number,
|
|
202
|
+
) => {
|
|
203
|
+
const pull = await client.fetchQuery({ ...pullAt(clients, place, number), staleTime: 0 });
|
|
199
204
|
if (pull === null) throw new Error(`There's no pull request #${number} here`);
|
|
200
205
|
|
|
201
206
|
if (pull.state !== 'open' || pull.merged !== null)
|
|
@@ -213,19 +218,29 @@ export const queueable = async (client: QueryClient, place: RepoPlace, number: n
|
|
|
213
218
|
* Adds `chosen` to the queue at the head the person confirmed, once it's checked again it may go:
|
|
214
219
|
* a head pushed since is refused, as `expectedHeadOid` is, and nothing joins.
|
|
215
220
|
*/
|
|
216
|
-
export const addPull = async (
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
221
|
+
export const addPull = async (
|
|
222
|
+
clients: Clients,
|
|
223
|
+
client: QueryClient,
|
|
224
|
+
place: RepoPlace,
|
|
225
|
+
chosen: PullDetail,
|
|
226
|
+
) => {
|
|
227
|
+
await queueable(clients, client, place, chosen.number);
|
|
228
|
+
|
|
229
|
+
await enqueuePull(clients, chosen);
|
|
220
230
|
};
|
|
221
231
|
|
|
222
232
|
/**
|
|
223
233
|
* Takes pull request `number` out of the queue through the drop-in, which names it by its node ID:
|
|
224
234
|
* read again, so a pull request gone since the page read it says so.
|
|
225
235
|
*/
|
|
226
|
-
export const removePull = async (
|
|
227
|
-
|
|
236
|
+
export const removePull = async (
|
|
237
|
+
clients: Clients,
|
|
238
|
+
client: QueryClient,
|
|
239
|
+
place: RepoPlace,
|
|
240
|
+
number: number,
|
|
241
|
+
) => {
|
|
242
|
+
const pull = await client.fetchQuery({ ...pullAt(clients, place, number), staleTime: 0 });
|
|
228
243
|
if (pull === null) throw new Error(`There's no pull request #${number} here`);
|
|
229
244
|
|
|
230
|
-
await dequeuePull(pull);
|
|
245
|
+
await dequeuePull(clients, pull);
|
|
231
246
|
};
|
|
@@ -2,6 +2,7 @@ import { useQuery } from '@tanstack/react-query';
|
|
|
2
2
|
import { TagIcon } from 'lucide-react';
|
|
3
3
|
|
|
4
4
|
import { Go } from '../code/controls.tsx';
|
|
5
|
+
import { useClients } from '../clients/clients.ts';
|
|
5
6
|
import { releaseHref, type RepoPlace } from '../code/places.ts';
|
|
6
7
|
import { RelativeTime } from '../components/relative-time.tsx';
|
|
7
8
|
import { Badge } from '../components/ui/badge.tsx';
|
|
@@ -13,7 +14,8 @@ import { latestRelease } from './releases.ts';
|
|
|
13
14
|
* a repository's code shows it. Its route reads it before it draws, so it holds its place.
|
|
14
15
|
*/
|
|
15
16
|
export function LatestRelease({ place }: { readonly place: RepoPlace }) {
|
|
16
|
-
const
|
|
17
|
+
const clients = useClients();
|
|
18
|
+
const latest = useQuery(latestRelease(clients, place));
|
|
17
19
|
const release = latest.data;
|
|
18
20
|
|
|
19
21
|
return (
|
|
@@ -2,6 +2,7 @@ import type { QueryClient } from '@tanstack/react-query';
|
|
|
2
2
|
|
|
3
3
|
import { readAhead } from '../clients/cached.ts';
|
|
4
4
|
import { loadHome, type HomeLoad } from '../code/load.ts';
|
|
5
|
+
import type { Clients } from '../clients/clients.ts';
|
|
5
6
|
import type { RepoPlace } from '../code/places.ts';
|
|
6
7
|
import { RepoHome } from '../code/repo-home.tsx';
|
|
7
8
|
import { LatestRelease } from './latest-release.tsx';
|
|
@@ -13,12 +14,13 @@ import { latestRelease } from './releases.ts';
|
|
|
13
14
|
* section, not as the page's.
|
|
14
15
|
*/
|
|
15
16
|
export const loadOverview = async (
|
|
17
|
+
clients: Clients,
|
|
16
18
|
client: QueryClient,
|
|
17
19
|
place: RepoPlace,
|
|
18
20
|
): Promise<HomeLoad | undefined> => {
|
|
19
21
|
const [load] = await Promise.all([
|
|
20
|
-
loadHome(client, place),
|
|
21
|
-
readAhead(client, latestRelease(place)),
|
|
22
|
+
loadHome(clients, client, place),
|
|
23
|
+
readAhead(client, latestRelease(clients, place)),
|
|
22
24
|
]);
|
|
23
25
|
|
|
24
26
|
return load;
|
|
@@ -5,6 +5,7 @@ import { useRef, useState } from 'react';
|
|
|
5
5
|
|
|
6
6
|
import { assetBytesMost } from '../clients/transfers.ts';
|
|
7
7
|
import { sizeText } from '../code/controls.tsx';
|
|
8
|
+
import { useClients } from '../clients/clients.ts';
|
|
8
9
|
import { releaseHref, type RepoPlace } from '../code/places.ts';
|
|
9
10
|
import { refNames } from '../code/repo.ts';
|
|
10
11
|
import { HotkeyHint, hotkeys } from '../components/hotkeys/hotkeys.tsx';
|
|
@@ -57,7 +58,8 @@ interface FormProps {
|
|
|
57
58
|
* anyone else is told they can't, never offered a form that fails.
|
|
58
59
|
*/
|
|
59
60
|
export function ReleaseForm(props: FormProps) {
|
|
60
|
-
const
|
|
61
|
+
const clients = useClients();
|
|
62
|
+
const asked = useQuery(allowedHere(clients, props.place));
|
|
61
63
|
const allowed = asked.data;
|
|
62
64
|
const operation = props.release === undefined ? 'release.create' : 'release.update';
|
|
63
65
|
|
|
@@ -92,6 +94,7 @@ export function ReleaseForm(props: FormProps) {
|
|
|
92
94
|
* the files that didn't.
|
|
93
95
|
*/
|
|
94
96
|
function ReleaseFields({ place, target, release }: FormProps) {
|
|
97
|
+
const clients = useClients();
|
|
95
98
|
const client = useQueryClient();
|
|
96
99
|
const navigate = useNavigate();
|
|
97
100
|
const held = useRef(release);
|
|
@@ -112,7 +115,7 @@ function ReleaseFields({ place, target, release }: FormProps) {
|
|
|
112
115
|
const [from, setFrom] = useState(release?.target ?? target);
|
|
113
116
|
const branches = useQuery({
|
|
114
117
|
queryKey: ['release-targets', place.owner, place.repo],
|
|
115
|
-
queryFn: async () => (await refNames(place, 'branches', undefined)).names,
|
|
118
|
+
queryFn: async () => (await refNames(clients, place, 'branches', undefined)).names,
|
|
116
119
|
enabled: release === undefined,
|
|
117
120
|
});
|
|
118
121
|
// The default branch is offered first, though it's past the first page the drop-in lists.
|
|
@@ -132,8 +135,8 @@ function ReleaseFields({ place, target, release }: FormProps) {
|
|
|
132
135
|
const at = held.current;
|
|
133
136
|
const made =
|
|
134
137
|
at === undefined
|
|
135
|
-
? await createRelease(place, drafted)
|
|
136
|
-
: await changeRelease(place, at.id, drafted);
|
|
138
|
+
? await createRelease(clients, place, drafted)
|
|
139
|
+
: await changeRelease(clients, place, at.id, drafted);
|
|
137
140
|
held.current = made;
|
|
138
141
|
|
|
139
142
|
// A file sent whose answer was lost landed when the release now has an asset the form
|
|
@@ -167,7 +170,7 @@ function ReleaseFields({ place, target, release }: FormProps) {
|
|
|
167
170
|
|
|
168
171
|
const removed = useMutation({
|
|
169
172
|
mutationFn: async (id: number) => {
|
|
170
|
-
await deleteAsset(place, id);
|
|
173
|
+
await deleteAsset(clients, place, id);
|
|
171
174
|
setAssets((shown) => shown.filter((asset) => asset.id !== id));
|
|
172
175
|
},
|
|
173
176
|
});
|
|
@@ -3,6 +3,7 @@ import { useNavigate } from '@tanstack/react-router';
|
|
|
3
3
|
import { TagIcon } from 'lucide-react';
|
|
4
4
|
|
|
5
5
|
import { Go } from '../code/controls.tsx';
|
|
6
|
+
import { useClients } from '../clients/clients.ts';
|
|
6
7
|
import type { RepoPlace } from '../code/places.ts';
|
|
7
8
|
import { ConfirmAction } from '../components/confirm-action.tsx';
|
|
8
9
|
import { TabIndicator, tabLinkClass } from '../components/tab-indicator.tsx';
|
|
@@ -70,8 +71,9 @@ export function ReleasesBar({
|
|
|
70
71
|
|
|
71
72
|
/** The repo's releases, newest first, 10 a page, with More releases while more are left. */
|
|
72
73
|
export function ReleaseList({ place }: { readonly place: RepoPlace }) {
|
|
73
|
-
const
|
|
74
|
-
const
|
|
74
|
+
const clients = useClients();
|
|
75
|
+
const pages = useInfiniteQuery(releaseList(clients, place));
|
|
76
|
+
const latest = useQuery(latestRelease(clients, place)).data;
|
|
75
77
|
const allowed = useAllowed(place);
|
|
76
78
|
const releases = pages.data?.pages.flatMap((page) => page.releases) ?? [];
|
|
77
79
|
|
|
@@ -129,15 +131,16 @@ export function ReleasePage({
|
|
|
129
131
|
readonly place: RepoPlace;
|
|
130
132
|
readonly release: Release;
|
|
131
133
|
}) {
|
|
134
|
+
const clients = useClients();
|
|
132
135
|
const allowed = useAllowed(place);
|
|
133
|
-
const latest = useQuery(latestRelease(place)).data;
|
|
136
|
+
const latest = useQuery(latestRelease(clients, place)).data;
|
|
134
137
|
const navigate = useNavigate();
|
|
135
138
|
const client = useQueryClient();
|
|
136
139
|
const deleted = useMutation({
|
|
137
|
-
mutationFn: () => deleteRelease(place, release.id),
|
|
140
|
+
mutationFn: () => deleteRelease(clients, place, release.id),
|
|
138
141
|
onSuccess: async () => {
|
|
139
142
|
await client.invalidateQueries({ queryKey: ['releases', place.owner, place.repo] });
|
|
140
|
-
await client.invalidateQueries({ queryKey: latestRelease(place).queryKey });
|
|
143
|
+
await client.invalidateQueries({ queryKey: latestRelease(clients, place).queryKey });
|
|
141
144
|
await navigate({ href: `/${place.owner}/${place.repo}/releases` });
|
|
142
145
|
},
|
|
143
146
|
});
|
|
@@ -139,6 +139,7 @@ export function ReleaseView({
|
|
|
139
139
|
<Markdown
|
|
140
140
|
text={release.body}
|
|
141
141
|
context={{ kind: 'comment', repo: `${place.owner}/${place.repo}` }}
|
|
142
|
+
from={{ kind: 'release', repo: `${place.owner}/${place.repo}`, id: release.id }}
|
|
142
143
|
/>
|
|
143
144
|
</CardContent>
|
|
144
145
|
)}
|
|
@@ -3,7 +3,7 @@ import { queryOptions } from '@tanstack/react-query';
|
|
|
3
3
|
import * as Option from 'effect/Option';
|
|
4
4
|
import * as Schema from 'effect/Schema';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import type { Clients } from '../clients/clients.ts';
|
|
7
7
|
import type { RepoPlace } from '../code/places.ts';
|
|
8
8
|
import { everyNamedPage, failure } from '../hooks/answers.ts';
|
|
9
9
|
import { readRefPage } from '../code/ref-pages.ts';
|
|
@@ -57,10 +57,15 @@ export interface ReleasePage {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/** A page of `perPage` releases from cursor `after`. */
|
|
60
|
-
const readReleases = async (
|
|
60
|
+
const readReleases = async (
|
|
61
|
+
clients: Clients,
|
|
62
|
+
place: RepoPlace,
|
|
63
|
+
perPage: number,
|
|
64
|
+
after: string | undefined,
|
|
65
|
+
) => {
|
|
61
66
|
// `after` is the drop-in's cursor, which GitHub's types don't name: a spread passes it.
|
|
62
67
|
const paging = { per_page: perPage, after };
|
|
63
|
-
const answer = await github.GET('/repos/{owner}/{repo}/releases', {
|
|
68
|
+
const answer = await clients.github.GET('/repos/{owner}/{repo}/releases', {
|
|
64
69
|
params: { path: place, query: { ...paging } },
|
|
65
70
|
});
|
|
66
71
|
if (answer.data === undefined) throw failure("The releases didn't load", answer);
|
|
@@ -76,10 +81,10 @@ const readReleases = async (place: RepoPlace, perPage: number, after: string | u
|
|
|
76
81
|
const firstPage: string | undefined = undefined;
|
|
77
82
|
|
|
78
83
|
/** The repo's releases, newest first, a page at a time as the reader asks for more. */
|
|
79
|
-
export const releaseList = (place: RepoPlace) => ({
|
|
84
|
+
export const releaseList = (clients: Clients, place: RepoPlace) => ({
|
|
80
85
|
queryKey: ['releases', place.owner, place.repo] as const,
|
|
81
86
|
queryFn: ({ pageParam }: { readonly pageParam: string | undefined }) =>
|
|
82
|
-
readReleases(place, releasesPerPage, pageParam),
|
|
87
|
+
readReleases(clients, place, releasesPerPage, pageParam),
|
|
83
88
|
initialPageParam: firstPage,
|
|
84
89
|
getNextPageParam: (last: ReleasePage) => last.next,
|
|
85
90
|
staleTime: 10_000,
|
|
@@ -92,11 +97,11 @@ const draftPages = 10;
|
|
|
92
97
|
* The draft on `tag`, which only its list shows: the drop-in, as GitHub, finds no draft by its
|
|
93
98
|
* tag, and lists drafts only to whoever may edit the repo's releases.
|
|
94
99
|
*/
|
|
95
|
-
const draftOn = async (place: RepoPlace, tag: string) => {
|
|
100
|
+
const draftOn = async (clients: Clients, place: RepoPlace, tag: string) => {
|
|
96
101
|
let after: string | undefined;
|
|
97
102
|
|
|
98
103
|
for (let page = 0; page < draftPages; page += 1) {
|
|
99
|
-
const read = await readReleases(place, 100, after);
|
|
104
|
+
const read = await readReleases(clients, place, 100, after);
|
|
100
105
|
const draft = read.releases.find((release) => release.tag === tag);
|
|
101
106
|
if (draft !== undefined) return draft;
|
|
102
107
|
|
|
@@ -109,11 +114,11 @@ const draftOn = async (place: RepoPlace, tag: string) => {
|
|
|
109
114
|
};
|
|
110
115
|
|
|
111
116
|
/** The repo's latest release, as GitHub marks it, or `null` when it has none. */
|
|
112
|
-
export const latestRelease = (place: RepoPlace) =>
|
|
117
|
+
export const latestRelease = (clients: Clients, place: RepoPlace) =>
|
|
113
118
|
queryOptions({
|
|
114
119
|
queryKey: ['release', place.owner, place.repo, 'latest'],
|
|
115
120
|
queryFn: async (): Promise<Release | null> => {
|
|
116
|
-
const answer = await github.GET('/repos/{owner}/{repo}/releases/latest', {
|
|
121
|
+
const answer = await clients.github.GET('/repos/{owner}/{repo}/releases/latest', {
|
|
117
122
|
params: { path: place },
|
|
118
123
|
});
|
|
119
124
|
if (answer.response.status === 404) return null;
|
|
@@ -126,14 +131,14 @@ export const latestRelease = (place: RepoPlace) =>
|
|
|
126
131
|
});
|
|
127
132
|
|
|
128
133
|
/** The release of `tag`, or its draft, or `null` when there's none the viewer can read. */
|
|
129
|
-
export const releaseAt = (place: RepoPlace, tag: string) =>
|
|
134
|
+
export const releaseAt = (clients: Clients, place: RepoPlace, tag: string) =>
|
|
130
135
|
queryOptions({
|
|
131
136
|
queryKey: ['release', place.owner, place.repo, 'tag', tag],
|
|
132
137
|
queryFn: async () => {
|
|
133
|
-
const answer = await github.GET('/repos/{owner}/{repo}/releases/tags/{tag}', {
|
|
138
|
+
const answer = await clients.github.GET('/repos/{owner}/{repo}/releases/tags/{tag}', {
|
|
134
139
|
params: { path: { ...place, tag } },
|
|
135
140
|
});
|
|
136
|
-
if (answer.response.status === 404) return draftOn(place, tag);
|
|
141
|
+
if (answer.response.status === 404) return draftOn(clients, place, tag);
|
|
137
142
|
|
|
138
143
|
if (answer.data === undefined) throw failure("The release didn't load", answer);
|
|
139
144
|
|
|
@@ -162,8 +167,8 @@ const bodyOf = (drafted: Drafted) => ({
|
|
|
162
167
|
});
|
|
163
168
|
|
|
164
169
|
/** Publishes a release, or saves it as a draft, and answers it as it's made. */
|
|
165
|
-
export const createRelease = async (place: RepoPlace, drafted: Drafted) => {
|
|
166
|
-
const answer = await github.POST('/repos/{owner}/{repo}/releases', {
|
|
170
|
+
export const createRelease = async (clients: Clients, place: RepoPlace, drafted: Drafted) => {
|
|
171
|
+
const answer = await clients.github.POST('/repos/{owner}/{repo}/releases', {
|
|
167
172
|
params: { path: place },
|
|
168
173
|
body: bodyOf(drafted),
|
|
169
174
|
});
|
|
@@ -173,8 +178,13 @@ export const createRelease = async (place: RepoPlace, drafted: Drafted) => {
|
|
|
173
178
|
};
|
|
174
179
|
|
|
175
180
|
/** Changes release `id`, and answers it as it is after. */
|
|
176
|
-
export const changeRelease = async (
|
|
177
|
-
|
|
181
|
+
export const changeRelease = async (
|
|
182
|
+
clients: Clients,
|
|
183
|
+
place: RepoPlace,
|
|
184
|
+
id: number,
|
|
185
|
+
drafted: Drafted,
|
|
186
|
+
) => {
|
|
187
|
+
const answer = await clients.github.PATCH('/repos/{owner}/{repo}/releases/{release_id}', {
|
|
178
188
|
params: { path: { ...place, release_id: id } },
|
|
179
189
|
body: bodyOf(drafted),
|
|
180
190
|
});
|
|
@@ -184,16 +194,16 @@ export const changeRelease = async (place: RepoPlace, id: number, drafted: Draft
|
|
|
184
194
|
};
|
|
185
195
|
|
|
186
196
|
/** Deletes release `id`; its tag stays. */
|
|
187
|
-
export const deleteRelease = async (place: RepoPlace, id: number) => {
|
|
188
|
-
const answer = await github.DELETE('/repos/{owner}/{repo}/releases/{release_id}', {
|
|
197
|
+
export const deleteRelease = async (clients: Clients, place: RepoPlace, id: number) => {
|
|
198
|
+
const answer = await clients.github.DELETE('/repos/{owner}/{repo}/releases/{release_id}', {
|
|
189
199
|
params: { path: { ...place, release_id: id } },
|
|
190
200
|
});
|
|
191
201
|
if (!answer.response.ok) throw failure("The release wasn't deleted", answer);
|
|
192
202
|
};
|
|
193
203
|
|
|
194
204
|
/** Deletes asset `id` from its release. */
|
|
195
|
-
export const deleteAsset = async (place: RepoPlace, id: number) => {
|
|
196
|
-
const answer = await github.DELETE('/repos/{owner}/{repo}/releases/assets/{asset_id}', {
|
|
205
|
+
export const deleteAsset = async (clients: Clients, place: RepoPlace, id: number) => {
|
|
206
|
+
const answer = await clients.github.DELETE('/repos/{owner}/{repo}/releases/assets/{asset_id}', {
|
|
197
207
|
params: { path: { ...place, asset_id: id } },
|
|
198
208
|
});
|
|
199
209
|
if (!answer.response.ok) throw failure("The asset wasn't deleted", answer);
|
|
@@ -274,13 +284,13 @@ export interface Tags {
|
|
|
274
284
|
* than 100 and still name the next, as the drop-in's `refTargets` bound has it. The newest 100 releases, read beside them, say which
|
|
275
285
|
* tags a release is made from: one call more.
|
|
276
286
|
*/
|
|
277
|
-
export const tagsOf = (place: RepoPlace) =>
|
|
287
|
+
export const tagsOf = (clients: Clients, place: RepoPlace) =>
|
|
278
288
|
queryOptions({
|
|
279
289
|
queryKey: ['tags', place.owner, place.repo],
|
|
280
290
|
queryFn: async (): Promise<Tags> => {
|
|
281
291
|
const [read, releases] = await Promise.all([
|
|
282
292
|
everyNamedPage(async (after) => {
|
|
283
|
-
const page = await readRefPage(place, {
|
|
293
|
+
const page = await readRefPage(clients, place, {
|
|
284
294
|
prefix: 'refs/tags/',
|
|
285
295
|
first: 100,
|
|
286
296
|
after,
|
|
@@ -289,7 +299,7 @@ export const tagsOf = (place: RepoPlace) =>
|
|
|
289
299
|
|
|
290
300
|
return { rows: page.rows, next: page.next };
|
|
291
301
|
}),
|
|
292
|
-
readReleases(place, 100, undefined),
|
|
302
|
+
readReleases(clients, place, 100, undefined),
|
|
293
303
|
]);
|
|
294
304
|
const released = new Set(releases.releases.map((release) => release.tag));
|
|
295
305
|
|