ref0-git 0.0.0-stage → 0.2.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 +6 -0
- package/app/apps/github/README.md +70 -0
- package/app/apps/github/THIRD_PARTY_NOTICES.md +214 -0
- package/app/apps/github/components.json +25 -0
- package/app/apps/github/generated/git-rest.ts +10444 -0
- package/app/apps/github/generated/routeTree.gen.ts +1242 -0
- package/app/apps/github/migrations/postgres/0001_auth.sql +46 -0
- package/app/apps/github/migrations/sql/0001_auth.sql +19 -0
- package/app/apps/github/migrations/sql/0002_passkeys.sql +9 -0
- package/app/apps/github/migrations/sql/0003_orgs.sql +22 -0
- package/app/apps/github/migrations/sql/0004_avatars.sql +6 -0
- package/app/apps/github/package.json +80 -0
- package/app/apps/github/src/branches/branch-list.tsx +385 -0
- package/app/apps/github/src/branches/branches.ts +55 -0
- package/app/apps/github/src/clients/allowed.ts +213 -0
- package/app/apps/github/src/clients/at-most.ts +17 -0
- package/app/apps/github/src/clients/avatars.ts +410 -0
- package/app/apps/github/src/clients/cached.ts +65 -0
- package/app/apps/github/src/clients/calls.ts +160 -0
- package/app/apps/github/src/clients/clients.ts +82 -0
- package/app/apps/github/src/clients/graphql.ts +50 -0
- package/app/apps/github/src/clients/host-answer.ts +28 -0
- package/app/apps/github/src/clients/host-calls.ts +382 -0
- package/app/apps/github/src/clients/icon-bytes.ts +203 -0
- package/app/apps/github/src/clients/proxy.ts +59 -0
- package/app/apps/github/src/clients/session-ended.ts +18 -0
- package/app/apps/github/src/clients/transfers.ts +212 -0
- package/app/apps/github/src/code/breadcrumbs.tsx +50 -0
- package/app/apps/github/src/code/code-page.tsx +147 -0
- package/app/apps/github/src/code/code-tree.tsx +338 -0
- package/app/apps/github/src/code/controls.tsx +230 -0
- package/app/apps/github/src/code/file-view.tsx +450 -0
- package/app/apps/github/src/code/files.ts +332 -0
- package/app/apps/github/src/code/folder-list.tsx +122 -0
- package/app/apps/github/src/code/go-to-file.tsx +131 -0
- package/app/apps/github/src/code/highlighted.tsx +58 -0
- package/app/apps/github/src/code/lines.ts +46 -0
- package/app/apps/github/src/code/load.ts +147 -0
- package/app/apps/github/src/code/markdown-files.ts +58 -0
- package/app/apps/github/src/code/places.ts +88 -0
- package/app/apps/github/src/code/ref-pages.ts +179 -0
- package/app/apps/github/src/code/ref-switcher.tsx +203 -0
- package/app/apps/github/src/code/refs.ts +142 -0
- package/app/apps/github/src/code/repo-home.tsx +240 -0
- package/app/apps/github/src/code/repo.ts +105 -0
- package/app/apps/github/src/code/saved-reads.ts +199 -0
- package/app/apps/github/src/code/saved.ts +110 -0
- package/app/apps/github/src/code/tree-fold.ts +186 -0
- package/app/apps/github/src/code/trees.ts +136 -0
- package/app/apps/github/src/components/avatar-picture.ts +53 -0
- package/app/apps/github/src/components/avatar-url.ts +16 -0
- package/app/apps/github/src/components/confirm-action.tsx +100 -0
- package/app/apps/github/src/components/count.tsx +24 -0
- package/app/apps/github/src/components/create-button.tsx +38 -0
- package/app/apps/github/src/components/file-icons/file-icons.css +225 -0
- package/app/apps/github/src/components/file-icons/file-icons.tsx +138 -0
- package/app/apps/github/src/components/filter.tsx +35 -0
- package/app/apps/github/src/components/hotkeys/hotkeys.tsx +255 -0
- package/app/apps/github/src/components/item-list.tsx +65 -0
- package/app/apps/github/src/components/language-dot.tsx +29 -0
- package/app/apps/github/src/components/list-toolbar.tsx +82 -0
- package/app/apps/github/src/components/markdown/editor.tsx +57 -0
- package/app/apps/github/src/components/markdown/markdown.css +177 -0
- package/app/apps/github/src/components/markdown/markdown.tsx +82 -0
- package/app/apps/github/src/components/owner-card.tsx +196 -0
- package/app/apps/github/src/components/pull-status.tsx +34 -0
- package/app/apps/github/src/components/recent.ts +41 -0
- package/app/apps/github/src/components/relative-time.tsx +78 -0
- package/app/apps/github/src/components/repos/icon-hashes.ts +91 -0
- package/app/apps/github/src/components/repos/new-repo-form.tsx +196 -0
- package/app/apps/github/src/components/repos/repo-icon.tsx +47 -0
- package/app/apps/github/src/components/repos/repo-list.tsx +528 -0
- package/app/apps/github/src/components/repos/your-repos.tsx +124 -0
- package/app/apps/github/src/components/review-state.tsx +75 -0
- package/app/apps/github/src/components/route-dialog.tsx +137 -0
- package/app/apps/github/src/components/save-button.tsx +58 -0
- package/app/apps/github/src/components/shell/app-shell.tsx +164 -0
- package/app/apps/github/src/components/shell/create-org-dialog.tsx +118 -0
- package/app/apps/github/src/components/shell/create-row.tsx +49 -0
- package/app/apps/github/src/components/shell/link-menu.tsx +94 -0
- package/app/apps/github/src/components/shell/nav-user.tsx +97 -0
- package/app/apps/github/src/components/shell/owner-repos.tsx +247 -0
- package/app/apps/github/src/components/shell/owner-switcher.tsx +104 -0
- package/app/apps/github/src/components/shell/repo-switcher.tsx +179 -0
- package/app/apps/github/src/components/shell/sections.ts +31 -0
- package/app/apps/github/src/components/shell/submenu-chevron.ts +147 -0
- package/app/apps/github/src/components/signin/device-card.tsx +139 -0
- package/app/apps/github/src/components/signin/login-form.tsx +88 -0
- package/app/apps/github/src/components/signin/signin-page.tsx +33 -0
- package/app/apps/github/src/components/signin/signup-form.tsx +106 -0
- package/app/apps/github/src/components/states/live-status.tsx +42 -0
- package/app/apps/github/src/components/states/states.tsx +126 -0
- package/app/apps/github/src/components/tab-indicator.tsx +143 -0
- package/app/apps/github/src/components/theme-choice.tsx +108 -0
- package/app/apps/github/src/components/theme-provider.tsx +126 -0
- package/app/apps/github/src/components/tones.ts +23 -0
- package/app/apps/github/src/components/ui/alert-dialog.tsx +187 -0
- package/app/apps/github/src/components/ui/alert.tsx +78 -0
- package/app/apps/github/src/components/ui/avatar.tsx +106 -0
- package/app/apps/github/src/components/ui/badge.tsx +51 -0
- package/app/apps/github/src/components/ui/breadcrumb.tsx +124 -0
- package/app/apps/github/src/components/ui/button-group.tsx +87 -0
- package/app/apps/github/src/components/ui/button.tsx +61 -0
- package/app/apps/github/src/components/ui/calendar.tsx +221 -0
- package/app/apps/github/src/components/ui/card.tsx +102 -0
- package/app/apps/github/src/components/ui/checkbox.tsx +26 -0
- package/app/apps/github/src/components/ui/collapsible.tsx +19 -0
- package/app/apps/github/src/components/ui/combobox.tsx +304 -0
- package/app/apps/github/src/components/ui/command.tsx +208 -0
- package/app/apps/github/src/components/ui/dialog.tsx +156 -0
- package/app/apps/github/src/components/ui/dropdown-menu.tsx +290 -0
- package/app/apps/github/src/components/ui/empty.tsx +100 -0
- package/app/apps/github/src/components/ui/field.tsx +236 -0
- package/app/apps/github/src/components/ui/hover-card.tsx +48 -0
- package/app/apps/github/src/components/ui/input-group.tsx +163 -0
- package/app/apps/github/src/components/ui/input.tsx +19 -0
- package/app/apps/github/src/components/ui/item.tsx +201 -0
- package/app/apps/github/src/components/ui/kbd.tsx +27 -0
- package/app/apps/github/src/components/ui/label.tsx +33 -0
- package/app/apps/github/src/components/ui/popover.tsx +87 -0
- package/app/apps/github/src/components/ui/radio-group.tsx +35 -0
- package/app/apps/github/src/components/ui/select.tsx +198 -0
- package/app/apps/github/src/components/ui/separator.tsx +22 -0
- package/app/apps/github/src/components/ui/sheet.tsx +138 -0
- package/app/apps/github/src/components/ui/sidebar.tsx +724 -0
- package/app/apps/github/src/components/ui/skeleton.tsx +13 -0
- package/app/apps/github/src/components/ui/sonner.tsx +47 -0
- package/app/apps/github/src/components/ui/styles.css +242 -0
- package/app/apps/github/src/components/ui/table.tsx +113 -0
- package/app/apps/github/src/components/ui/tabs.tsx +79 -0
- package/app/apps/github/src/components/ui/textarea.tsx +17 -0
- package/app/apps/github/src/components/ui/title.ts +6 -0
- package/app/apps/github/src/components/ui/toggle-group.tsx +89 -0
- package/app/apps/github/src/components/ui/toggle.tsx +42 -0
- package/app/apps/github/src/components/ui/tooltip.tsx +63 -0
- package/app/apps/github/src/components/user-avatar.tsx +145 -0
- package/app/apps/github/src/components/view-tabs.tsx +42 -0
- package/app/apps/github/src/context/context.ts +133 -0
- package/app/apps/github/src/diffs/blobs.ts +94 -0
- package/app/apps/github/src/diffs/diff-view.tsx +155 -0
- package/app/apps/github/src/diffs/files.ts +121 -0
- package/app/apps/github/src/diffs/hunks.tsx +454 -0
- package/app/apps/github/src/diffs/patch.ts +131 -0
- package/app/apps/github/src/diffs/rows.ts +137 -0
- package/app/apps/github/src/history/commit-diff.ts +54 -0
- package/app/apps/github/src/history/commit-list.tsx +207 -0
- package/app/apps/github/src/history/commit-page.tsx +147 -0
- package/app/apps/github/src/history/history.ts +129 -0
- package/app/apps/github/src/hooks/allowed.ts +31 -0
- package/app/apps/github/src/hooks/answers.ts +65 -0
- package/app/apps/github/src/hooks/avatars.ts +54 -0
- package/app/apps/github/src/hooks/draft.ts +38 -0
- package/app/apps/github/src/hooks/open-counts.ts +127 -0
- package/app/apps/github/src/hooks/profiles.ts +120 -0
- package/app/apps/github/src/hooks/repos.ts +440 -0
- package/app/apps/github/src/hooks/use-mobile.ts +19 -0
- package/app/apps/github/src/hooks/viewer.ts +39 -0
- package/app/apps/github/src/inbox/count.ts +70 -0
- package/app/apps/github/src/inbox/inbox-item.tsx +66 -0
- package/app/apps/github/src/inbox/inbox-page.tsx +572 -0
- package/app/apps/github/src/inbox/marks.ts +130 -0
- package/app/apps/github/src/inbox/release-tags.ts +65 -0
- package/app/apps/github/src/inbox/search.ts +97 -0
- package/app/apps/github/src/inbox/subjects.ts +184 -0
- package/app/apps/github/src/inbox/subscription-controls.tsx +184 -0
- package/app/apps/github/src/inbox/subscriptions.ts +189 -0
- package/app/apps/github/src/inbox/threads.ts +198 -0
- package/app/apps/github/src/issues/changes.ts +332 -0
- package/app/apps/github/src/issues/counts.ts +62 -0
- package/app/apps/github/src/issues/issue-list.tsx +682 -0
- package/app/apps/github/src/issues/issue-page.tsx +533 -0
- package/app/apps/github/src/issues/issues.ts +566 -0
- package/app/apps/github/src/issues/label-dialog.tsx +310 -0
- package/app/apps/github/src/issues/labels-page.tsx +119 -0
- package/app/apps/github/src/issues/new-issue.tsx +79 -0
- package/app/apps/github/src/issues/parts.tsx +71 -0
- package/app/apps/github/src/issues/picker.tsx +298 -0
- package/app/apps/github/src/issues/search.ts +238 -0
- package/app/apps/github/src/issues/sidebar.tsx +236 -0
- package/app/apps/github/src/lib/cn.ts +8 -0
- package/app/apps/github/src/lib/highlighting.ts +13 -0
- package/app/apps/github/src/live/follow.ts +129 -0
- package/app/apps/github/src/live/sse.ts +74 -0
- package/app/apps/github/src/live/use-follow.ts +37 -0
- package/app/apps/github/src/markdown/README.md +53 -0
- package/app/apps/github/src/markdown/allowed-html.ts +69 -0
- package/app/apps/github/src/markdown/context.ts +206 -0
- package/app/apps/github/src/markdown/images.ts +81 -0
- package/app/apps/github/src/markdown/lookup.ts +122 -0
- package/app/apps/github/src/markdown/patches.ts +299 -0
- package/app/apps/github/src/markdown/query.ts +25 -0
- package/app/apps/github/src/markdown/references.ts +158 -0
- package/app/apps/github/src/markdown/render.ts +103 -0
- package/app/apps/github/src/names/owners.ts +51 -0
- package/app/apps/github/src/names/repos.ts +24 -0
- package/app/apps/github/src/palette/palette.tsx +547 -0
- package/app/apps/github/src/palette/recent.ts +116 -0
- package/app/apps/github/src/palette/rows.tsx +455 -0
- package/app/apps/github/src/palette/server.ts +104 -0
- package/app/apps/github/src/palette/targets.ts +306 -0
- package/app/apps/github/src/policy.ts +600 -0
- package/app/apps/github/src/private-repos.ts +47 -0
- package/app/apps/github/src/pulls/compare-page.tsx +342 -0
- package/app/apps/github/src/pulls/files-tab.tsx +776 -0
- package/app/apps/github/src/pulls/live.ts +124 -0
- package/app/apps/github/src/pulls/merge-box.tsx +367 -0
- package/app/apps/github/src/pulls/merge-button.ts +86 -0
- package/app/apps/github/src/pulls/pull-list.tsx +235 -0
- package/app/apps/github/src/pulls/pull-page.tsx +474 -0
- package/app/apps/github/src/pulls/pull.ts +468 -0
- package/app/apps/github/src/pulls/pulls.ts +318 -0
- package/app/apps/github/src/pulls/review.ts +350 -0
- package/app/apps/github/src/pulls/search.ts +130 -0
- package/app/apps/github/src/queue/queue-page.tsx +405 -0
- package/app/apps/github/src/queue/queue.ts +231 -0
- package/app/apps/github/src/releases/latest-release.tsx +55 -0
- package/app/apps/github/src/releases/overview.tsx +30 -0
- package/app/apps/github/src/releases/release-form.tsx +353 -0
- package/app/apps/github/src/releases/release-list.tsx +173 -0
- package/app/apps/github/src/releases/release-view.tsx +183 -0
- package/app/apps/github/src/releases/releases.ts +308 -0
- package/app/apps/github/src/releases/tag-list.tsx +134 -0
- package/app/apps/github/src/router.tsx +46 -0
- package/app/apps/github/src/routes/$owner/$repo/_code/blob/$.tsx +33 -0
- package/app/apps/github/src/routes/$owner/$repo/_code/tree/$.tsx +28 -0
- package/app/apps/github/src/routes/$owner/$repo/_code.tsx +11 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases/releases/index.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases/tags.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/_releases.tsx +23 -0
- package/app/apps/github/src/routes/$owner/$repo/branches.tsx +39 -0
- package/app/apps/github/src/routes/$owner/$repo/commit/$sha.tsx +34 -0
- package/app/apps/github/src/routes/$owner/$repo/commits/$.tsx +42 -0
- package/app/apps/github/src/routes/$owner/$repo/compare/$.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/index.tsx +24 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/$number.tsx +50 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/index.tsx +53 -0
- package/app/apps/github/src/routes/$owner/$repo/issues/new.tsx +43 -0
- package/app/apps/github/src/routes/$owner/$repo/labels.tsx +22 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/checks.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/commits.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/files.tsx +15 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/index.tsx +19 -0
- package/app/apps/github/src/routes/$owner/$repo/pull/$number/route.tsx +52 -0
- package/app/apps/github/src/routes/$owner/$repo/pulls/index.tsx +48 -0
- package/app/apps/github/src/routes/$owner/$repo/queue.tsx +22 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/edit/$.tsx +58 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/new.tsx +40 -0
- package/app/apps/github/src/routes/$owner/$repo/releases/tag/$.tsx +35 -0
- package/app/apps/github/src/routes/$owner/$repo/route.tsx +102 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/access.tsx +9 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/index.tsx +16 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/hooks/new.tsx +25 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/index.tsx +17 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/route.tsx +28 -0
- package/app/apps/github/src/routes/$owner/$repo/settings/rules.tsx +12 -0
- package/app/apps/github/src/routes/$owner/$repo/tokens.tsx +16 -0
- package/app/apps/github/src/routes/$owner/index.tsx +45 -0
- package/app/apps/github/src/routes/-nav.tsx +293 -0
- package/app/apps/github/src/routes/-root-testing.ts +107 -0
- package/app/apps/github/src/routes/__root.tsx +225 -0
- package/app/apps/github/src/routes/api.auth.$.ts +18 -0
- package/app/apps/github/src/routes/downloads/$owner/$repo/$asset.tsx +10 -0
- package/app/apps/github/src/routes/file-icons[.]svg.ts +21 -0
- package/app/apps/github/src/routes/icons/$owner/$repo.tsx +14 -0
- package/app/apps/github/src/routes/icons/$owner/index.tsx +14 -0
- package/app/apps/github/src/routes/icons/index.tsx +12 -0
- package/app/apps/github/src/routes/index.tsx +48 -0
- package/app/apps/github/src/routes/login.tsx +24 -0
- package/app/apps/github/src/routes/login_.code.tsx +31 -0
- package/app/apps/github/src/routes/new.tsx +91 -0
- package/app/apps/github/src/routes/notifications.tsx +20 -0
- package/app/apps/github/src/routes/orgs/$owner/issues.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/pulls.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/releases.tsx +8 -0
- package/app/apps/github/src/routes/orgs/$owner/route.tsx +25 -0
- package/app/apps/github/src/routes/orgs/$owner/settings.tsx +30 -0
- package/app/apps/github/src/routes/orgs/$owner/tokens.tsx +15 -0
- package/app/apps/github/src/routes/settings.tsx +54 -0
- package/app/apps/github/src/routes/signup.tsx +24 -0
- package/app/apps/github/src/routes/uploads/$owner/$repo/$release.tsx +10 -0
- package/app/apps/github/src/seed/acme.ts +498 -0
- package/app/apps/github/src/seed/licenses.ts +114 -0
- package/app/apps/github/src/seed/seed.ts +538 -0
- package/app/apps/github/src/server.ts +97 -0
- package/app/apps/github/src/settings/account-avatar.tsx +43 -0
- package/app/apps/github/src/settings/avatar-section.tsx +140 -0
- package/app/apps/github/src/settings/avatar.ts +58 -0
- package/app/apps/github/src/settings/general-settings.tsx +439 -0
- package/app/apps/github/src/settings/general.ts +73 -0
- package/app/apps/github/src/settings/hook-form.tsx +195 -0
- package/app/apps/github/src/settings/hook-list.tsx +166 -0
- package/app/apps/github/src/settings/hooks.ts +87 -0
- package/app/apps/github/src/settings/org-settings.tsx +228 -0
- package/app/apps/github/src/settings/orgs.ts +116 -0
- package/app/apps/github/src/settings/rule-list.tsx +72 -0
- package/app/apps/github/src/settings/rules.ts +27 -0
- package/app/apps/github/src/settings/settings-layout.tsx +114 -0
- package/app/apps/github/src/signin/approval.ts +186 -0
- package/app/apps/github/src/signin/auth-client.ts +127 -0
- package/app/apps/github/src/signin/auth.ts +753 -0
- package/app/apps/github/src/signin/avatars.ts +126 -0
- package/app/apps/github/src/signin/client-ip.ts +39 -0
- package/app/apps/github/src/signin/credentials.ts +26 -0
- package/app/apps/github/src/signin/device-code.ts +95 -0
- package/app/apps/github/src/signin/device-prompt.ts +125 -0
- package/app/apps/github/src/signin/errors.ts +135 -0
- package/app/apps/github/src/signin/host-session.ts +68 -0
- package/app/apps/github/src/signin/orgs.ts +283 -0
- package/app/apps/github/src/signin/owner-names.ts +183 -0
- package/app/apps/github/src/signin/person-lock.ts +104 -0
- package/app/apps/github/src/signin/seal.ts +88 -0
- package/app/apps/github/src/signin/seed-people.ts +92 -0
- package/app/apps/github/src/signin/session.ts +48 -0
- package/app/apps/github/src/signin/unborn.ts +110 -0
- package/app/apps/github/src/signin/viewer-orgs.ts +47 -0
- package/app/apps/github/src/signin/viewer.ts +74 -0
- package/app/apps/github/src/signin/with-headers.ts +14 -0
- package/app/apps/github/src/tokens/tokens-page.tsx +529 -0
- package/app/apps/github/src/tokens/tokens.ts +54 -0
- package/app/apps/github/tsconfig.json +25 -0
- package/app/apps/github/tsconfig.worker.json +24 -0
- package/app/apps/github/vite.config.ts +21 -0
- package/app/pnpm-workspace.yaml +216 -0
- package/app/tsconfig.base.json +127 -0
- package/dist/LICENSE +202 -0
- package/dist/cli/child.mjs +42 -0
- package/dist/cli/commands.mjs +23 -0
- package/dist/cli/credentials.mjs +84 -0
- package/dist/cli/documents.mjs +214 -0
- package/dist/cli/events.mjs +55 -0
- package/dist/cli/failure.mjs +105 -0
- package/dist/cli/folders.mjs +32 -0
- package/dist/cli/git-remote-ref0.d.mts +1 -0
- package/dist/cli/git-remote-ref0.mjs +29 -0
- package/dist/cli/git.mjs +48 -0
- package/dist/cli/helpers.mjs +51 -0
- package/dist/cli/hosts.mjs +127 -0
- package/dist/cli/node.mjs +15 -0
- package/dist/cli/output.mjs +135 -0
- package/dist/cli/prompt.mjs +35 -0
- package/dist/cli/queue.mjs +215 -0
- package/dist/cli/ref0-git.d.mts +1 -0
- package/dist/cli/ref0-git.mjs +144 -0
- package/dist/cli/repos.mjs +162 -0
- package/dist/cli/resources.mjs +131 -0
- package/dist/cli/run-end.mjs +57 -0
- package/dist/cli/runtime.mjs +50 -0
- package/dist/cli/setup.mjs +1410 -0
- package/dist/cli/sign-in.mjs +162 -0
- package/dist/cli/sign-ins.mjs +79 -0
- package/dist/cli/sqlite.mjs +28 -0
- package/dist/cli/tokens.mjs +141 -0
- package/dist/cli/vendor.mjs +123 -0
- package/dist/init/app.mjs +231 -0
- package/dist/init/astro.mjs +49 -0
- package/dist/init/choices.mjs +497 -0
- package/dist/init/cloudflare.mjs +324 -0
- package/dist/init/create.mjs +151 -0
- package/dist/init/detect.mjs +297 -0
- package/dist/init/files.mjs +75 -0
- package/dist/init/frameworks.mjs +248 -0
- package/dist/init/git-module.mjs +49 -0
- package/dist/init/github-routes.mjs +66 -0
- package/dist/init/jsonc.mjs +143 -0
- package/dist/init/metadata.mjs +48 -0
- package/dist/init/mounts.mjs +109 -0
- package/dist/init/next.mjs +205 -0
- package/dist/init/node-app.mjs +189 -0
- package/dist/init/node.mjs +458 -0
- package/dist/init/nuxt.mjs +115 -0
- package/dist/init/output.mjs +21 -0
- package/dist/init/plan.mjs +82 -0
- package/dist/init/range-major.mjs +257 -0
- package/dist/init/react-router.mjs +59 -0
- package/dist/init/routes.mjs +148 -0
- package/dist/init/shell.mjs +4 -0
- package/dist/init/stores.mjs +51 -0
- package/dist/init/sveltekit.mjs +139 -0
- package/dist/init/template.mjs +142 -0
- package/dist/init/templates.mjs +343 -0
- package/dist/init/vercel.mjs +383 -0
- package/dist/init/versions.mjs +32 -0
- package/dist/init/workspace.mjs +20 -0
- package/package.json +52 -3
- package/README.md +0 -3
|
@@ -0,0 +1,776 @@
|
|
|
1
|
+
import type { DiffLineAnnotation, SelectedLineRange } from '@pierre/diffs';
|
|
2
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
3
|
+
import { useRouteContext } from '@tanstack/react-router';
|
|
4
|
+
import { ChevronRightIcon } from 'lucide-react';
|
|
5
|
+
import { useMemo, useRef, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Go } from '../code/controls.tsx';
|
|
8
|
+
import { commitHref, type RepoPlace } from '../code/places.ts';
|
|
9
|
+
import { Markdown } from '../components/markdown/markdown.tsx';
|
|
10
|
+
import { HotkeyHint, hotkeys } from '../components/hotkeys/hotkeys.tsx';
|
|
11
|
+
import { MarkdownEditor } from '../components/markdown/editor.tsx';
|
|
12
|
+
import { Badge } from '../components/ui/badge.tsx';
|
|
13
|
+
import { OwnerCard } from '../components/owner-card.tsx';
|
|
14
|
+
import { UserAvatar } from '../components/user-avatar.tsx';
|
|
15
|
+
import { Button } from '../components/ui/button.tsx';
|
|
16
|
+
import { ConfirmAction } from '../components/confirm-action.tsx';
|
|
17
|
+
import {
|
|
18
|
+
Collapsible,
|
|
19
|
+
CollapsibleContent,
|
|
20
|
+
CollapsibleTrigger,
|
|
21
|
+
} from '../components/ui/collapsible.tsx';
|
|
22
|
+
import {
|
|
23
|
+
Dialog,
|
|
24
|
+
DialogClose,
|
|
25
|
+
DialogContent,
|
|
26
|
+
DialogDescription,
|
|
27
|
+
DialogFooter,
|
|
28
|
+
DialogHeader,
|
|
29
|
+
DialogTitle,
|
|
30
|
+
DialogTrigger,
|
|
31
|
+
} from '../components/ui/dialog.tsx';
|
|
32
|
+
import { Field, FieldContent, FieldDescription, FieldLabel } from '../components/ui/field.tsx';
|
|
33
|
+
import { RadioGroup, RadioGroupItem } from '../components/ui/radio-group.tsx';
|
|
34
|
+
import { DiffView } from '../diffs/diff-view.tsx';
|
|
35
|
+
import { pullFiles, type Notes } from '../diffs/files.ts';
|
|
36
|
+
import { useAllowed } from '../hooks/allowed.ts';
|
|
37
|
+
import { Comment, Failed } from '../issues/issue-page.tsx';
|
|
38
|
+
import { refreshPull, reviewsOf, type PullDetail } from './pull.ts';
|
|
39
|
+
import {
|
|
40
|
+
commentOnLines,
|
|
41
|
+
discardPending,
|
|
42
|
+
draftsOf,
|
|
43
|
+
lineCommentsOf,
|
|
44
|
+
noReviewDraft,
|
|
45
|
+
mergeBaseOf,
|
|
46
|
+
onHead,
|
|
47
|
+
outdatedThreads,
|
|
48
|
+
pendingCommentsOf,
|
|
49
|
+
refreshReviews,
|
|
50
|
+
replyTo,
|
|
51
|
+
reviewDraftOf,
|
|
52
|
+
submitPending,
|
|
53
|
+
submitReview,
|
|
54
|
+
type Draft,
|
|
55
|
+
type LineComment,
|
|
56
|
+
type LinePlace,
|
|
57
|
+
type LineSide,
|
|
58
|
+
type ReviewDraft,
|
|
59
|
+
type ReviewEvent,
|
|
60
|
+
} from './review.ts';
|
|
61
|
+
|
|
62
|
+
/** Where `@pierre/diffs` draws a side's notes: the old file's lines, or the new's. */
|
|
63
|
+
const sides = { LEFT: 'deletions', RIGHT: 'additions' } as const;
|
|
64
|
+
|
|
65
|
+
const sideOf = (side: SelectedLineRange['side']): LineSide =>
|
|
66
|
+
side === 'deletions' ? 'LEFT' : 'RIGHT';
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The lines picked from the gutter, as GitHub's REST places a comment: on its last line, from its
|
|
70
|
+
* first when it's a range, whichever way the drag went.
|
|
71
|
+
*/
|
|
72
|
+
export const placeOfPick = (path: string, picked: SelectedLineRange): LinePlace => {
|
|
73
|
+
const first = { line: picked.start, side: sideOf(picked.side) };
|
|
74
|
+
const last = { line: picked.end, side: sideOf(picked.endSide ?? picked.side) };
|
|
75
|
+
const [from, to] =
|
|
76
|
+
first.side === last.side && first.line > last.line ? [last, first] : [first, last];
|
|
77
|
+
if (from.line === to.line && from.side === to.side) return { path, ...to };
|
|
78
|
+
|
|
79
|
+
return { path, ...to, startLine: from.line, startSide: from.side };
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/** A note on `place`, under its last line, by the key its box is drawn from. */
|
|
83
|
+
const noteOn = (place: LinePlace, key: string) => ({
|
|
84
|
+
path: place.path,
|
|
85
|
+
note: { side: sides[place.side], lineNumber: place.line, metadata: key },
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
/** Which lines a comment is on, as its header says it. */
|
|
89
|
+
const linesSaid = (place: LinePlace) =>
|
|
90
|
+
place.startLine === undefined
|
|
91
|
+
? `line ${place.line}`
|
|
92
|
+
: `lines ${place.startLine} to ${place.line}`;
|
|
93
|
+
|
|
94
|
+
/** What each choice in **Review changes** does, as GitHub's box says it. */
|
|
95
|
+
const events: readonly {
|
|
96
|
+
readonly event: ReviewEvent;
|
|
97
|
+
readonly name: string;
|
|
98
|
+
readonly says: string;
|
|
99
|
+
}[] = [
|
|
100
|
+
{ event: 'COMMENT', name: 'Comment', says: 'Submit general feedback without explicit approval.' },
|
|
101
|
+
{ event: 'APPROVE', name: 'Approve', says: 'Submit feedback and approve merging these changes.' },
|
|
102
|
+
{
|
|
103
|
+
event: 'REQUEST_CHANGES',
|
|
104
|
+
name: 'Request changes',
|
|
105
|
+
says: 'Submit feedback that must be addressed before merging.',
|
|
106
|
+
},
|
|
107
|
+
];
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A thread: its first comment, its replies, and a reply box for those allowed. An outdated one
|
|
111
|
+
* says which file and lines it was made on, and links the commit, since it isn't drawn on the diff.
|
|
112
|
+
*/
|
|
113
|
+
function Thread({
|
|
114
|
+
repo,
|
|
115
|
+
comments,
|
|
116
|
+
outdatedIn,
|
|
117
|
+
reply,
|
|
118
|
+
}: {
|
|
119
|
+
readonly repo: string;
|
|
120
|
+
readonly comments: readonly LineComment[];
|
|
121
|
+
/** The repo an outdated thread's commit is in, or `undefined` for a thread on the diff. */
|
|
122
|
+
readonly outdatedIn?: RepoPlace;
|
|
123
|
+
readonly reply: ((body: string) => Promise<void>) | undefined;
|
|
124
|
+
}) {
|
|
125
|
+
const [draft, setDraft] = useState<string | undefined>();
|
|
126
|
+
const replied = useMutation({
|
|
127
|
+
mutationFn: async (body: string) => reply?.(body),
|
|
128
|
+
onSuccess: () => setDraft(undefined),
|
|
129
|
+
});
|
|
130
|
+
const first = comments[0];
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<div
|
|
134
|
+
className={`flex flex-col gap-2 bg-muted/30 p-3 font-sans text-sm whitespace-normal ${outdatedIn === undefined ? 'border-y' : 'border'}`}
|
|
135
|
+
>
|
|
136
|
+
{first !== undefined &&
|
|
137
|
+
(outdatedIn === undefined ? (
|
|
138
|
+
<p className="text-meta text-muted-foreground">On {linesSaid(first)}</p>
|
|
139
|
+
) : (
|
|
140
|
+
<p className="flex flex-wrap items-center gap-2 text-meta text-muted-foreground">
|
|
141
|
+
<Badge variant="outline">Outdated</Badge>
|
|
142
|
+
<span>
|
|
143
|
+
<span className="font-mono">{first.path}</span>, {linesSaid(first)}, at{' '}
|
|
144
|
+
<Go
|
|
145
|
+
href={commitHref(outdatedIn, first.commit)}
|
|
146
|
+
className="font-mono text-foreground hover:underline"
|
|
147
|
+
>
|
|
148
|
+
{first.commit.slice(0, 7)}
|
|
149
|
+
</Go>
|
|
150
|
+
</span>
|
|
151
|
+
</p>
|
|
152
|
+
))}
|
|
153
|
+
{comments.map((comment) => (
|
|
154
|
+
<Comment
|
|
155
|
+
key={comment.id}
|
|
156
|
+
repo={repo}
|
|
157
|
+
author={comment.login}
|
|
158
|
+
upload={comment.pictures.get(comment.login)}
|
|
159
|
+
created={comment.created}
|
|
160
|
+
body={comment.body}
|
|
161
|
+
save={undefined}
|
|
162
|
+
/>
|
|
163
|
+
))}
|
|
164
|
+
{reply !== undefined &&
|
|
165
|
+
(draft === undefined ? (
|
|
166
|
+
<Button variant="outline" size="sm" className="self-start" onClick={() => setDraft('')}>
|
|
167
|
+
Reply
|
|
168
|
+
</Button>
|
|
169
|
+
) : (
|
|
170
|
+
<div className="flex flex-col gap-2" data-hotkey-box>
|
|
171
|
+
<MarkdownEditor repo={repo} label="Reply" value={draft} onChange={setDraft} />
|
|
172
|
+
<div className="flex justify-end gap-2">
|
|
173
|
+
<Button variant="ghost" onClick={() => setDraft(undefined)}>
|
|
174
|
+
Cancel
|
|
175
|
+
</Button>
|
|
176
|
+
<Button
|
|
177
|
+
disabled={replied.isPending || draft.trim() === ''}
|
|
178
|
+
onClick={() => replied.mutate(draft)}
|
|
179
|
+
data-hotkey={hotkeys.submit}
|
|
180
|
+
>
|
|
181
|
+
Reply
|
|
182
|
+
<HotkeyHint keys={hotkeys.submit} />
|
|
183
|
+
</Button>
|
|
184
|
+
</div>
|
|
185
|
+
<Failed error={replied.error} />
|
|
186
|
+
</div>
|
|
187
|
+
))}
|
|
188
|
+
</div>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* The threads begun on an earlier head, folded above the diff as GitHub folds an outdated thread:
|
|
194
|
+
* their lines may hold other code now, so they aren't drawn on it.
|
|
195
|
+
*/
|
|
196
|
+
function OutdatedThreads({
|
|
197
|
+
place,
|
|
198
|
+
threads,
|
|
199
|
+
reply,
|
|
200
|
+
}: {
|
|
201
|
+
readonly place: RepoPlace;
|
|
202
|
+
readonly threads: readonly (readonly LineComment[])[];
|
|
203
|
+
readonly reply: (first: LineComment) => ((body: string) => Promise<void>) | undefined;
|
|
204
|
+
}) {
|
|
205
|
+
if (threads.length === 0) return null;
|
|
206
|
+
|
|
207
|
+
return (
|
|
208
|
+
<Collapsible
|
|
209
|
+
aria-label="Outdated threads"
|
|
210
|
+
render={<section />}
|
|
211
|
+
className="border text-sm ring-1 ring-foreground/10"
|
|
212
|
+
>
|
|
213
|
+
<CollapsibleTrigger
|
|
214
|
+
render={<Button variant="ghost" className="group w-full justify-start" />}
|
|
215
|
+
>
|
|
216
|
+
<ChevronRightIcon
|
|
217
|
+
data-icon="inline-start"
|
|
218
|
+
className="transition-transform group-data-panel-open:rotate-90"
|
|
219
|
+
/>
|
|
220
|
+
{threads.length} outdated {threads.length === 1 ? 'thread' : 'threads'}
|
|
221
|
+
<span className="font-normal text-muted-foreground">, made on earlier commits</span>
|
|
222
|
+
</CollapsibleTrigger>
|
|
223
|
+
{/* Kept in the page while folded, as a details element keeps its threads, for find in page. */}
|
|
224
|
+
<CollapsibleContent hiddenUntilFound className="flex flex-col gap-2 border-t p-2">
|
|
225
|
+
{threads.map((thread) => {
|
|
226
|
+
const first = thread[0];
|
|
227
|
+
|
|
228
|
+
return (
|
|
229
|
+
first && (
|
|
230
|
+
<Thread
|
|
231
|
+
key={first.id}
|
|
232
|
+
repo={`${place.owner}/${place.repo}`}
|
|
233
|
+
comments={thread}
|
|
234
|
+
outdatedIn={place}
|
|
235
|
+
reply={reply(first)}
|
|
236
|
+
/>
|
|
237
|
+
)
|
|
238
|
+
);
|
|
239
|
+
})}
|
|
240
|
+
</CollapsibleContent>
|
|
241
|
+
</Collapsible>
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** A comment waiting in the viewer's review, until it's submitted, and its delete for the page's. */
|
|
246
|
+
function Pending({
|
|
247
|
+
repo,
|
|
248
|
+
login,
|
|
249
|
+
draft,
|
|
250
|
+
remove,
|
|
251
|
+
}: {
|
|
252
|
+
readonly repo: string;
|
|
253
|
+
readonly login: string;
|
|
254
|
+
readonly draft: LinePlace & { readonly body: string };
|
|
255
|
+
readonly remove: (() => void) | undefined;
|
|
256
|
+
}) {
|
|
257
|
+
return (
|
|
258
|
+
<div className="border-y bg-muted/30 p-3 font-sans text-sm whitespace-normal">
|
|
259
|
+
<article aria-label={`${login}'s pending comment`} className="border bg-background">
|
|
260
|
+
<header className="flex items-center justify-between gap-2 border-b px-3 py-1.5">
|
|
261
|
+
<span className="flex items-center gap-2">
|
|
262
|
+
<UserAvatar login={login} size="sm" account="user" />
|
|
263
|
+
<OwnerCard login={login} className="font-semibold">
|
|
264
|
+
{login}
|
|
265
|
+
</OwnerCard>
|
|
266
|
+
<Badge variant="outline">Pending</Badge>
|
|
267
|
+
<span className="text-meta text-muted-foreground">On {linesSaid(draft)}</span>
|
|
268
|
+
</span>
|
|
269
|
+
{remove !== undefined && (
|
|
270
|
+
<Button variant="destructive" size="sm" onClick={remove}>
|
|
271
|
+
Delete
|
|
272
|
+
</Button>
|
|
273
|
+
)}
|
|
274
|
+
</header>
|
|
275
|
+
<div className="px-3 py-2">
|
|
276
|
+
<Markdown text={draft.body} context={{ kind: 'comment', repo }} />
|
|
277
|
+
</div>
|
|
278
|
+
</article>
|
|
279
|
+
</div>
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* The box under picked lines: its comment posted alone, or kept for the review the viewer is
|
|
285
|
+
* writing, as GitHub's offers both until a review is started.
|
|
286
|
+
*/
|
|
287
|
+
function CommentForm({
|
|
288
|
+
repo,
|
|
289
|
+
place,
|
|
290
|
+
earlier,
|
|
291
|
+
typed,
|
|
292
|
+
reviewing,
|
|
293
|
+
single,
|
|
294
|
+
start,
|
|
295
|
+
cancel,
|
|
296
|
+
}: {
|
|
297
|
+
readonly repo: string;
|
|
298
|
+
readonly place: LinePlace;
|
|
299
|
+
/**
|
|
300
|
+
* What's typed so far, kept by the page: a push draws the diff, and this form, again, and the
|
|
301
|
+
* form starts from it.
|
|
302
|
+
*/
|
|
303
|
+
readonly typed: { current: string };
|
|
304
|
+
/**
|
|
305
|
+
* Whether the lines were picked before the latest commit: its comment posts there, and the form
|
|
306
|
+
* sits above the diff, which may not have the lines.
|
|
307
|
+
*/
|
|
308
|
+
readonly earlier: boolean;
|
|
309
|
+
readonly reviewing: boolean;
|
|
310
|
+
readonly single: (body: string) => Promise<void>;
|
|
311
|
+
readonly start: (body: string) => void;
|
|
312
|
+
readonly cancel: () => void;
|
|
313
|
+
}) {
|
|
314
|
+
const [body, setBody] = useState(typed.current);
|
|
315
|
+
const posted = useMutation({ mutationFn: single });
|
|
316
|
+
const empty = body.trim() === '';
|
|
317
|
+
|
|
318
|
+
return (
|
|
319
|
+
<section
|
|
320
|
+
aria-label={`Comment on ${linesSaid(place)}`}
|
|
321
|
+
data-hotkey-box
|
|
322
|
+
className={`flex flex-col gap-2 bg-muted/30 p-3 font-sans text-sm whitespace-normal ${earlier ? 'border' : 'border-y'}`}
|
|
323
|
+
>
|
|
324
|
+
<p className="text-sm text-muted-foreground">
|
|
325
|
+
Commenting on {linesSaid(place)}
|
|
326
|
+
{earlier && (
|
|
327
|
+
<>
|
|
328
|
+
{' of '}
|
|
329
|
+
<span className="font-mono">{place.path}</span> in an earlier commit, where it posts as
|
|
330
|
+
outdated
|
|
331
|
+
</>
|
|
332
|
+
)}
|
|
333
|
+
</p>
|
|
334
|
+
<MarkdownEditor
|
|
335
|
+
repo={repo}
|
|
336
|
+
autoFocus
|
|
337
|
+
label="Review comment"
|
|
338
|
+
value={body}
|
|
339
|
+
onChange={(text) => {
|
|
340
|
+
typed.current = text;
|
|
341
|
+
setBody(text);
|
|
342
|
+
}}
|
|
343
|
+
placeholder="Leave a comment"
|
|
344
|
+
/>
|
|
345
|
+
<div className="flex flex-wrap justify-end gap-2">
|
|
346
|
+
<Button variant="ghost" onClick={cancel}>
|
|
347
|
+
Cancel
|
|
348
|
+
</Button>
|
|
349
|
+
{!reviewing && (
|
|
350
|
+
<Button
|
|
351
|
+
variant="outline"
|
|
352
|
+
disabled={empty || posted.isPending}
|
|
353
|
+
onClick={() => posted.mutate(body)}
|
|
354
|
+
>
|
|
355
|
+
Add single comment
|
|
356
|
+
</Button>
|
|
357
|
+
)}
|
|
358
|
+
<Button
|
|
359
|
+
disabled={empty || posted.isPending}
|
|
360
|
+
onClick={() => start(body)}
|
|
361
|
+
data-hotkey={hotkeys.submit}
|
|
362
|
+
>
|
|
363
|
+
{reviewing ? 'Add review comment' : 'Start a review'}
|
|
364
|
+
<HotkeyHint keys={hotkeys.submit} />
|
|
365
|
+
</Button>
|
|
366
|
+
</div>
|
|
367
|
+
<Failed error={posted.error} />
|
|
368
|
+
</section>
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* **Review changes**' dialog: a summary, what the review says of the pull request, and its submit,
|
|
374
|
+
* with the drafts the page holds, or the viewer's pending review started elsewhere. It starts
|
|
375
|
+
* from the page's draft, and each change is the draft's too, so closing the dialog keeps it.
|
|
376
|
+
*/
|
|
377
|
+
function ReviewBox({
|
|
378
|
+
repo,
|
|
379
|
+
own,
|
|
380
|
+
start,
|
|
381
|
+
setDraft,
|
|
382
|
+
drafted,
|
|
383
|
+
earlier,
|
|
384
|
+
submit,
|
|
385
|
+
discard,
|
|
386
|
+
discardEarlier,
|
|
387
|
+
}: {
|
|
388
|
+
readonly repo: string;
|
|
389
|
+
/** Whether the viewer opened the pull request, who can neither approve it nor ask for changes. */
|
|
390
|
+
readonly own: boolean;
|
|
391
|
+
/** The draft as it is when the dialog opens. */
|
|
392
|
+
readonly start: () => ReviewDraft;
|
|
393
|
+
readonly setDraft: (change: (held: ReviewDraft) => ReviewDraft) => void;
|
|
394
|
+
readonly drafted: number;
|
|
395
|
+
/** How many of the drafts were written on an earlier head, and post there. */
|
|
396
|
+
readonly earlier: number;
|
|
397
|
+
readonly submit: (event: ReviewEvent, body: string) => Promise<void>;
|
|
398
|
+
/** Discards a pending review started elsewhere, and its comments, when there's one. */
|
|
399
|
+
readonly discard: (() => Promise<void>) | undefined;
|
|
400
|
+
readonly discardEarlier: () => void;
|
|
401
|
+
}) {
|
|
402
|
+
// Its own state answers at once, and each change is the page's draft too, which reopening reads.
|
|
403
|
+
const [{ body, event }, setHeld] = useState(start);
|
|
404
|
+
const change = (next: Partial<ReviewDraft>) => {
|
|
405
|
+
setHeld((held) => ({ ...held, ...next }));
|
|
406
|
+
setDraft((held) => ({ ...held, ...next }));
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
const acted = useMutation({ mutationFn: (act: () => Promise<void>) => act() });
|
|
410
|
+
// GitHub refuses a comment with nothing in it, and changes asked for with no word of which.
|
|
411
|
+
const empty = body.trim() === '';
|
|
412
|
+
const refused =
|
|
413
|
+
(event === 'COMMENT' && empty && drafted === 0) || (event === 'REQUEST_CHANGES' && empty);
|
|
414
|
+
const comments = drafted === 1 ? '1 pending comment' : `${drafted} pending comments`;
|
|
415
|
+
|
|
416
|
+
return (
|
|
417
|
+
<>
|
|
418
|
+
<DialogHeader>
|
|
419
|
+
<DialogTitle>
|
|
420
|
+
Finish your review
|
|
421
|
+
{drafted > 0 && <span className="font-normal text-muted-foreground"> · {comments}</span>}
|
|
422
|
+
</DialogTitle>
|
|
423
|
+
<DialogDescription className="sr-only">
|
|
424
|
+
A summary, and whether the review comments, approves or asks for changes.
|
|
425
|
+
</DialogDescription>
|
|
426
|
+
</DialogHeader>
|
|
427
|
+
{earlier > 0 && (
|
|
428
|
+
// Discarding them deletes them, so it's a destructive button after the line, not a link in it.
|
|
429
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
430
|
+
<p className="text-muted-foreground">
|
|
431
|
+
{earlier === 1 ? '1 comment was' : `${earlier} comments were`} written before the latest
|
|
432
|
+
commit, and {earlier === 1 ? 'posts' : 'post'} on the commit{' '}
|
|
433
|
+
{earlier === 1 ? 'it was' : 'they were'} written on, as outdated.
|
|
434
|
+
</p>
|
|
435
|
+
<Button variant="destructive" size="sm" onClick={discardEarlier}>
|
|
436
|
+
Discard {earlier === 1 ? 'it' : 'them'}
|
|
437
|
+
</Button>
|
|
438
|
+
</div>
|
|
439
|
+
)}
|
|
440
|
+
<MarkdownEditor
|
|
441
|
+
repo={repo}
|
|
442
|
+
label="Review summary"
|
|
443
|
+
value={body}
|
|
444
|
+
onChange={(next) => change({ body: next })}
|
|
445
|
+
placeholder="Leave a comment"
|
|
446
|
+
/>
|
|
447
|
+
<RadioGroup
|
|
448
|
+
aria-label="What the review says"
|
|
449
|
+
value={event}
|
|
450
|
+
onValueChange={(value) => {
|
|
451
|
+
const picked = events.find((each) => each.event === value);
|
|
452
|
+
if (picked !== undefined) change({ event: picked.event });
|
|
453
|
+
}}
|
|
454
|
+
>
|
|
455
|
+
{events.map((each) => {
|
|
456
|
+
const barred = own && each.event !== 'COMMENT';
|
|
457
|
+
const id = `review-event-${each.event}`;
|
|
458
|
+
|
|
459
|
+
return (
|
|
460
|
+
<Field key={each.event} orientation="horizontal" data-disabled={barred || undefined}>
|
|
461
|
+
<RadioGroupItem id={id} value={each.event} disabled={barred} />
|
|
462
|
+
<FieldContent>
|
|
463
|
+
<FieldLabel htmlFor={id}>{each.name}</FieldLabel>
|
|
464
|
+
<FieldDescription>
|
|
465
|
+
{barred ? 'Pull request authors can’t review their own pull request.' : each.says}
|
|
466
|
+
</FieldDescription>
|
|
467
|
+
</FieldContent>
|
|
468
|
+
</Field>
|
|
469
|
+
);
|
|
470
|
+
})}
|
|
471
|
+
</RadioGroup>
|
|
472
|
+
<Failed error={acted.error} />
|
|
473
|
+
<DialogFooter>
|
|
474
|
+
{discard !== undefined && (
|
|
475
|
+
<ConfirmAction
|
|
476
|
+
label="Discard pending review"
|
|
477
|
+
title={`Discard your review and its ${comments}?`}
|
|
478
|
+
description="Its summary and its comments are deleted. This can’t be undone."
|
|
479
|
+
confirm="Discard review"
|
|
480
|
+
size="default"
|
|
481
|
+
className="sm:mr-auto"
|
|
482
|
+
disabled={acted.isPending}
|
|
483
|
+
onConfirm={() => acted.mutate(discard)}
|
|
484
|
+
/>
|
|
485
|
+
)}
|
|
486
|
+
<DialogClose render={<Button variant="outline" />}>Cancel</DialogClose>
|
|
487
|
+
<Button
|
|
488
|
+
disabled={refused || acted.isPending}
|
|
489
|
+
onClick={() => acted.mutate(() => submit(event, body))}
|
|
490
|
+
data-hotkey={hotkeys.submit}
|
|
491
|
+
>
|
|
492
|
+
Submit review
|
|
493
|
+
<HotkeyHint keys={hotkeys.submit} />
|
|
494
|
+
</Button>
|
|
495
|
+
</DialogFooter>
|
|
496
|
+
</>
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* A pull request's Files changed: its diff, the review comments on its lines in threads, and, for
|
|
502
|
+
* those the drop-in lets review it, a comment on lines picked from the gutter, posted alone or
|
|
503
|
+
* kept for a review the viewer submits as a comment, an approval or changes requested. The page
|
|
504
|
+
* holds a review's drafts until it's submitted; a pending review started elsewhere shows, and is
|
|
505
|
+
* submitted or discarded here.
|
|
506
|
+
*/
|
|
507
|
+
export function PullFiles({
|
|
508
|
+
place,
|
|
509
|
+
pull,
|
|
510
|
+
}: {
|
|
511
|
+
readonly place: RepoPlace;
|
|
512
|
+
readonly pull: PullDetail;
|
|
513
|
+
}) {
|
|
514
|
+
const client = useQueryClient();
|
|
515
|
+
const { viewer } = useRouteContext({ from: '__root__' });
|
|
516
|
+
const allowed = useAllowed(place, pull.number);
|
|
517
|
+
const repo = `${place.owner}/${place.repo}`;
|
|
518
|
+
const base = useQuery(mergeBaseOf(place, pull)).data;
|
|
519
|
+
const comments = useQuery(lineCommentsOf(place, pull.number));
|
|
520
|
+
const pending = useQuery(reviewsOf(place, pull.number)).data?.find(
|
|
521
|
+
(review) => review.state === 'PENDING',
|
|
522
|
+
);
|
|
523
|
+
const elsewhere = useQuery({
|
|
524
|
+
...pendingCommentsOf(place, pull.number, pending?.id),
|
|
525
|
+
enabled: pending !== undefined,
|
|
526
|
+
});
|
|
527
|
+
const drafts = useQuery(draftsOf(place, pull.number)).data ?? [];
|
|
528
|
+
// The lines picked, and the head whose diff they were picked from, which a push may move on from.
|
|
529
|
+
const [picked, setPicked] = useState<(LinePlace & { readonly head: string }) | undefined>();
|
|
530
|
+
const typed = useRef('');
|
|
531
|
+
const [reviewing, setReviewing] = useState(false);
|
|
532
|
+
const login = viewer?.login;
|
|
533
|
+
const canReview = allowed.has('pull.review') && login !== undefined;
|
|
534
|
+
|
|
535
|
+
const setDrafts = (change: (held: readonly Draft[]) => readonly Draft[]) =>
|
|
536
|
+
client.setQueryData(draftsOf(place, pull.number).queryKey, (held) => change(held ?? []));
|
|
537
|
+
|
|
538
|
+
// What **Review changes** holds, which closing it keeps, read as it opens.
|
|
539
|
+
const draftKey = reviewDraftOf(place, pull.number).queryKey;
|
|
540
|
+
const setDraft = (change: (held: ReviewDraft) => ReviewDraft) =>
|
|
541
|
+
client.setQueryData(draftKey, (held) => change(held ?? noReviewDraft));
|
|
542
|
+
|
|
543
|
+
// A pending review started elsewhere brings its summary, unless one's already typed.
|
|
544
|
+
const startDraft = () => {
|
|
545
|
+
const held = client.getQueryData(draftKey) ?? noReviewDraft;
|
|
546
|
+
const started = pending?.body ?? '';
|
|
547
|
+
|
|
548
|
+
return held.body === '' && started !== '' ? { ...held, body: started } : held;
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
const refresh = () => refreshReviews(client, place, pull.number);
|
|
552
|
+
|
|
553
|
+
const head = pull.head.sha;
|
|
554
|
+
const current = drafts.filter((draft) => draft.head === head);
|
|
555
|
+
|
|
556
|
+
// A reply joins no pending review: the drop-in adds none to one, so it waits until it's done.
|
|
557
|
+
const replyIn = (first: LineComment) =>
|
|
558
|
+
canReview && pending === undefined
|
|
559
|
+
? async (body: string) => {
|
|
560
|
+
await replyTo(place, pull, first, body);
|
|
561
|
+
await refresh();
|
|
562
|
+
}
|
|
563
|
+
: undefined;
|
|
564
|
+
|
|
565
|
+
const { notes, apart } = useMemo(() => {
|
|
566
|
+
const saved = onHead(comments.data ?? [], head);
|
|
567
|
+
const threads = new Map<number, LineComment[]>();
|
|
568
|
+
|
|
569
|
+
for (const comment of saved) {
|
|
570
|
+
const root = comment.replyTo ?? comment.id;
|
|
571
|
+
threads.set(root, [...(threads.get(root) ?? []), comment]);
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
const placed: readonly { readonly path: string; readonly note: DiffLineAnnotation<string> }[] =
|
|
575
|
+
[
|
|
576
|
+
...saved.flatMap((comment) =>
|
|
577
|
+
comment.replyTo === undefined ? [noteOn(comment, `thread:${comment.id}`)] : [],
|
|
578
|
+
),
|
|
579
|
+
...onHead(elsewhere.data ?? [], head).map((comment) =>
|
|
580
|
+
noteOn(comment, `pending:${comment.id}`),
|
|
581
|
+
),
|
|
582
|
+
...current.map((draft) => noteOn(draft, `draft:${draft.key}`)),
|
|
583
|
+
...(picked === undefined || picked.head !== head ? [] : [noteOn(picked, 'form')]),
|
|
584
|
+
];
|
|
585
|
+
|
|
586
|
+
const form = picked && (
|
|
587
|
+
<CommentForm
|
|
588
|
+
repo={repo}
|
|
589
|
+
place={picked}
|
|
590
|
+
earlier={picked.head !== head}
|
|
591
|
+
typed={typed}
|
|
592
|
+
reviewing={drafts.length > 0}
|
|
593
|
+
cancel={() => setPicked(undefined)}
|
|
594
|
+
single={async (body) => {
|
|
595
|
+
await commentOnLines(place, pull.number, { ...picked, body });
|
|
596
|
+
await refresh();
|
|
597
|
+
setPicked(undefined);
|
|
598
|
+
}}
|
|
599
|
+
start={(body) => {
|
|
600
|
+
setDrafts((held) => [...held, { ...picked, key: crypto.randomUUID(), body }]);
|
|
601
|
+
setPicked(undefined);
|
|
602
|
+
}}
|
|
603
|
+
/>
|
|
604
|
+
);
|
|
605
|
+
|
|
606
|
+
const render = (path: string, key: string) => {
|
|
607
|
+
const [kind = '', id = ''] = key.split(/:(.*)/);
|
|
608
|
+
|
|
609
|
+
switch (kind) {
|
|
610
|
+
case 'thread': {
|
|
611
|
+
const thread = threads.get(Number(id)) ?? [];
|
|
612
|
+
const first = thread[0];
|
|
613
|
+
|
|
614
|
+
return (
|
|
615
|
+
<Thread
|
|
616
|
+
repo={repo}
|
|
617
|
+
comments={thread}
|
|
618
|
+
reply={first === undefined ? undefined : replyIn(first)}
|
|
619
|
+
/>
|
|
620
|
+
);
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
case 'pending': {
|
|
624
|
+
const comment = elsewhere.data?.find((each) => each.id === Number(id));
|
|
625
|
+
|
|
626
|
+
return (
|
|
627
|
+
comment && (
|
|
628
|
+
<Pending repo={repo} login={comment.login} draft={comment} remove={undefined} />
|
|
629
|
+
)
|
|
630
|
+
);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
case 'draft': {
|
|
634
|
+
const draft = drafts.find((each) => each.key === id);
|
|
635
|
+
|
|
636
|
+
return (
|
|
637
|
+
draft && (
|
|
638
|
+
<Pending
|
|
639
|
+
repo={repo}
|
|
640
|
+
login={login ?? ''}
|
|
641
|
+
draft={draft}
|
|
642
|
+
remove={() => setDrafts((held) => held.filter((each) => each.key !== id))}
|
|
643
|
+
/>
|
|
644
|
+
)
|
|
645
|
+
);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
default:
|
|
649
|
+
return picked?.path === path && form;
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
|
|
653
|
+
const notes: Notes = {
|
|
654
|
+
of: (path) => placed.flatMap((each) => (each.path === path ? [each.note] : [])),
|
|
655
|
+
render,
|
|
656
|
+
// A pending review started elsewhere takes no drafts from here: the drop-in adds none to one.
|
|
657
|
+
pick:
|
|
658
|
+
canReview && pending === undefined
|
|
659
|
+
? (path, lines) => {
|
|
660
|
+
typed.current = '';
|
|
661
|
+
setPicked({ ...placeOfPick(path, lines), head });
|
|
662
|
+
}
|
|
663
|
+
: undefined,
|
|
664
|
+
};
|
|
665
|
+
|
|
666
|
+
// Lines picked before a push are an earlier commit's: the new diff may not have them, or have
|
|
667
|
+
// other lines there, so their form sits above it, until it's posted, held or cancelled.
|
|
668
|
+
return { notes, apart: picked?.head === head ? undefined : form };
|
|
669
|
+
}, [
|
|
670
|
+
comments.data,
|
|
671
|
+
elsewhere.data,
|
|
672
|
+
drafts,
|
|
673
|
+
current,
|
|
674
|
+
head,
|
|
675
|
+
picked,
|
|
676
|
+
canReview,
|
|
677
|
+
pending,
|
|
678
|
+
repo,
|
|
679
|
+
place,
|
|
680
|
+
pull,
|
|
681
|
+
login,
|
|
682
|
+
]);
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Submits the pending review started elsewhere, or the drafts as a review of the head they were
|
|
686
|
+
* written on, removing only those it sent: a draft added meanwhile stays.
|
|
687
|
+
*/
|
|
688
|
+
const submit = async (event: ReviewEvent, body: string) => {
|
|
689
|
+
if (pending !== undefined) {
|
|
690
|
+
await submitPending(place, pull.number, pending.id, { event, body });
|
|
691
|
+
} else {
|
|
692
|
+
const sent = drafts;
|
|
693
|
+
const heads = [...new Set(sent.map((draft) => draft.head))];
|
|
694
|
+
|
|
695
|
+
if (heads.length > 1) {
|
|
696
|
+
throw new Error(
|
|
697
|
+
'Your comments are on different commits: discard those written before the latest to submit the rest.',
|
|
698
|
+
);
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
await submitReview(place, pull.number, { event, body, head: heads[0] ?? head, drafts: sent });
|
|
702
|
+
setDrafts((held) => held.filter((draft) => !sent.includes(draft)));
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
setDraft(() => noReviewDraft);
|
|
706
|
+
setReviewing(false);
|
|
707
|
+
await refresh();
|
|
708
|
+
};
|
|
709
|
+
|
|
710
|
+
// Discarding a pending review is its author's, as `pull.review`, which the box already needs.
|
|
711
|
+
const discard =
|
|
712
|
+
pending === undefined
|
|
713
|
+
? undefined
|
|
714
|
+
: async () => {
|
|
715
|
+
await discardPending(place, pull.number, pending.id);
|
|
716
|
+
setDraft(() => noReviewDraft);
|
|
717
|
+
setReviewing(false);
|
|
718
|
+
await refresh();
|
|
719
|
+
};
|
|
720
|
+
|
|
721
|
+
const drafted = pending === undefined ? drafts.length : (elsewhere.data?.length ?? 0);
|
|
722
|
+
const earlier = pending === undefined ? drafts.length - current.length : 0;
|
|
723
|
+
|
|
724
|
+
return (
|
|
725
|
+
<div className="flex flex-col gap-3">
|
|
726
|
+
{canReview && (
|
|
727
|
+
<div className="flex flex-wrap items-center justify-end gap-2">
|
|
728
|
+
{pending !== undefined && (
|
|
729
|
+
<p className="mr-auto text-sm text-muted-foreground">
|
|
730
|
+
You have a pending review, started elsewhere. Submit or discard it to comment here.
|
|
731
|
+
</p>
|
|
732
|
+
)}
|
|
733
|
+
<Dialog open={reviewing} onOpenChange={setReviewing}>
|
|
734
|
+
<DialogTrigger render={<Button />}>
|
|
735
|
+
Review changes
|
|
736
|
+
{drafted > 0 && <Badge variant="secondary">{drafted}</Badge>}
|
|
737
|
+
</DialogTrigger>
|
|
738
|
+
{/* ⌘↵, or Ctrl+↵, in its summary clicks Submit review. */}
|
|
739
|
+
<DialogContent className="text-sm sm:max-w-2xl" data-hotkey-box>
|
|
740
|
+
<ReviewBox
|
|
741
|
+
repo={repo}
|
|
742
|
+
own={pull.author === login}
|
|
743
|
+
start={startDraft}
|
|
744
|
+
setDraft={setDraft}
|
|
745
|
+
drafted={drafted}
|
|
746
|
+
earlier={earlier}
|
|
747
|
+
submit={submit}
|
|
748
|
+
discard={discard}
|
|
749
|
+
discardEarlier={() =>
|
|
750
|
+
setDrafts((held) => held.filter((each) => each.head === head))
|
|
751
|
+
}
|
|
752
|
+
/>
|
|
753
|
+
</DialogContent>
|
|
754
|
+
</Dialog>
|
|
755
|
+
</div>
|
|
756
|
+
)}
|
|
757
|
+
<Failed error={comments.error ?? elsewhere.error} />
|
|
758
|
+
<OutdatedThreads
|
|
759
|
+
place={place}
|
|
760
|
+
threads={outdatedThreads(comments.data ?? [], head)}
|
|
761
|
+
reply={replyIn}
|
|
762
|
+
/>
|
|
763
|
+
{apart}
|
|
764
|
+
<DiffView
|
|
765
|
+
list={pullFiles(
|
|
766
|
+
repo,
|
|
767
|
+
pull.number,
|
|
768
|
+
head,
|
|
769
|
+
() => void refreshPull(client, place, pull.number),
|
|
770
|
+
)}
|
|
771
|
+
revisions={{ repo, base: base ?? pull.base.sha, head }}
|
|
772
|
+
notes={notes}
|
|
773
|
+
/>
|
|
774
|
+
</div>
|
|
775
|
+
);
|
|
776
|
+
}
|