Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- mods/diff/hooks/ask/armed-ask/armed-ask.ts +9 -0
- mods/diff/hooks/ask/armed-ask/index.ts +3 -0
- mods/diff/hooks/ask/ask-cut-note/ask-cut-note.ts +5 -0
- mods/diff/hooks/ask/ask-cut-note/index.ts +3 -0
- mods/diff/hooks/backend/types/backend-host/backend-host.ts +23 -0
- mods/diff/hooks/backend/types/backend-host/index.ts +3 -0
- mods/diff/hooks/backend/types/backend-probe/backend-probe.ts +10 -0
- mods/diff/hooks/backend/types/backend-probe/index.ts +3 -0
- mods/diff/hooks/backend/types/backend-words/backend-words.ts +29 -0
- mods/diff/hooks/backend/types/backend-words/index.ts +3 -0
- mods/diff/hooks/backend/types/backend/backend.ts +45 -0
- mods/diff/hooks/backend/types/backend/index.ts +3 -0
- mods/diff/hooks/backend/types/index.ts +6 -0
- mods/diff/hooks/classify/base-name-of/base-name-of.ts +7 -0
- mods/diff/hooks/classify/base-name-of/index.ts +3 -0
- mods/diff/hooks/classify/is-generated-file/generated-directories/generated-directories.ts +28 -0
- mods/diff/hooks/classify/is-generated-file/generated-directories/index.ts +3 -0
- mods/diff/hooks/classify/is-generated-file/generated-filename-patterns/generated-filename-patterns.ts +21 -0
- mods/diff/hooks/classify/is-generated-file/generated-filename-patterns/index.ts +3 -0
- mods/diff/hooks/classify/is-generated-file/generated-filenames/generated-filenames.ts +18 -0
- mods/diff/hooks/classify/is-generated-file/generated-filenames/index.ts +3 -0
- mods/diff/hooks/classify/is-generated-file/generated-suffixes/generated-suffixes.ts +15 -0
- mods/diff/hooks/classify/is-generated-file/generated-suffixes/index.ts +3 -0
- mods/diff/hooks/classify/is-generated-file/index.ts +7 -0
- mods/diff/hooks/classify/is-generated-file/is-generated-file.ts +29 -0
- mods/diff/hooks/classify/is-test-file/index.ts +5 -0
- mods/diff/hooks/classify/is-test-file/is-test-file.ts +21 -0
- mods/diff/hooks/classify/is-test-file/test-directories/index.ts +3 -0
- mods/diff/hooks/classify/is-test-file/test-directories/test-directories.ts +16 -0
- mods/diff/hooks/classify/is-test-file/test-filename-patterns/index.ts +3 -0
- mods/diff/hooks/classify/is-test-file/test-filename-patterns/test-filename-patterns.ts +11 -0
- mods/diff/hooks/classify/rooted-path-of/index.ts +3 -0
- mods/diff/hooks/classify/rooted-path-of/rooted-path-of.ts +8 -0
- mods/diff/hooks/limits/columns/auto-open-min-columns.ts +5 -0
- mods/diff/hooks/limits/columns/dialog-path-reserve.ts +5 -0
- mods/diff/hooks/limits/columns/index.ts +9 -0
- mods/diff/hooks/limits/columns/open-min-columns.ts +8 -0
- mods/diff/hooks/limits/columns/pane-right-pad-columns.ts +5 -0
- mods/diff/hooks/limits/columns/path-floor.ts +5 -0
- mods/diff/hooks/limits/columns/stat-cells.ts +5 -0
- mods/diff/hooks/limits/columns/widest-bucket-columns.ts +4 -0
- mods/diff/hooks/limits/sizes/bytes/host-output-cap-bytes.ts +5 -0
- mods/diff/hooks/limits/sizes/bytes/index.ts +4 -0
- mods/diff/hooks/limits/sizes/bytes/max-diff-bytes.ts +5 -0
- mods/diff/hooks/limits/sizes/index.ts +11 -0
- mods/diff/hooks/limits/sizes/max-files-for-details.ts +5 -0
- mods/diff/hooks/limits/sizes/max-files.ts +5 -0
- mods/diff/hooks/limits/sizes/max-lines-per-file.ts +5 -0
- mods/diff/hooks/limits/sizes/max-listed-directories.ts +9 -0
- mods/diff/hooks/limits/sizes/max-untracked-probes.ts +5 -0
mods/diff/hooks/ask/armed-ask/armed-ask.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The file the person asked about from the pane: its path and its diff as
|
| 3 |
+
* text, held until the next prompt carries it as context.
|
| 4 |
+
*/
|
| 5 |
+
export type ArmedAsk = {
|
| 6 |
+
path: string
|
| 7 |
+
text: string
|
| 8 |
+
lines: number
|
| 9 |
+
}
|
mods/diff/hooks/ask/armed-ask/index.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export type * from './armed-ask.js'
|
| 2 |
+
|
| 3 |
+
export * as default from '.'
|
mods/diff/hooks/ask/ask-cut-note/ask-cut-note.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The line an ask ends with when its diff was cut to fit the prompt.
|
| 3 |
+
*/
|
| 4 |
+
export const ASK_CUT_NOTE =
|
| 5 |
+
'(The rest of this diff was cut: it did not fit in the prompt.)'
|
mods/diff/hooks/ask/ask-cut-note/index.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from './ask-cut-note.js'
|
| 2 |
+
|
| 3 |
+
export * as default from '.'
|
mods/diff/hooks/backend/types/backend-host/backend-host.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type Git from '../../../git'
|
| 2 |
+
import type { Host } from '../../../host'
|
| 3 |
+
|
| 4 |
+
/**
|
| 5 |
+
* What pinning a backend takes from the bound host: its raw process runner,
|
| 6 |
+
* file probes, clock, session start and branch-base listener.
|
| 7 |
+
*
|
| 8 |
+
* Each backend names its own program, argv lead, environment and timeout
|
| 9 |
+
* to the runner; the session's start is read as it stands at each fetch
|
| 10 |
+
* (a later `session.start` moves it).
|
| 11 |
+
*/
|
| 12 |
+
export type BackendHost = Pick<Host, 'run' | 'readFile'> &
|
| 13 |
+
Pick<Git.GitDeps, 'mtimeOf' | 'entryKindsOf' | 'onBranchBase'> & {
|
| 14 |
+
/**
|
| 15 |
+
* The engine's clock, in milliseconds (`$.clock.now`).
|
| 16 |
+
*/
|
| 17 |
+
nowMs: () => Promise<number>
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* When the current session began, read at each fetch.
|
| 21 |
+
*/
|
| 22 |
+
sessionStartMsOf: () => number
|
| 23 |
+
}
|
mods/diff/hooks/backend/types/backend-host/index.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export type * from './backend-host.js'
|
| 2 |
+
|
| 3 |
+
export * as default from '.'
|
mods/diff/hooks/backend/types/backend-probe/backend-probe.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type { Backend } from '../backend'
|
| 2 |
+
import type { BackendHost } from '../backend-host'
|
| 3 |
+
|
| 4 |
+
/**
|
| 5 |
+
* Probes the session's directory for one backend's working tree: the
|
| 6 |
+
* backend when it holds the directory, else null.
|
| 7 |
+
*
|
| 8 |
+
* Null too where git should govern it instead (Git.gitBackendOf is git's).
|
| 9 |
+
*/
|
| 10 |
+
export type BackendProbe = (host: BackendHost) => Promise<Backend | null>
|
mods/diff/hooks/backend/types/backend-probe/index.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export type * from './backend-probe.js'
|
| 2 |
+
|
| 3 |
+
export * as default from '.'
|
mods/diff/hooks/backend/types/backend-words/backend-words.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The words the pane draws that name the backend.
|
| 3 |
+
*
|
| 4 |
+
* What uncommitted mode compares against, the command whose failure the
|
| 5 |
+
* empty state names, the tool that lists untracked files, and the note
|
| 6 |
+
* under an untracked row.
|
| 7 |
+
*/
|
| 8 |
+
export type BackendWords = {
|
| 9 |
+
/**
|
| 10 |
+
* What the working tree is compared with outside branch mode: `HEAD`.
|
| 11 |
+
*/
|
| 12 |
+
base: string
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* The command a failed fetch could not read: `git diff`.
|
| 16 |
+
*/
|
| 17 |
+
diffCommand: string
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* The program that lists untracked files: `git`.
|
| 21 |
+
*/
|
| 22 |
+
lister: string
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* The dim lines under an untracked row: what it is, and how to get its
|
| 26 |
+
* line counts (a pasteable command only when the path is safe to paste).
|
| 27 |
+
*/
|
| 28 |
+
untrackedNoteOf: (path: string, isPasteable: boolean) => readonly string[]
|
| 29 |
+
}
|
mods/diff/hooks/backend/types/backend-words/index.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export type * from './backend-words.js'
|
| 2 |
+
|
| 3 |
+
export * as default from '.'
|
mods/diff/hooks/backend/types/backend/backend.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import type Git from '../../../git'
|
| 2 |
+
import type { BackendWords } from '../backend-words'
|
| 3 |
+
|
| 4 |
+
/**
|
| 5 |
+
* The version-control system behind the pane, pinned once per session: its
|
| 6 |
+
* working tree, what it compares, how it words them, and the pane's reads.
|
| 7 |
+
*
|
| 8 |
+
* Git is the plugin's own backend; a host may install probes for others,
|
| 9 |
+
* consulted where no git working tree holds the directory (backendOf).
|
| 10 |
+
*/
|
| 11 |
+
export type Backend = {
|
| 12 |
+
/**
|
| 13 |
+
* The working tree's top; every row's path is relative to it.
|
| 14 |
+
*/
|
| 15 |
+
repository: Pick<Git.Repository, 'toplevel'>
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* What the picker offers to compare against, in its order.
|
| 19 |
+
*/
|
| 20 |
+
baseModes: readonly Git.BaseMode[]
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* The pane's words for what this backend compares and runs.
|
| 24 |
+
*/
|
| 25 |
+
words: BackendWords
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* One fetch of the working tree against the mode's base (Git.fetchDiff).
|
| 29 |
+
*/
|
| 30 |
+
fetchDiff: (mode: Git.BaseMode) => Promise<Git.FetchOutcome>
|
| 31 |
+
|
| 32 |
+
/**
|
| 33 |
+
* One row's hunks against the base its fetch read (Git.fetchFileHunks).
|
| 34 |
+
*/
|
| 35 |
+
fetchFileHunks: (
|
| 36 |
+
data: Git.DiffData,
|
| 37 |
+
file: Git.FileStat,
|
| 38 |
+
) => Promise<Git.FileHunks | null>
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* A string that changes when the checked-out commit moves
|
| 42 |
+
* (Git.headKeyOf); empty when it cannot be read this tick.
|
| 43 |
+
*/
|
| 44 |
+
headKeyOf: () => Promise<string>
|
| 45 |
+
}
|
mods/diff/hooks/backend/types/backend/index.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export type * from './backend.js'
|
| 2 |
+
|
| 3 |
+
export * as default from '.'
|
mods/diff/hooks/backend/types/index.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from './backend'
|
| 2 |
+
export * from './backend-host'
|
| 3 |
+
export * from './backend-probe'
|
| 4 |
+
export * from './backend-words'
|
| 5 |
+
|
| 6 |
+
export * as default from '.'
|
mods/diff/hooks/classify/base-name-of/base-name-of.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* A `/`-separated path's last segment: the file's own name.
|
| 3 |
+
*
|
| 4 |
+
* @param path the repository-relative path
|
| 5 |
+
* @returns the base name
|
| 6 |
+
*/
|
| 7 |
+
export const baseNameOf = (path: string) => path.split('/').at(-1) ?? path
|
mods/diff/hooks/classify/base-name-of/index.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from './base-name-of.js'
|
| 2 |
+
|
| 3 |
+
export * as default from '.'
|
mods/diff/hooks/classify/is-generated-file/generated-directories/generated-directories.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Path segments of build output, vendored code, caches and snapshots, the
|
| 3 |
+
* engine's excluded directories, matched against `/<path>`.
|
| 4 |
+
*/
|
| 5 |
+
export const GENERATED_DIRECTORIES = [
|
| 6 |
+
'/dist/',
|
| 7 |
+
'/build/',
|
| 8 |
+
'/out/',
|
| 9 |
+
'/output/',
|
| 10 |
+
'/node_modules/',
|
| 11 |
+
'/vendor/',
|
| 12 |
+
'/vendored/',
|
| 13 |
+
'/third_party/',
|
| 14 |
+
'/third-party/',
|
| 15 |
+
'/external/',
|
| 16 |
+
'/.next/',
|
| 17 |
+
'/.nuxt/',
|
| 18 |
+
'/.svelte-kit/',
|
| 19 |
+
'/coverage/',
|
| 20 |
+
'/__pycache__/',
|
| 21 |
+
'/.tox/',
|
| 22 |
+
'/venv/',
|
| 23 |
+
'/.venv/',
|
| 24 |
+
'/target/release/',
|
| 25 |
+
'/target/debug/',
|
| 26 |
+
'.generated/',
|
| 27 |
+
'/__snapshots__/',
|
| 28 |
+
] as const
|
mods/diff/hooks/classify/is-generated-file/generated-directories/index.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from './generated-directories.js'
|
| 2 |
+
|
| 3 |
+
export * as default from '.'
|
mods/diff/hooks/classify/is-generated-file/generated-filename-patterns/generated-filename-patterns.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* File-name shapes of generated code, the engine's excluded file-name
|
| 3 |
+
* patterns: minified, bundled, stubs, specs, snapshots.
|
| 4 |
+
*/
|
| 5 |
+
export const GENERATED_FILENAME_PATTERNS: readonly RegExp[] = Object.freeze([
|
| 6 |
+
/\.min\.[a-z]+$/i,
|
| 7 |
+
/-min\.[a-z]+$/i,
|
| 8 |
+
/\.bundle\.[a-z]+$/i,
|
| 9 |
+
/\.generated\.[a-z]+$/i,
|
| 10 |
+
/\.gen\.[a-z]+$/i,
|
| 11 |
+
/\.auto\.[a-z]+$/i,
|
| 12 |
+
/_generated\.[a-z]+$/i,
|
| 13 |
+
/_gen\.[a-z]+$/i,
|
| 14 |
+
/\.pb\.(?:go|js|ts|py|rb)$/i,
|
| 15 |
+
/_pb2?\.py$/i,
|
| 16 |
+
/\.pb\.h$/i,
|
| 17 |
+
/\.grpc\.[a-z]+$/i,
|
| 18 |
+
/\.swagger\.[a-z]+$/i,
|
| 19 |
+
/\.openapi\.[a-z]+$/i,
|
| 20 |
+
/\.snap$/i,
|
| 21 |
+
])
|
mods/diff/hooks/classify/is-generated-file/generated-filename-patterns/index.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from './generated-filename-patterns.js'
|
| 2 |
+
|
| 3 |
+
export * as default from '.'
|
mods/diff/hooks/classify/is-generated-file/generated-filenames/generated-filenames.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* File names (lowercase) that are lockfiles or shrinkwraps, never hand
|
| 3 |
+
* written, so their churn is noise in a diff.
|
| 4 |
+
*/
|
| 5 |
+
export const GENERATED_FILENAMES: ReadonlySet<string> = new Set([
|
| 6 |
+
'package-lock.json',
|
| 7 |
+
'yarn.lock',
|
| 8 |
+
'pnpm-lock.yaml',
|
| 9 |
+
'bun.lockb',
|
| 10 |
+
'bun.lock',
|
| 11 |
+
'composer.lock',
|
| 12 |
+
'gemfile.lock',
|
| 13 |
+
'cargo.lock',
|
| 14 |
+
'poetry.lock',
|
| 15 |
+
'pipfile.lock',
|
| 16 |
+
'shrinkwrap.json',
|
| 17 |
+
'npm-shrinkwrap.json',
|
| 18 |
+
])
|
mods/diff/hooks/classify/is-generated-file/generated-filenames/index.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from './generated-filenames.js'
|
| 2 |
+
|
| 3 |
+
export * as default from '.'
|
mods/diff/hooks/classify/is-generated-file/generated-suffixes/generated-suffixes.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Extensions, simple and compound (lowercase), of minified, bundled or
|
| 3 |
+
* generated output, the engine's excluded extensions.
|
| 4 |
+
*/
|
| 5 |
+
export const GENERATED_SUFFIXES = [
|
| 6 |
+
'.lock',
|
| 7 |
+
'.min.js',
|
| 8 |
+
'.min.css',
|
| 9 |
+
'.min.html',
|
| 10 |
+
'.bundle.js',
|
| 11 |
+
'.bundle.css',
|
| 12 |
+
'.generated.ts',
|
| 13 |
+
'.generated.js',
|
| 14 |
+
'.d.ts',
|
| 15 |
+
] as const
|
mods/diff/hooks/classify/is-generated-file/generated-suffixes/index.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from './generated-suffixes.js'
|
| 2 |
+
|
| 3 |
+
export * as default from '.'
|
mods/diff/hooks/classify/is-generated-file/index.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from './generated-directories'
|
| 2 |
+
export * from './generated-filename-patterns'
|
| 3 |
+
export * from './generated-filenames'
|
| 4 |
+
export * from './generated-suffixes'
|
| 5 |
+
export * from './is-generated-file.js'
|
| 6 |
+
|
| 7 |
+
export * as default from '.'
|
mods/diff/hooks/classify/is-generated-file/is-generated-file.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { baseNameOf } from '../base-name-of'
|
| 2 |
+
import { rootedPathOf } from '../rooted-path-of'
|
| 3 |
+
import { GENERATED_DIRECTORIES } from './generated-directories'
|
| 4 |
+
import { GENERATED_FILENAME_PATTERNS } from './generated-filename-patterns'
|
| 5 |
+
import { GENERATED_FILENAMES } from './generated-filenames'
|
| 6 |
+
import { GENERATED_SUFFIXES } from './generated-suffixes'
|
| 7 |
+
|
| 8 |
+
/**
|
| 9 |
+
* Whether a repository-relative path names generated or vendored content,
|
| 10 |
+
* by the Linguist-style rules the engine's own diff panel applies.
|
| 11 |
+
*
|
| 12 |
+
* @param path the file's path from the repository root, `/`-separated
|
| 13 |
+
* @returns whether the diff pane counts it among the tests and generated files
|
| 14 |
+
*/
|
| 15 |
+
export function isGeneratedFile(path: string) {
|
| 16 |
+
const name = baseNameOf(path).toLowerCase()
|
| 17 |
+
const rooted = rootedPathOf(path)
|
| 18 |
+
|
| 19 |
+
const hasGeneratedSuffix = GENERATED_SUFFIXES.some(suffix =>
|
| 20 |
+
name.endsWith(suffix),
|
| 21 |
+
)
|
| 22 |
+
|
| 23 |
+
return (
|
| 24 |
+
GENERATED_FILENAMES.has(name) ||
|
| 25 |
+
hasGeneratedSuffix ||
|
| 26 |
+
GENERATED_DIRECTORIES.some(directory => rooted.includes(directory)) ||
|
| 27 |
+
GENERATED_FILENAME_PATTERNS.some(pattern => pattern.test(name))
|
| 28 |
+
)
|
| 29 |
+
}
|
mods/diff/hooks/classify/is-test-file/index.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from './is-test-file.js'
|
| 2 |
+
export * from './test-directories'
|
| 3 |
+
export * from './test-filename-patterns'
|
| 4 |
+
|
| 5 |
+
export * as default from '.'
|
mods/diff/hooks/classify/is-test-file/is-test-file.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { baseNameOf } from '../base-name-of'
|
| 2 |
+
import { rootedPathOf } from '../rooted-path-of'
|
| 3 |
+
import { TEST_DIRECTORIES } from './test-directories'
|
| 4 |
+
import { TEST_FILENAME_PATTERNS } from './test-filename-patterns'
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Whether a repository-relative path is a test, spec, fixture or snapshot,
|
| 8 |
+
* by the same rules the engine's own diff panel applies.
|
| 9 |
+
*
|
| 10 |
+
* @param path the file's path from the repository root, `/`-separated
|
| 11 |
+
* @returns whether the diff pane counts it among the tests and generated files
|
| 12 |
+
*/
|
| 13 |
+
export function isTestFile(path: string) {
|
| 14 |
+
const name = baseNameOf(path)
|
| 15 |
+
const rooted = rootedPathOf(path)
|
| 16 |
+
|
| 17 |
+
return (
|
| 18 |
+
TEST_DIRECTORIES.some(directory => rooted.includes(directory)) ||
|
| 19 |
+
TEST_FILENAME_PATTERNS.some(pattern => pattern.test(name))
|
| 20 |
+
)
|
| 21 |
+
}
|
mods/diff/hooks/classify/is-test-file/test-directories/index.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from './test-directories.js'
|
| 2 |
+
|
| 3 |
+
export * as default from '.'
|
mods/diff/hooks/classify/is-test-file/test-directories/test-directories.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Path segments of tests, specs, mocks and fixtures, the engine's test
|
| 3 |
+
* directories, matched against `/<path>`.
|
| 4 |
+
*/
|
| 5 |
+
export const TEST_DIRECTORIES = [
|
| 6 |
+
'/test/',
|
| 7 |
+
'/tests/',
|
| 8 |
+
'/spec/',
|
| 9 |
+
'/specs/',
|
| 10 |
+
'/__tests__/',
|
| 11 |
+
'/__mocks__/',
|
| 12 |
+
'/__snapshots__/',
|
| 13 |
+
'/__fixtures__/',
|
| 14 |
+
'/fixtures/',
|
| 15 |
+
'/testdata/',
|
| 16 |
+
] as const
|
mods/diff/hooks/classify/is-test-file/test-filename-patterns/index.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from './test-filename-patterns.js'
|
| 2 |
+
|
| 3 |
+
export * as default from '.'
|
mods/diff/hooks/classify/is-test-file/test-filename-patterns/test-filename-patterns.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* File-name shapes of test files and snapshots, the engine's test file-name
|
| 3 |
+
* patterns.
|
| 4 |
+
*/
|
| 5 |
+
export const TEST_FILENAME_PATTERNS: readonly RegExp[] = Object.freeze([
|
| 6 |
+
/\.test\.[a-z]+$/i,
|
| 7 |
+
/\.spec\.[a-z]+$/i,
|
| 8 |
+
/_test\.[a-z]+$/i,
|
| 9 |
+
/_spec\.[a-z]+$/i,
|
| 10 |
+
/\.snap$/i,
|
| 11 |
+
])
|
mods/diff/hooks/classify/rooted-path-of/index.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from './rooted-path-of.js'
|
| 2 |
+
|
| 3 |
+
export * as default from '.'
|
mods/diff/hooks/classify/rooted-path-of/rooted-path-of.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* A path with exactly one leading `/`, so a directory pattern like `/test/`
|
| 3 |
+
* matches at the start of a relative path too.
|
| 4 |
+
*
|
| 5 |
+
* @param path the repository-relative path
|
| 6 |
+
* @returns the rooted path
|
| 7 |
+
*/
|
| 8 |
+
export const rootedPathOf = (path: string) => `/${path.replace(/^\/+/, '')}`
|
mods/diff/hooks/limits/columns/auto-open-min-columns.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The terminal width from which the first edit opens the pane when the person
|
| 3 |
+
* never said whether they want it (the built-in sidebar's own 144).
|
| 4 |
+
*/
|
| 5 |
+
export const AUTO_OPEN_MIN_COLUMNS = 144
|
mods/diff/hooks/limits/columns/dialog-path-reserve.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The cells an inline file row keeps off its path (DiffFileList's 16 for
|
| 3 |
+
* the counts, 3 for the pointer, 4 for the frame).
|
| 4 |
+
*/
|
| 5 |
+
export const DIALOG_PATH_RESERVE = 23
|
mods/diff/hooks/limits/columns/index.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from './auto-open-min-columns.js'
|
| 2 |
+
export * from './dialog-path-reserve.js'
|
| 3 |
+
export * from './open-min-columns.js'
|
| 4 |
+
export * from './pane-right-pad-columns.js'
|
| 5 |
+
export * from './path-floor.js'
|
| 6 |
+
export * from './stat-cells.js'
|
| 7 |
+
export * from './widest-bucket-columns.js'
|
| 8 |
+
|
| 9 |
+
export * as default from '.'
|
mods/diff/hooks/limits/columns/open-min-columns.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The terminal width from which `/diff` opens the pane (the built-in
|
| 3 |
+
* sidebar's own minimum).
|
| 4 |
+
*
|
| 5 |
+
* The first edit opens it from this width too, when the person kept it
|
| 6 |
+
* open before.
|
| 7 |
+
*/
|
| 8 |
+
export const OPEN_MIN_COLUMNS = 110
|
mods/diff/hooks/limits/columns/pane-right-pad-columns.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The blank column the docked pane keeps at its right edge, as the built-in
|
| 3 |
+
* sidebar's body does (its `paddingX`): rows wrap one column short of it.
|
| 4 |
+
*/
|
| 5 |
+
export const PANE_RIGHT_PAD_COLUMNS = 1
|
mods/diff/hooks/limits/columns/path-floor.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The fewest cells a docked file row gives its path, however narrow the
|
| 3 |
+
* pane (ReplDiffSidebar's 8).
|
| 4 |
+
*/
|
| 5 |
+
export const PATH_FLOOR = 8
|
mods/diff/hooks/limits/columns/stat-cells.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The cells a docked file row keeps for its `+N -M` (ReplDiffSidebar's 12):
|
| 3 |
+
* the path is cut from its start to the rest.
|
| 4 |
+
*/
|
| 5 |
+
export const STAT_CELLS = 12
|
mods/diff/hooks/limits/columns/widest-bucket-columns.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The terminal width from which `diff_pane_shown` reports `200_plus`.
|
| 3 |
+
*/
|
| 4 |
+
export const WIDEST_BUCKET_COLUMNS = 200
|
mods/diff/hooks/limits/sizes/bytes/host-output-cap-bytes.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* The most of a child's stdout `$.process.run` hands back, in bytes
|
| 3 |
+
* (process-host OUTPUT_LIMIT); a listing that long was cut, silently.
|
| 4 |
+
*/
|
| 5 |
+
export const HOST_OUTPUT_CAP_BYTES = 4 * 1024 * 1024
|
mods/diff/hooks/limits/sizes/bytes/index.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from './host-output-cap-bytes.js'
|
| 2 |
+
export * from './max-diff-bytes.js'
|
| 3 |
+
|
| 4 |
+
export * as default from '.'
|
mods/diff/hooks/limits/sizes/bytes/max-diff-bytes.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* A file whose unified diff text is longer than this is a "large file": its
|
| 3 |
+
* hunks are not parsed (the built-in panel's size cap).
|
| 4 |
+
*/
|
| 5 |
+
export const MAX_DIFF_BYTES = 1_000_000
|
mods/diff/hooks/limits/sizes/index.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export * from './bytes'
|
| 2 |
+
export * from './max-files.js'
|
| 3 |
+
export * from './max-files-for-details.js'
|
| 4 |
+
export * from './max-lines-per-file.js'
|
| 5 |
+
export * from './max-listed-directories.js'
|
| 6 |
+
export * from './max-untracked-probes.js'
|
| 7 |
+
export * from './max-visible-files.js'
|
| 8 |
+
export * from './pane'
|
| 9 |
+
export * from './prompt-context-max-chars.js'
|
| 10 |
+
|
| 11 |
+
export * as default from '.'
|
mods/diff/hooks/limits/sizes/max-files-for-details.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Past this many changed files the shortstat totals alone are kept: no
|
| 3 |
+
* per-file rows, no hunks, no untracked probe (the built-in panel's cap).
|
| 4 |
+
*/
|
| 5 |
+
export const MAX_FILES_FOR_DETAILS = 500
|
mods/diff/hooks/limits/sizes/max-files.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* How many per-file rows a diff keeps (the built-in panel's cap); the rest
|
| 3 |
+
* are counted as "not shown".
|
| 4 |
+
*/
|
| 5 |
+
export const MAX_FILES = 50
|
mods/diff/hooks/limits/sizes/max-lines-per-file.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* How many diff lines of one file are kept before the body is cut and the
|
| 3 |
+
* file reads as truncated (GitHub's auto-load limit, as the built-in's).
|
| 4 |
+
*/
|
| 5 |
+
export const MAX_LINES_PER_FILE = 400
|
mods/diff/hooks/limits/sizes/max-listed-directories.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* How many directories one fetch may list while dating its files; past it
|
| 3 |
+
* an untracked file reads as pre-session, a tracked one as session work.
|
| 4 |
+
*
|
| 5 |
+
* A walk lists only the distinct ancestors of the paths it dates (MAX_FILES
|
| 6 |
+
* tracked, MAX_UNTRACKED_PROBES untracked), so the budget in effect is the
|
| 7 |
+
* dated set's own directory count; this caps a pathological spread.
|
| 8 |
+
*/
|
| 9 |
+
export const MAX_LISTED_DIRECTORIES = 512
|
mods/diff/hooks/limits/sizes/max-untracked-probes.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* How many untracked paths get a timestamp probe per fetch; the rest read as
|
| 3 |
+
* pre-session, since only MAX_FILES rows could ever show.
|
| 4 |
+
*/
|
| 5 |
+
export const MAX_UNTRACKED_PROBES = 500
|