ref0-git 0.3.0 → 0.6.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 +9 -8
- 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 +7 -4
- package/app/apps/github/src/palette/rows.tsx +54 -33
- package/app/apps/github/src/palette/server.ts +5 -5
- package/app/apps/github/src/palette/targets.ts +1 -0
- package/app/apps/github/src/policy.ts +165 -66
- package/app/apps/github/src/private-repos.ts +2 -2
- 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 -110
- 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 +12 -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 +1 -1
- package/dist/cli/helpers.mjs +2 -2
- 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 +4 -4
- 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 +20 -21
- package/dist/init/choices.mjs +1 -1
- package/dist/init/cloudflare.mjs +15 -19
- package/dist/init/create.mjs +3 -2
- package/dist/init/detect.mjs +4 -4
- package/dist/init/files.mjs +120 -13
- 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 +2 -2
- package/dist/init/node-app.mjs +3 -3
- package/dist/init/node.mjs +42 -45
- 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 +63 -47
- package/dist/init/vercel.mjs +37 -37
- package/dist/init/versions.mjs +3 -3
- package/package.json +6 -5
|
@@ -9,7 +9,10 @@ import { OrgSettings } from '../../../settings/org-settings.tsx';
|
|
|
9
9
|
export const Route = createFileRoute('/orgs/$owner/settings')({
|
|
10
10
|
loader: async ({ params, context }) => {
|
|
11
11
|
// The owner's level reads the same owner, at the same time, so the two share the one read.
|
|
12
|
-
const owner = await cached(
|
|
12
|
+
const owner = await cached(
|
|
13
|
+
context.queryClient,
|
|
14
|
+
ownerAt(context.clients, params.owner, context.viewer?.login),
|
|
15
|
+
);
|
|
13
16
|
if (owner?.kind !== 'org') throw notFound();
|
|
14
17
|
},
|
|
15
18
|
component: OrgSettingsPage,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* What the seed makes: the org `acme`, with Pip and Mo from ref0's cast, and three of its repos,
|
|
3
3
|
* each with a description, a license and a history in its own language, and most with branches,
|
|
4
4
|
* pull requests and issues, so a local copy is a demo to try. Every step
|
|
5
|
-
* is named, by a repo's
|
|
5
|
+
* is named, by a repo's name, a branch, a label, a title or a tag, and the seed looks each up by that
|
|
6
6
|
* name before it makes it.
|
|
7
7
|
*/
|
|
8
8
|
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import type { CreatedToken, GitError, Oid, RefName,
|
|
1
|
+
import type { CreatedToken, GitError, Oid, RefName, RepoName, Result, Signature } from '@ref0/git';
|
|
2
2
|
import { createRestClient } from '@ref0/git/rest';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Change, Committed, Read, Scope, Snapshot } from '@ref0/infra';
|
|
4
4
|
import type { RestClient } from '@ref0/git/rest';
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
7
|
import { org, pip, repos } from './acme.ts';
|
|
8
8
|
import type { Person, SeedCommit, SeedIssue, SeedPull, SeedRepo } from './acme.ts';
|
|
9
9
|
|
|
10
|
-
/**
|
|
10
|
+
/** The records the seed keeps its progress in, beside Git's own: `read` and `commit`, as a store's. */
|
|
11
|
+
export interface SeedRecords {
|
|
12
|
+
readonly read: (scope: Scope, reads: Read[]) => Promise<Snapshot>;
|
|
13
|
+
readonly commit: (scope: Scope, change: Change) => Promise<Committed>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** What the seed writes through: the host's own handler and its records, and the admin secret. */
|
|
11
17
|
export interface SeedHost {
|
|
12
18
|
/** The host's handler, which every write goes through, as a request from outside would. */
|
|
13
19
|
readonly fetch: (request: Request) => Promise<Response>;
|
|
@@ -15,8 +21,8 @@ export interface SeedHost {
|
|
|
15
21
|
readonly origin: string;
|
|
16
22
|
/** Signs in as the admin, who makes the org's repos and each person's token. */
|
|
17
23
|
readonly adminToken: string;
|
|
18
|
-
/**
|
|
19
|
-
readonly store:
|
|
24
|
+
/** Git's records, which keep the seed's progress beside Git's own. */
|
|
25
|
+
readonly store: SeedRecords;
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
/** What a call to `seed` did: made what was missing, or left a host that needs none. */
|
|
@@ -56,7 +62,7 @@ const value = <A>(result: Result<A>, doing: string): A => {
|
|
|
56
62
|
|
|
57
63
|
const missing = (error: GitError) => error.code === 'NOT_FOUND';
|
|
58
64
|
|
|
59
|
-
const readProgress = async (store:
|
|
65
|
+
const readProgress = async (store: SeedRecords) => {
|
|
60
66
|
const snapshot = await store.read(progressScope, [progressKey]);
|
|
61
67
|
const row = snapshot.results[0]?.[0];
|
|
62
68
|
|
|
@@ -67,7 +73,7 @@ const readProgress = async (store: Store) => {
|
|
|
67
73
|
};
|
|
68
74
|
|
|
69
75
|
/** Saves `progress` if nothing moved the record since `version`; whether it did. */
|
|
70
|
-
const saveProgress = async (store:
|
|
76
|
+
const saveProgress = async (store: SeedRecords, version: number, progress: Progress) => {
|
|
71
77
|
const committed = await store.commit(progressScope, {
|
|
72
78
|
id: `seed-${progress.state}-${progress.since}-${progress.tokensExpire?.at(-1) ?? 0}`,
|
|
73
79
|
expect: version,
|
|
@@ -81,7 +87,7 @@ const saveProgress = async (store: Store, version: number, progress: Progress) =
|
|
|
81
87
|
* The progress to go on from: a cut seed's, or a new one when the host holds no repos. A host
|
|
82
88
|
* whose seed is done, or that has repos of its own, gets none.
|
|
83
89
|
*/
|
|
84
|
-
const begin = async (store:
|
|
90
|
+
const begin = async (store: SeedRecords, admin: RestClient): Promise<Progress | undefined> => {
|
|
85
91
|
const { version, progress } = await readProgress(store);
|
|
86
92
|
if (progress !== undefined) return progress.state === 'running' ? progress : undefined;
|
|
87
93
|
|
|
@@ -142,14 +148,35 @@ const dropInCall =
|
|
|
142
148
|
/** What the seed reads back from the drop-in, to find what it made before. */
|
|
143
149
|
const Numbered = Schema.Struct({ number: Schema.Number });
|
|
144
150
|
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
151
|
+
const MilestoneRef = Schema.NullOr(Numbered);
|
|
152
|
+
|
|
153
|
+
const CreatedItem = Schema.Struct({
|
|
154
|
+
number: Schema.Number,
|
|
155
|
+
milestone: MilestoneRef,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
const Described = Schema.Struct({
|
|
159
|
+
description: Schema.NullOr(Schema.String),
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const ExistingPull = Schema.Struct({
|
|
163
|
+
number: Schema.Number,
|
|
164
|
+
head: Schema.Struct({ label: Schema.String }),
|
|
165
|
+
milestone: MilestoneRef,
|
|
166
|
+
merged_at: Schema.NullOr(Schema.String),
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
type ExistingPull = typeof ExistingPull.Type;
|
|
170
|
+
|
|
171
|
+
const ExistingIssue = Schema.Struct({
|
|
172
|
+
number: Schema.Number,
|
|
173
|
+
title: Schema.String,
|
|
174
|
+
state: Schema.String,
|
|
175
|
+
milestone: MilestoneRef,
|
|
176
|
+
pull_request: Schema.optional(Schema.Unknown),
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
type ExistingIssue = typeof ExistingIssue.Type;
|
|
153
180
|
|
|
154
181
|
const Authored = Schema.Array(
|
|
155
182
|
Schema.Struct({
|
|
@@ -158,14 +185,18 @@ const Authored = Schema.Array(
|
|
|
158
185
|
}),
|
|
159
186
|
);
|
|
160
187
|
|
|
161
|
-
const decodePulls = Schema.decodeUnknownSync(Schema.fromJsonString(Schema.Array(
|
|
188
|
+
const decodePulls = Schema.decodeUnknownSync(Schema.fromJsonString(Schema.Array(ExistingPull)));
|
|
162
189
|
|
|
163
|
-
const decodeIssues = Schema.decodeUnknownSync(Schema.fromJsonString(
|
|
190
|
+
const decodeIssues = Schema.decodeUnknownSync(Schema.fromJsonString(Schema.Array(ExistingIssue)));
|
|
164
191
|
|
|
165
192
|
const decodeAuthored = Schema.decodeUnknownSync(Schema.fromJsonString(Authored));
|
|
166
193
|
|
|
167
194
|
const decodeNumbered = Schema.decodeUnknownSync(Schema.fromJsonString(Numbered));
|
|
168
195
|
|
|
196
|
+
const decodeCreated = Schema.decodeUnknownSync(Schema.fromJsonString(CreatedItem));
|
|
197
|
+
|
|
198
|
+
const decodeDescribed = Schema.decodeUnknownSync(Schema.fromJsonString(Described));
|
|
199
|
+
|
|
169
200
|
/** A repo's milestones, by their titles. */
|
|
170
201
|
const decodeTitled = Schema.decodeUnknownSync(
|
|
171
202
|
Schema.fromJsonString(
|
|
@@ -173,17 +204,6 @@ const decodeTitled = Schema.decodeUnknownSync(
|
|
|
173
204
|
),
|
|
174
205
|
);
|
|
175
206
|
|
|
176
|
-
/** The milestone an issue or a pull request is on. */
|
|
177
|
-
const decodeMilestoned = Schema.decodeUnknownSync(
|
|
178
|
-
Schema.fromJsonString(
|
|
179
|
-
Schema.Struct({ milestone: Schema.NullOr(Schema.Struct({ number: Schema.Number })) }),
|
|
180
|
-
),
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
const decodeMerged = Schema.decodeUnknownSync(
|
|
184
|
-
Schema.fromJsonString(Schema.Struct({ merged: Schema.Boolean })),
|
|
185
|
-
);
|
|
186
|
-
|
|
187
207
|
/**
|
|
188
208
|
* Who the seed acts as: the admin's Git calls and drop-in calls, and each person's Git calls and
|
|
189
209
|
* drop-in calls.
|
|
@@ -195,19 +215,23 @@ interface Cast {
|
|
|
195
215
|
readonly call: (person: Person) => Call;
|
|
196
216
|
}
|
|
197
217
|
|
|
198
|
-
const
|
|
199
|
-
const found = await
|
|
200
|
-
if (found.kind === 'success') return;
|
|
218
|
+
const ensureRepo = async (cast: Cast, id: RepoName, path: string, description: string) => {
|
|
219
|
+
const found = await cast.adminCall('GET', path);
|
|
201
220
|
|
|
202
|
-
if (
|
|
221
|
+
if (found.status === 404) {
|
|
222
|
+
value(await cast.admin.repos.create({ name: id, public: true }), `make ${id}`);
|
|
223
|
+
} else if (decodeDescribed(found.text).description === (description || null)) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
203
226
|
|
|
204
|
-
|
|
227
|
+
// A repo's settings are its admin's to change, which a person's `write` token isn't.
|
|
228
|
+
await cast.adminCall('PATCH', path, { description });
|
|
205
229
|
};
|
|
206
230
|
|
|
207
231
|
/** Each commit in turn on `parent`, as `git commit` makes them; their IDs, oldest first. */
|
|
208
232
|
const commitAll = async (
|
|
209
233
|
git: RestClient,
|
|
210
|
-
id:
|
|
234
|
+
id: RepoName,
|
|
211
235
|
parent: Oid | undefined,
|
|
212
236
|
commits: readonly SeedCommit[],
|
|
213
237
|
since: number,
|
|
@@ -231,42 +255,60 @@ const commitAll = async (
|
|
|
231
255
|
|
|
232
256
|
/**
|
|
233
257
|
* The repo's history, pushed as Pip: its commits, each dated from `since`, so a seed started again
|
|
234
|
-
* makes the same objects, then each branch and the tag that isn't there yet, at once.
|
|
258
|
+
* makes the same objects, then each branch and the tag that isn't there yet, at once. Checks the
|
|
259
|
+
* expected refs first so a resumed seed skips rebuilding commits and tags once every ref exists.
|
|
235
260
|
*/
|
|
236
|
-
const pushHistory = async (git: RestClient, id:
|
|
237
|
-
const main = await commitAll(git, id, undefined, repo.main, since);
|
|
238
|
-
const refs: { readonly ref: RefName; readonly to: Oid }[] = [];
|
|
239
|
-
refs.push({ ref: 'refs/heads/main', to: main.at(-1) ?? '' });
|
|
240
|
-
|
|
241
|
-
for (const branch of repo.branches) {
|
|
242
|
-
const made = await commitAll(git, id, main[branch.from], branch.commits, since);
|
|
243
|
-
refs.push({ ref: `refs/heads/${branch.name}`, to: made.at(-1) ?? '' });
|
|
244
|
-
}
|
|
245
|
-
|
|
261
|
+
const pushHistory = async (git: RestClient, id: RepoName, repo: SeedRepo, since: number) => {
|
|
246
262
|
const { release } = repo;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
263
|
+
const targets: readonly {
|
|
264
|
+
readonly ref: RefName;
|
|
265
|
+
readonly build: (main: readonly Oid[]) => Promise<Oid>;
|
|
266
|
+
}[] = [
|
|
267
|
+
{ ref: 'refs/heads/main', build: (main) => Promise.resolve(main.at(-1) ?? '') },
|
|
268
|
+
...repo.branches.map((branch) => ({
|
|
269
|
+
ref: `refs/heads/${branch.name}`,
|
|
270
|
+
build: async (main: readonly Oid[]) =>
|
|
271
|
+
(await commitAll(git, id, main[branch.from], branch.commits, since)).at(-1) ?? '',
|
|
272
|
+
})),
|
|
273
|
+
...(release === undefined
|
|
274
|
+
? []
|
|
275
|
+
: [
|
|
276
|
+
{
|
|
277
|
+
ref: `refs/tags/${release.tag}`,
|
|
278
|
+
build: async (main: readonly Oid[]) => {
|
|
279
|
+
const tagged = repo.main[release.at];
|
|
280
|
+
const tag = await git.tags.create(id, {
|
|
281
|
+
object: main[release.at] ?? '',
|
|
282
|
+
tag: release.tag,
|
|
283
|
+
tagger: signature(pip, since, (tagged?.daysAgo ?? 0) - 1),
|
|
284
|
+
message: `${release.title}\n`,
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
return value(tag, `tag ${release.tag}`).oid;
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
]),
|
|
291
|
+
];
|
|
292
|
+
|
|
293
|
+
const missingRefs = new Set<RefName>();
|
|
294
|
+
|
|
295
|
+
for (const { ref } of targets) {
|
|
262
296
|
const found = await git.refs.get(id, { ref });
|
|
263
297
|
if (found.kind === 'success') continue;
|
|
264
298
|
|
|
265
299
|
if (!missing(found.error)) value(found, `read ${ref}`);
|
|
266
|
-
|
|
300
|
+
missingRefs.add(ref);
|
|
267
301
|
}
|
|
268
302
|
|
|
269
|
-
if (
|
|
303
|
+
if (missingRefs.size === 0) return;
|
|
304
|
+
|
|
305
|
+
const main = await commitAll(git, id, undefined, repo.main, since);
|
|
306
|
+
const absent = [];
|
|
307
|
+
|
|
308
|
+
for (const { ref, build } of targets) {
|
|
309
|
+
const to = await build(main);
|
|
310
|
+
if (missingRefs.has(ref)) absent.push({ ref, from: null, to });
|
|
311
|
+
}
|
|
270
312
|
|
|
271
313
|
const updated = value(await git.refs.update(id, { updates: absent, atomic: true }), 'push');
|
|
272
314
|
const refused = updated.updates.find((update) => update.kind === 'rejected');
|
|
@@ -299,14 +341,16 @@ const makeMilestones = async (call: Call, path: string, repo: SeedRepo) => {
|
|
|
299
341
|
};
|
|
300
342
|
|
|
301
343
|
/** Puts the issue or pull request `number` on `milestone`, unless it's on it already. */
|
|
302
|
-
const placeOn = async (
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
344
|
+
const placeOn = async (
|
|
345
|
+
call: Call,
|
|
346
|
+
path: string,
|
|
347
|
+
number: number,
|
|
348
|
+
currentMilestone: number | null,
|
|
349
|
+
milestone?: number,
|
|
350
|
+
) => {
|
|
351
|
+
if (milestone === undefined || currentMilestone === milestone) return;
|
|
306
352
|
|
|
307
|
-
|
|
308
|
-
await call('PATCH', `${path}/issues/${number}`, { milestone });
|
|
309
|
-
}
|
|
353
|
+
await call('PATCH', `${path}/issues/${number}`, { milestone });
|
|
310
354
|
};
|
|
311
355
|
|
|
312
356
|
/** Whether `person` already wrote `body` among a pull request's reviews or an issue's comments. */
|
|
@@ -321,13 +365,12 @@ const openPull = async (
|
|
|
321
365
|
path: string,
|
|
322
366
|
pull: SeedPull,
|
|
323
367
|
milestones: ReadonlyMap<string, number>,
|
|
368
|
+
found: ExistingPull | undefined,
|
|
324
369
|
) => {
|
|
325
370
|
const author = cast.call(pull.by);
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
found?.number ??
|
|
330
|
-
decodeNumbered(
|
|
371
|
+
const item =
|
|
372
|
+
found ??
|
|
373
|
+
decodeCreated(
|
|
331
374
|
(
|
|
332
375
|
await author('POST', `${path}/pulls`, {
|
|
333
376
|
title: pull.title,
|
|
@@ -336,24 +379,26 @@ const openPull = async (
|
|
|
336
379
|
base: 'main',
|
|
337
380
|
})
|
|
338
381
|
).text,
|
|
339
|
-
)
|
|
340
|
-
await placeOn(
|
|
382
|
+
);
|
|
383
|
+
await placeOn(
|
|
384
|
+
author,
|
|
385
|
+
path,
|
|
386
|
+
item.number,
|
|
387
|
+
item.milestone?.number ?? null,
|
|
388
|
+
milestones.get(pull.milestone ?? ''),
|
|
389
|
+
);
|
|
341
390
|
|
|
342
391
|
const reviewer = cast.call(pull.review.by);
|
|
343
|
-
const reviews = await reviewer('GET', `${path}/pulls/${number}/reviews`);
|
|
392
|
+
const reviews = await reviewer('GET', `${path}/pulls/${item.number}/reviews`);
|
|
344
393
|
|
|
345
394
|
if (!wrote(reviews.text, pull.review.by)) {
|
|
346
395
|
const { event, body } = pull.review;
|
|
347
|
-
await reviewer('POST', `${path}/pulls/${number}/reviews`, { event, body });
|
|
396
|
+
await reviewer('POST', `${path}/pulls/${item.number}/reviews`, { event, body });
|
|
348
397
|
}
|
|
349
398
|
|
|
350
|
-
if (!pull.merged) return;
|
|
399
|
+
if (!pull.merged || found?.merged_at != null) return;
|
|
351
400
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
if (!state.merged) {
|
|
355
|
-
await author('PUT', `${path}/pulls/${number}/merge`, { merge_method: 'merge' });
|
|
356
|
-
}
|
|
401
|
+
await author('PUT', `${path}/pulls/${item.number}/merge`, { merge_method: 'merge' });
|
|
357
402
|
};
|
|
358
403
|
|
|
359
404
|
/** The issue by its title, opened by its author if it isn't open yet, its comments, then closed. */
|
|
@@ -362,15 +407,12 @@ const openIssue = async (
|
|
|
362
407
|
path: string,
|
|
363
408
|
issue: SeedIssue,
|
|
364
409
|
milestones: ReadonlyMap<string, number>,
|
|
410
|
+
found: ExistingIssue | undefined,
|
|
365
411
|
) => {
|
|
366
412
|
const author = cast.call(issue.by);
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
(
|
|
370
|
-
);
|
|
371
|
-
const number =
|
|
372
|
-
found?.number ??
|
|
373
|
-
decodeNumbered(
|
|
413
|
+
const item =
|
|
414
|
+
found ??
|
|
415
|
+
decodeCreated(
|
|
374
416
|
(
|
|
375
417
|
await author('POST', `${path}/issues`, {
|
|
376
418
|
title: issue.title,
|
|
@@ -378,20 +420,26 @@ const openIssue = async (
|
|
|
378
420
|
labels: issue.labels,
|
|
379
421
|
})
|
|
380
422
|
).text,
|
|
381
|
-
)
|
|
382
|
-
await placeOn(
|
|
423
|
+
);
|
|
424
|
+
await placeOn(
|
|
425
|
+
author,
|
|
426
|
+
path,
|
|
427
|
+
item.number,
|
|
428
|
+
item.milestone?.number ?? null,
|
|
429
|
+
milestones.get(issue.milestone ?? ''),
|
|
430
|
+
);
|
|
383
431
|
|
|
384
432
|
for (const comment of issue.comments) {
|
|
385
433
|
const commenter = cast.call(comment.by);
|
|
386
|
-
const comments = await commenter('GET', `${path}/issues/${number}/comments?per_page=100`);
|
|
434
|
+
const comments = await commenter('GET', `${path}/issues/${item.number}/comments?per_page=100`);
|
|
387
435
|
|
|
388
436
|
if (!wrote(comments.text, comment.by, comment.body)) {
|
|
389
|
-
await commenter('POST', `${path}/issues/${number}/comments`, { body: comment.body });
|
|
437
|
+
await commenter('POST', `${path}/issues/${item.number}/comments`, { body: comment.body });
|
|
390
438
|
}
|
|
391
439
|
}
|
|
392
440
|
|
|
393
441
|
if (issue.closed && found?.state !== 'closed') {
|
|
394
|
-
await author('PATCH', `${path}/issues/${number}`, {
|
|
442
|
+
await author('PATCH', `${path}/issues/${item.number}`, {
|
|
395
443
|
state: 'closed',
|
|
396
444
|
state_reason: 'completed',
|
|
397
445
|
});
|
|
@@ -413,20 +461,48 @@ const publishRelease = async (call: Call, path: string, repo: SeedRepo) => {
|
|
|
413
461
|
};
|
|
414
462
|
|
|
415
463
|
const seedRepo = async (cast: Cast, repo: SeedRepo, since: number) => {
|
|
416
|
-
const id:
|
|
464
|
+
const id: RepoName = `${org.login}/${repo.name}`;
|
|
417
465
|
const path = `/repos/${id}`;
|
|
466
|
+
const asPip = cast.call(pip);
|
|
418
467
|
|
|
419
|
-
await
|
|
420
|
-
// A repo's settings are its admin's to change, which a person's `write` token isn't.
|
|
421
|
-
await cast.adminCall('PATCH', path, { description: repo.description });
|
|
468
|
+
await ensureRepo(cast, id, path, repo.description);
|
|
422
469
|
await pushHistory(cast.git(pip), id, repo, since);
|
|
423
|
-
await makeLabels(
|
|
424
|
-
const milestones = await makeMilestones(
|
|
470
|
+
await makeLabels(asPip, path, repo);
|
|
471
|
+
const milestones = await makeMilestones(asPip, path, repo);
|
|
472
|
+
|
|
473
|
+
if (repo.pulls.length > 0) {
|
|
474
|
+
const listedPulls = decodePulls(
|
|
475
|
+
(await asPip('GET', `${path}/pulls?state=all&per_page=100`)).text,
|
|
476
|
+
);
|
|
477
|
+
const pullsByHead = new Map<string, ExistingPull>();
|
|
478
|
+
|
|
479
|
+
for (const item of listedPulls) {
|
|
480
|
+
if (!pullsByHead.has(item.head.label)) pullsByHead.set(item.head.label, item);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
for (const pull of repo.pulls) {
|
|
484
|
+
await openPull(cast, path, pull, milestones, pullsByHead.get(`${org.login}:${pull.branch}`));
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
if (repo.issues.length > 0) {
|
|
489
|
+
const listedIssues = decodeIssues(
|
|
490
|
+
(await asPip('GET', `${path}/issues?state=all&per_page=100`)).text,
|
|
491
|
+
);
|
|
492
|
+
const issuesByTitle = new Map<string, ExistingIssue>();
|
|
425
493
|
|
|
426
|
-
|
|
494
|
+
for (const item of listedIssues) {
|
|
495
|
+
if (item.pull_request === undefined && !issuesByTitle.has(item.title)) {
|
|
496
|
+
issuesByTitle.set(item.title, item);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
for (const issue of repo.issues) {
|
|
501
|
+
await openIssue(cast, path, issue, milestones, issuesByTitle.get(issue.title));
|
|
502
|
+
}
|
|
503
|
+
}
|
|
427
504
|
|
|
428
|
-
|
|
429
|
-
await publishRelease(cast.call(pip), path, repo);
|
|
505
|
+
await publishRelease(asPip, path, repo);
|
|
430
506
|
};
|
|
431
507
|
|
|
432
508
|
const members: ReadonlySet<string> = new Set(org.members.map((person) => person.login));
|
|
@@ -490,7 +566,7 @@ export const seed = async (host: SeedHost): Promise<SeedOutcome> => {
|
|
|
490
566
|
if (!marked) throw new Error('Another start is seeding this host');
|
|
491
567
|
|
|
492
568
|
const issued = new Map<string, CreatedToken>();
|
|
493
|
-
|
|
569
|
+
const revoked: Result<void>[] = [];
|
|
494
570
|
|
|
495
571
|
try {
|
|
496
572
|
for (const person of org.members) {
|
|
@@ -505,17 +581,30 @@ export const seed = async (host: SeedHost): Promise<SeedOutcome> => {
|
|
|
505
581
|
issued.set(person.login, value(token, `make ${person.login}'s token`));
|
|
506
582
|
}
|
|
507
583
|
|
|
584
|
+
const gitClients = new Map<string, RestClient>();
|
|
585
|
+
const dropInCalls = new Map<string, Call>();
|
|
508
586
|
const secret = (person: Person) => issued.get(person.login)?.secret ?? '';
|
|
587
|
+
const memo = <A>(cache: Map<string, A>, person: Person, make: (token: string) => A): A => {
|
|
588
|
+
const existing = cache.get(person.login);
|
|
589
|
+
if (existing !== undefined) return existing;
|
|
590
|
+
|
|
591
|
+
const made = make(secret(person));
|
|
592
|
+
cache.set(person.login, made);
|
|
593
|
+
|
|
594
|
+
return made;
|
|
595
|
+
};
|
|
596
|
+
|
|
509
597
|
const cast: Cast = {
|
|
510
598
|
admin,
|
|
511
599
|
adminCall: dropInCall(host, host.adminToken),
|
|
512
|
-
git: (person) =>
|
|
513
|
-
call: (person) => dropInCall(host,
|
|
600
|
+
git: (person) => memo(gitClients, person, client),
|
|
601
|
+
call: (person) => memo(dropInCalls, person, (token) => dropInCall(host, token)),
|
|
514
602
|
};
|
|
515
603
|
|
|
516
604
|
for (const repo of repos) await seedRepo(cast, repo, progress.since);
|
|
517
605
|
} finally {
|
|
518
|
-
|
|
606
|
+
// One at a time: revokes at once in one scope miss each other's writes, and some run out of tries.
|
|
607
|
+
for (const token of issued.values()) revoked.push(await admin.tokens.revoke(token.id));
|
|
519
608
|
}
|
|
520
609
|
|
|
521
610
|
// A revoke that failed leaves the seed running, so the next call revokes what it left.
|
|
@@ -1,18 +1,10 @@
|
|
|
1
|
+
import { Records } from '@ref0/infra';
|
|
1
2
|
import handler, { createServerEntry } from '@tanstack/react-start/server-entry';
|
|
2
3
|
|
|
4
|
+
import { workersFetch } from './camo/fetch.ts';
|
|
5
|
+
import { imageProxy } from './camo/proxy.ts';
|
|
3
6
|
import type { AppContext } from './context/context.ts';
|
|
4
|
-
import {
|
|
5
|
-
adapter,
|
|
6
|
-
auth,
|
|
7
|
-
directory,
|
|
8
|
-
env,
|
|
9
|
-
git,
|
|
10
|
-
github,
|
|
11
|
-
pictures,
|
|
12
|
-
policy,
|
|
13
|
-
rest,
|
|
14
|
-
sessionKey,
|
|
15
|
-
} from './git.ts';
|
|
7
|
+
import { auth, directory, env, git, github, pictures, policy, rest, sessionKey } from './git.ts';
|
|
16
8
|
import { hostRules } from './policy.ts';
|
|
17
9
|
import { shownRules } from './settings/rules.ts';
|
|
18
10
|
import { sessionCookieOf, sessionEnder, sessionFrom } from './signin/auth.ts';
|
|
@@ -27,6 +19,18 @@ const owned = async (request: Request) =>
|
|
|
27
19
|
/** Git's answer for a URL it doesn't own: the app's server calls never reach the app. */
|
|
28
20
|
const api = async (request: Request) => (await owned(request)) ?? rest.fetch(request);
|
|
29
21
|
|
|
22
|
+
/**
|
|
23
|
+
* The image proxy (Q860): a text's remote images load through `/_camo/`, and the pages' CSP loads
|
|
24
|
+
* no other. Without it, and with `IMAGE_PROXY=off`, they load from their own origin.
|
|
25
|
+
*/
|
|
26
|
+
const images = imageProxy({
|
|
27
|
+
secret: env.SESSION_SECRET,
|
|
28
|
+
appOrigin: env.APP_ORIGIN,
|
|
29
|
+
setting: env.IMAGE_PROXY,
|
|
30
|
+
fetch: workersFetch,
|
|
31
|
+
cache: caches.default,
|
|
32
|
+
});
|
|
33
|
+
|
|
30
34
|
/** The host's push rules, as a repo's settings show them. */
|
|
31
35
|
const rules = shownRules(hostRules);
|
|
32
36
|
|
|
@@ -53,7 +57,11 @@ const seeded = () => {
|
|
|
53
57
|
fetch: api,
|
|
54
58
|
origin: env.APP_ORIGIN,
|
|
55
59
|
adminToken: env.ADMIN_TOKEN,
|
|
56
|
-
|
|
60
|
+
// Git's records, on its runtime, keep the seed's progress beside Git's own.
|
|
61
|
+
store: {
|
|
62
|
+
read: (scope, reads) => git.runtime.runPromise(Records.read(scope, reads)),
|
|
63
|
+
commit: (scope, change) => git.runtime.runPromise(Records.commit(scope, change)),
|
|
64
|
+
},
|
|
57
65
|
});
|
|
58
66
|
})
|
|
59
67
|
.then(
|
|
@@ -66,7 +74,7 @@ const seeded = () => {
|
|
|
66
74
|
|
|
67
75
|
/** Q8's order: the drop-in, then Git, then the app. A URL one owns never falls through. */
|
|
68
76
|
export default createServerEntry({
|
|
69
|
-
fetch: async (incoming) => {
|
|
77
|
+
fetch: images.around(async (incoming) => {
|
|
70
78
|
// A host session is the app's server's to set in this Worker, never a caller's to send
|
|
71
79
|
// (Q520): every route, the APIs, the app and any upgrade, sees the request without one.
|
|
72
80
|
const request = withoutHostSession(incoming);
|
|
@@ -90,8 +98,9 @@ export default createServerEntry({
|
|
|
90
98
|
avatars: pictures,
|
|
91
99
|
accounts: directory,
|
|
92
100
|
git,
|
|
101
|
+
images,
|
|
93
102
|
};
|
|
94
103
|
|
|
95
104
|
return handler.fetch(request, { context });
|
|
96
|
-
},
|
|
105
|
+
}),
|
|
97
106
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useClients } from '../clients/clients.ts';
|
|
1
2
|
import { avatarUrl } from '../components/avatar-url.ts';
|
|
2
3
|
import { type Account, UserAvatar } from '../components/user-avatar.tsx';
|
|
3
4
|
import { avatarAt } from '../hooks/avatars.ts';
|
|
@@ -23,6 +24,8 @@ export function AccountAvatar({
|
|
|
23
24
|
/** Why the viewer can't change it, or none when they can. */
|
|
24
25
|
readonly refusal?: string | undefined;
|
|
25
26
|
}) {
|
|
27
|
+
const clients = useClients();
|
|
28
|
+
|
|
26
29
|
return (
|
|
27
30
|
<AvatarSection
|
|
28
31
|
place={{ owner: login }}
|
|
@@ -34,7 +37,7 @@ export function AccountAvatar({
|
|
|
34
37
|
preview={<UserAvatar login={login} account={account} size="xl" />}
|
|
35
38
|
onShown={(client, hash) =>
|
|
36
39
|
client.setQueryData(
|
|
37
|
-
avatarAt(login).queryKey,
|
|
40
|
+
avatarAt(clients, login).queryKey,
|
|
38
41
|
hash === null ? null : avatarUrl({ owner: login }, hash),
|
|
39
42
|
)
|
|
40
43
|
}
|
|
@@ -4,6 +4,7 @@ import { LockIcon } from 'lucide-react';
|
|
|
4
4
|
import { type FormEvent, type ReactNode, useState } from 'react';
|
|
5
5
|
import { toast } from 'sonner';
|
|
6
6
|
|
|
7
|
+
import { useClients } from '../clients/clients.ts';
|
|
7
8
|
import type { RepoPlace } from '../code/places.ts';
|
|
8
9
|
import { ConfirmAction } from '../components/confirm-action.tsx';
|
|
9
10
|
import { setIconHash } from '../components/repos/icon-hashes.ts';
|
|
@@ -125,8 +126,9 @@ function Section({
|
|
|
125
126
|
* buttons, then the danger zone. Each is changed as the viewer, through the host's sign-in.
|
|
126
127
|
*/
|
|
127
128
|
export function GeneralSettings({ place }: { readonly place: RepoPlace }) {
|
|
129
|
+
const clients = useClients();
|
|
128
130
|
const allowed = useAllowed(place);
|
|
129
|
-
const asked = useQuery(generalSettings(place));
|
|
131
|
+
const asked = useQuery(generalSettings(clients, place));
|
|
130
132
|
|
|
131
133
|
if (!allowed.has('repo.update')) {
|
|
132
134
|
return (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { queryOptions } from '@tanstack/react-query';
|
|
2
2
|
import * as Schema from 'effect/Schema';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import type { Clients } from '../clients/clients.ts';
|
|
5
5
|
import { hostAnswer } from '../clients/host-answer.ts';
|
|
6
6
|
import type { RepoPlace } from '../code/places.ts';
|
|
7
7
|
import { refNames } from '../code/repo.ts';
|
|
@@ -21,15 +21,15 @@ export interface General {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/** The repo's General settings, and its first 100 branches, which its default may be. */
|
|
24
|
-
export const generalSettings = (place: RepoPlace) =>
|
|
24
|
+
export const generalSettings = (clients: Clients, place: RepoPlace) =>
|
|
25
25
|
queryOptions({
|
|
26
26
|
queryKey: ['general', place.owner, place.repo],
|
|
27
27
|
queryFn: async () => {
|
|
28
|
-
const answer = await github.GET('/repos/{owner}/{repo}', { params: { path: place } });
|
|
28
|
+
const answer = await clients.github.GET('/repos/{owner}/{repo}', { params: { path: place } });
|
|
29
29
|
if (answer.data === undefined) throw failure("The settings didn't load", answer);
|
|
30
30
|
|
|
31
31
|
const repo = answer.data;
|
|
32
|
-
const branches = await refNames(place, 'branches', undefined);
|
|
32
|
+
const branches = await refNames(clients, place, 'branches', undefined);
|
|
33
33
|
const general: General = {
|
|
34
34
|
name: repo.name,
|
|
35
35
|
description: repo.description ?? '',
|