@osdlc/repo-cleaner 0.22.0 → 0.24.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/CHANGELOG.md +28 -0
- package/README.md +17 -2
- package/dist/candidates.d.ts +42 -0
- package/dist/candidates.js +42 -0
- package/dist/clean.d.ts +36 -0
- package/dist/clean.js +163 -49
- package/dist/cli.js +23 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.js +8 -4
- package/dist/reference.js +6 -1
- package/dist/render.js +1 -1
- package/dist/resolve.d.ts +12 -1
- package/dist/resolve.js +15 -3
- package/dist/sweep.d.ts +5 -0
- package/dist/sweep.js +1 -0
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @osdlc/repo-cleaner
|
|
2
2
|
|
|
3
|
+
## 0.24.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 767c641: Add `--max-depth <n>`, and `maxDepth` on `sweep` and `resolveEntries`: how many levels below a directory target a checkout may sit and still be found. The default stays 3, now exported as `DEFAULT_MAX_DEPTH`. A value that is not a whole number, 1 or more, is refused, and a search that stops at the limit says `--max-depth` looks deeper.
|
|
8
|
+
|
|
9
|
+
## 0.23.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [3f84b08]
|
|
14
|
+
- @osdlc/typed-git@0.21.0
|
|
15
|
+
- @osdlc/typed-gh@0.19.2
|
|
16
|
+
|
|
17
|
+
## 0.23.1
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [1ba6088]
|
|
22
|
+
- @osdlc/typed-git@0.20.0
|
|
23
|
+
- @osdlc/typed-gh@0.19.1
|
|
24
|
+
|
|
25
|
+
## 0.23.0
|
|
26
|
+
|
|
27
|
+
### Minor Changes
|
|
28
|
+
|
|
29
|
+
- 32263e3: Add `candidatesOf` and `removeCandidate`, which hand a sweep's rows to a host as plain data and delete one of them with `run`'s checks, verification and archive-first. Export `fingerprint`, `sameFingerprint`, `PlanSchema`, `writeJsonAtomic` and `busyHolders`, and `isGlob` and `globRegExp`, the glob matching `--spare` uses, so a host spares rows the same way.
|
|
30
|
+
|
|
3
31
|
## 0.22.0
|
|
4
32
|
|
|
5
33
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -390,6 +390,7 @@ repo-cleaner dev run a develop
|
|
|
390
390
|
| | `--remote=<name>` | Branches on this remote; `*` is every remote. Repeatable, and combines with a bare `--remote`. |
|
|
391
391
|
| | `--all` | `--local` and `--remote`. |
|
|
392
392
|
| | `--worktrees`, `--branches` | Only worktrees, or only local branches. |
|
|
393
|
+
| | `--max-depth <n>` | How many levels below a directory target a checkout may sit and still be found. Default 3: `repos/<owner>/<repo>` from `~/dev`. A whole number, 1 or more. |
|
|
393
394
|
| how sure | `--fetch` | Fetch the default remote before judging local rows. Off by default. |
|
|
394
395
|
| | `--offline` | No fetch; judge from the refs on disk. Pull requests are still looked up; add `--provider none` for no network at all. |
|
|
395
396
|
| | `--against <remote>` | Judge every row against this remote's default branch. Without it, each remote's branches are judged against their own remote's default branch, and local rows against the default remote's. |
|
|
@@ -441,7 +442,7 @@ A target is what to sweep:
|
|
|
441
442
|
| Target | Swept |
|
|
442
443
|
| --- | --- |
|
|
443
444
|
| a checkout | that repository; a linked worktree sweeps the repository it belongs to |
|
|
444
|
-
| a directory | every checkout found under it, three levels deep at most |
|
|
445
|
+
| a directory | every checkout found under it, three levels deep at most; `--max-depth` changes that |
|
|
445
446
|
| a remote URL (`https://`, `ssh://`, `file://`, `user@host:path`) | its remote branches only, through a clone kept in the cache directory (see [A remote with no checkout](#a-remote-with-no-checkout)) |
|
|
446
447
|
|
|
447
448
|
No target is the same as naming the current directory: at a checkout's root
|
|
@@ -1237,7 +1238,11 @@ const receipt = run(preview)
|
|
|
1237
1238
|
| `check(plan, approval, opts?)` | Resolve `{ select, pick, spare, allow }` against the plan, sweep again, and return a `Preview`: the steps, the rows dropped and why, the allows no row needed, and `notes`, what the re-check judged without. Deletes nothing |
|
|
1238
1239
|
| `run(preview, opts?)` | Sweep once more and take the preview's steps, writing a `Receipt` (to `receiptPath` after every step, when given). `onNotes` hears what its own re-check judged without. Each worktree it removes is measured with `du` first, into the step's `freedBytes` |
|
|
1239
1240
|
| `inspectWorktree(path, opts?)` | One worktree judged as a sweep judges it, submodules included |
|
|
1240
|
-
| `
|
|
1241
|
+
| `candidatesOf(sweep)` | The sweep's deletable or objecting rows as plain data (`CleanCandidate`): id, kind, path, evidence, fingerprint, `requires`, blockers, risks |
|
|
1242
|
+
| `removeCandidate(candidate, opts?)` | Delete one candidate as `run` takes one row: archive first with `archive`, the live-process and unsafe-force checks, the removal, its verification. Returns a `CandidateRemoval` (`ok`, `steps`, `error`, and `archiveFailed` for a failed archive push, which a host should treat as fatal). Never throws for a refused or failed delete |
|
|
1243
|
+
| `readPlan`, `writePlan`, `PlanSchema` | Plans on disk |
|
|
1244
|
+
| `fingerprint`, `sameFingerprint` | The evidence a row rests on and the rule that compares two of them |
|
|
1245
|
+
| `writeJsonAtomic`, `busyHolders` | The atomic JSON write the receipt uses; the holders of a worktree that are not idle shells |
|
|
1241
1246
|
| `render` | The command line's formats: `text`, `json`, `summary`, `commands`, `preview`, `receipt` |
|
|
1242
1247
|
| `defaultProcessProbe`, `providers` | The defaults a host can wrap or replace |
|
|
1243
1248
|
| `RepoCleanerError` | Every refusal, with a `code`: `conflict`, `bad-input`, `not-found`, `ambiguous`, `spared-changed`, `bad-plan` |
|
|
@@ -1290,6 +1295,16 @@ host rarely has to veto one. It mostly sharpens the rows left at `keep` or
|
|
|
1290
1295
|
`review`. A worktree the host holds back keeps its branch: the sweep applies
|
|
1291
1296
|
that rule after the hook.
|
|
1292
1297
|
|
|
1298
|
+
### Taking one candidate at a time
|
|
1299
|
+
|
|
1300
|
+
A host that runs its own phases (discover, object, re-check, delete) uses
|
|
1301
|
+
`candidatesOf` and `removeCandidate` instead of `plan`, `check` and `run`. The
|
|
1302
|
+
host re-checks a candidate by sweeping again and comparing `fingerprint` with
|
|
1303
|
+
`sameFingerprint`, and turns `blockers` and `risks` into its own objections. It
|
|
1304
|
+
deletes what a branch `requires` (its worktree) first. `removeCandidate` keeps the safety model of
|
|
1305
|
+
`run`: a risk not in `allow` is refused, and with `archive` the push is made
|
|
1306
|
+
and verified before the delete, one archive per candidate.
|
|
1307
|
+
|
|
1293
1308
|
## Providers (prototype)
|
|
1294
1309
|
|
|
1295
1310
|
Pull request evidence comes from a provider. Classification reads the same
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A sweep's rows as plain data for a host that runs its own phases (a
|
|
3
|
+
* `git` plugin of host-cleaner): what could be deleted, what would object,
|
|
4
|
+
* and what it depends on. `removeCandidate` (in `clean.ts`) takes one back.
|
|
5
|
+
*/
|
|
6
|
+
import { type Action, type Blocker, type Kind, type Risk, type Row, type RowId, type Sweep, type Verdict } from './types.ts';
|
|
7
|
+
/** One row of a sweep, as data a host can compare, object to and hand back. */
|
|
8
|
+
export interface CleanCandidate {
|
|
9
|
+
/** The row id, `<kind>:<name>`. */
|
|
10
|
+
id: RowId;
|
|
11
|
+
kind: Kind;
|
|
12
|
+
/** The main checkout's root the row belongs to. */
|
|
13
|
+
repo: string;
|
|
14
|
+
/** A worktree's path; for a branch, its name; for a remote branch, `<remote>/<branch>`. */
|
|
15
|
+
path: string;
|
|
16
|
+
verdict: Verdict;
|
|
17
|
+
/** What deleting it does; null when it can never be deleted. */
|
|
18
|
+
action: Action | null;
|
|
19
|
+
/** One line, already phrased for a report. */
|
|
20
|
+
why: string;
|
|
21
|
+
/** The row's evidence, as the sweep read it. */
|
|
22
|
+
evidence: Row['evidence'];
|
|
23
|
+
/** The evidence a re-check compares with `sameFingerprint`. */
|
|
24
|
+
fingerprint: Record<string, unknown>;
|
|
25
|
+
/** The row ids this one cannot go without: a branch needs the worktree that has it checked out. */
|
|
26
|
+
requires?: RowId[];
|
|
27
|
+
/** Why it can never be deleted as things stand; one `refuse` objection each. */
|
|
28
|
+
blockers: Blocker[];
|
|
29
|
+
/** What its deletion loses; one `protest` objection each, allowed by name. */
|
|
30
|
+
risks: Risk[];
|
|
31
|
+
/** The repository's remote, where an archive is pushed; null without one. */
|
|
32
|
+
remote: string | null;
|
|
33
|
+
/** The ref the repository's local rows are judged against (`origin/main`), the base an archive is made on. */
|
|
34
|
+
landedRef: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The rows of `sweep` that could be deleted or that object to it: every row
|
|
38
|
+
* with an action or a blocker. Rows kept for structure (the primary
|
|
39
|
+
* worktree, a branch a worktree holds) are left out. A branch freed by its
|
|
40
|
+
* worktree `requires` that worktree.
|
|
41
|
+
*/
|
|
42
|
+
export declare function candidatesOf(sweep: Sweep): CleanCandidate[];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A sweep's rows as plain data for a host that runs its own phases (a
|
|
3
|
+
* `git` plugin of host-cleaner): what could be deleted, what would object,
|
|
4
|
+
* and what it depends on. `removeCandidate` (in `clean.ts`) takes one back.
|
|
5
|
+
*/
|
|
6
|
+
import { fingerprint } from "./plan.js";
|
|
7
|
+
import { landedFor, refOf, rowId, } from "./types.js";
|
|
8
|
+
/**
|
|
9
|
+
* The rows of `sweep` that could be deleted or that object to it: every row
|
|
10
|
+
* with an action or a blocker. Rows kept for structure (the primary
|
|
11
|
+
* worktree, a branch a worktree holds) are left out. A branch freed by its
|
|
12
|
+
* worktree `requires` that worktree.
|
|
13
|
+
*/
|
|
14
|
+
export function candidatesOf(sweep) {
|
|
15
|
+
return sweep.repos.flatMap((swept) => {
|
|
16
|
+
const repo = swept.repo;
|
|
17
|
+
if (repo === null)
|
|
18
|
+
return [];
|
|
19
|
+
return swept.rows
|
|
20
|
+
.filter((row) => row.action !== null || row.blockers.length > 0)
|
|
21
|
+
.map((row) => {
|
|
22
|
+
const worktree = row.kind === 'branch' ? row.evidence.worktree : undefined;
|
|
23
|
+
return {
|
|
24
|
+
id: row.id,
|
|
25
|
+
kind: row.kind,
|
|
26
|
+
repo: repo.root,
|
|
27
|
+
path: row.name,
|
|
28
|
+
verdict: row.verdict,
|
|
29
|
+
action: row.action,
|
|
30
|
+
why: row.why,
|
|
31
|
+
evidence: row.evidence,
|
|
32
|
+
fingerprint: fingerprint(row),
|
|
33
|
+
...(worktree === undefined ? {} : { requires: [rowId('worktree', worktree)] }),
|
|
34
|
+
blockers: [...row.blockers],
|
|
35
|
+
risks: [...row.risks],
|
|
36
|
+
remote: repo.remote,
|
|
37
|
+
// The archive's base, as `run` uses: the local rows' landed-against ref.
|
|
38
|
+
landedRef: refOf(landedFor(repo)),
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
package/dist/clean.d.ts
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
import { type ArchiveOptions } from './archive.ts';
|
|
30
30
|
import { type Approval, type ResolvedApproval } from './approval.ts';
|
|
31
31
|
import type { Annotate } from './hooks.ts';
|
|
32
|
+
import type { CleanCandidate } from './candidates.ts';
|
|
32
33
|
import { type Plan } from './plan.ts';
|
|
33
34
|
import { type Dropped, type Receipt, type Step } from './receipt.ts';
|
|
34
35
|
import { type Runners } from './sweep.ts';
|
|
@@ -136,4 +137,39 @@ export declare function check(plan: Plan, approval: Approval, opts?: CheckOption
|
|
|
136
137
|
* repository, as {@link check} does. Nothing has been touched.
|
|
137
138
|
*/
|
|
138
139
|
export declare function run(preview: Preview, opts?: RunOptions): Receipt;
|
|
140
|
+
export interface RemoveCandidateOptions extends Runners {
|
|
141
|
+
/** Where git runs from. A worktree the caller stands in is refused. Defaults to the process's cwd. */
|
|
142
|
+
cwd?: string | undefined;
|
|
143
|
+
/** The risks granted for this candidate. */
|
|
144
|
+
allow?: readonly Risk[] | undefined;
|
|
145
|
+
/** Archive unlanded work to the remote first, as `check` is given it. */
|
|
146
|
+
archive?: ArchiveOptions | undefined;
|
|
147
|
+
now?: (() => Date) | undefined;
|
|
148
|
+
/** Told after each step, with its `result` set. */
|
|
149
|
+
onStepDone?: ((step: Step) => void) | undefined;
|
|
150
|
+
}
|
|
151
|
+
/** What taking one candidate did. */
|
|
152
|
+
export interface CandidateRemoval {
|
|
153
|
+
/** Every step taken, the failed one last. Empty when the candidate was refused before any. */
|
|
154
|
+
steps: Step[];
|
|
155
|
+
ok: boolean;
|
|
156
|
+
/** The archive step failed, so nothing was deleted and a host should stop the whole run. */
|
|
157
|
+
archiveFailed: boolean;
|
|
158
|
+
/** Why it did not complete: the failed step's error, or the refusal. Null when `ok`. */
|
|
159
|
+
error: string | null;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Delete one candidate as `run` takes one row: the archive first when
|
|
163
|
+
* `archive` is given and the row holds unlanded work, then the live-process
|
|
164
|
+
* and unsafe-force checks, the removal and its verification, stopping at the
|
|
165
|
+
* first failure. The caller has already re-checked the candidate; this
|
|
166
|
+
* refuses only what is unsafe now.
|
|
167
|
+
*
|
|
168
|
+
* A worktree whose removal needs `git worktree prune` is refused when the
|
|
169
|
+
* prune would also drop another worktree of its repository, since this sees
|
|
170
|
+
* only the one row.
|
|
171
|
+
*
|
|
172
|
+
* Does not throw for a refused or failed delete: see `CandidateRemoval`.
|
|
173
|
+
*/
|
|
174
|
+
export declare function removeCandidate(candidate: CleanCandidate, opts?: RemoveCandidateOptions): CandidateRemoval;
|
|
139
175
|
export {};
|
package/dist/clean.js
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* verified, and the receipt is rewritten after each.
|
|
28
28
|
*/
|
|
29
29
|
import { existsSync } from 'node:fs';
|
|
30
|
-
import { join, resolve } from 'node:path';
|
|
30
|
+
import { isAbsolute, join, resolve, sep } from 'node:path';
|
|
31
31
|
import { shellJoin } from '@osdlc/command-seam';
|
|
32
32
|
import { nodeGuard } from '@osdlc/path-guard/node';
|
|
33
33
|
import { Git, PUSH_REJECTIONS } from '@osdlc/typed-git';
|
|
@@ -41,10 +41,29 @@ import { defaultCacheDir, mirrorProblem } from "./remote-mirror.js";
|
|
|
41
41
|
import { sizeOf } from "./size.js";
|
|
42
42
|
import { inspectSubmodules, submoduleHazards } from "./submodules.js";
|
|
43
43
|
import { holdFreedBranches, sweepRepo } from "./sweep.js";
|
|
44
|
-
import { KINDS, RepoCleanerError, judgedRemotes, landedFor, refOf, parseRowId, sweepNotes, } from "./types.js";
|
|
44
|
+
import { KINDS, RepoCleanerError, judgedRemotes, landedFor, refOf, makeRow, parseRowId, sweepNotes, } from "./types.js";
|
|
45
45
|
import { errorText } from "./util.js";
|
|
46
46
|
import { removeIsForced, worktreeCommands } from "./worktrees.js";
|
|
47
47
|
import { writeJsonAtomic } from "./write-json.js";
|
|
48
|
+
/**
|
|
49
|
+
* What `row` needs allowed, given `isAllowed`: the risks not granted
|
|
50
|
+
* (`missing`, phrased as asked, `discard-archived` where the archive covers
|
|
51
|
+
* one), the risks to ask for (`needs`), and whether the remove may discard
|
|
52
|
+
* changes or abandon unmerged work.
|
|
53
|
+
*/
|
|
54
|
+
function judgeRisks(row, isAllowed, archive, gitAt) {
|
|
55
|
+
const coverage = archive === undefined ? null : coverageOf(row, archive, gitAt);
|
|
56
|
+
// `discard-archived` grants the risks the archive covers, and only those.
|
|
57
|
+
const archived = (risk) => coverage?.covers.includes(risk) === true && isAllowed('discard-archived');
|
|
58
|
+
const grants = (risk) => isAllowed(risk) || archived(risk);
|
|
59
|
+
const asked = (risk) => (coverage?.covers.includes(risk) ? 'discard-archived' : risk);
|
|
60
|
+
return {
|
|
61
|
+
needs: [...new Set(row.risks.map(asked))],
|
|
62
|
+
missing: [...new Set(row.risks.filter((risk) => !grants(risk)).map(asked))],
|
|
63
|
+
discard: grants('discard-changes'),
|
|
64
|
+
abandon: grants('abandon-unmerged'),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
48
67
|
/**
|
|
49
68
|
* The plan repository's rows as they stand now, annotated as the sweep
|
|
50
69
|
* annotated them, and, when it had to sweep again, that sweep's notes on what
|
|
@@ -176,27 +195,18 @@ function recheck(plan, approval, opts) {
|
|
|
176
195
|
drop('changed', `planned ${JSON.stringify(was)}, now ${JSON.stringify(now)}`);
|
|
177
196
|
continue;
|
|
178
197
|
}
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
// `discard-archived` grants the risks the archive covers, and only those.
|
|
183
|
-
const archived = (risk) => coverage?.covers.includes(risk) === true && allowed(approval.allow, s, 'discard-archived');
|
|
184
|
-
const grants = (risk) => allowed(approval.allow, s, risk) || archived(risk);
|
|
185
|
-
// A risk the archive covers is asked for as `discard-archived`.
|
|
186
|
-
const asked = (risk) => coverage?.covers.includes(risk) ? 'discard-archived' : risk;
|
|
187
|
-
const needs = [...new Set(row.risks.map(asked))];
|
|
188
|
-
const missing = row.risks.filter((risk) => !grants(risk));
|
|
189
|
-
if (missing.length > 0) {
|
|
190
|
-
drop('not-allowed', `needs ${[...new Set(missing.map(asked))].join(', ')}`);
|
|
198
|
+
const judged = judgeRisks(row, (risk) => allowed(approval.allow, s, risk), opts.archive, (path) => new Git(path, { runner: opts.git }));
|
|
199
|
+
if (judged.missing.length > 0) {
|
|
200
|
+
drop('not-allowed', `needs ${judged.missing.join(', ')}`);
|
|
191
201
|
continue;
|
|
192
202
|
}
|
|
193
203
|
accepted.push({
|
|
194
204
|
repo: s.repo,
|
|
195
205
|
row,
|
|
196
|
-
discard:
|
|
197
|
-
abandon:
|
|
206
|
+
discard: judged.discard,
|
|
207
|
+
abandon: judged.abandon,
|
|
198
208
|
discardNamed: allowed(approval.allow, s, 'discard-changes'),
|
|
199
|
-
needs,
|
|
209
|
+
needs: judged.needs,
|
|
200
210
|
});
|
|
201
211
|
}
|
|
202
212
|
// A worktree judged safe because remote branches hold its HEAD loses that
|
|
@@ -745,6 +755,32 @@ measure, archive) {
|
|
|
745
755
|
}
|
|
746
756
|
}
|
|
747
757
|
}
|
|
758
|
+
/** Run one step and record how it went on the step: its `result`, `verification` and `error`. Never throws. */
|
|
759
|
+
function runStep(step, a, ctx, archive) {
|
|
760
|
+
try {
|
|
761
|
+
const done = execute(step, a, ctx.git, ctx.probe, ctx.removedHere, ctx.measure, {
|
|
762
|
+
...archive,
|
|
763
|
+
stamps: ctx.stamps,
|
|
764
|
+
});
|
|
765
|
+
if (done instanceof Gone) {
|
|
766
|
+
step.verification = done.verification;
|
|
767
|
+
step.gone = true;
|
|
768
|
+
}
|
|
769
|
+
else {
|
|
770
|
+
step.verification = done;
|
|
771
|
+
}
|
|
772
|
+
step.result = 'ok';
|
|
773
|
+
if (step.action === 'unlock-worktree')
|
|
774
|
+
ctx.unlocked.add(a.row.name);
|
|
775
|
+
}
|
|
776
|
+
catch (err) {
|
|
777
|
+
step.result = 'failed';
|
|
778
|
+
step.error = errorText(err);
|
|
779
|
+
if (a !== null && step.action !== 'unlock-worktree' && ctx.unlocked.has(a.row.name)) {
|
|
780
|
+
step.error += `; the lock on ${a.row.name} was cleared earlier in this run and is not restored`;
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
}
|
|
748
784
|
/**
|
|
749
785
|
* Take the steps `preview` showed: sweeps again, drops a row that moved since
|
|
750
786
|
* the preview, and runs the rest in order, compare-and-swap, verifying each
|
|
@@ -816,14 +852,13 @@ export function run(preview, opts = {}) {
|
|
|
816
852
|
const git = new Git(cwd, { runner: opts.git });
|
|
817
853
|
const probe = opts.probe ?? defaultProcessProbe();
|
|
818
854
|
const { removedHere } = planned;
|
|
819
|
-
// Worktrees whose lock this run cleared. typed-git has no `worktree lock`
|
|
820
|
-
// verb, so a failed remove cannot put the lock back; the receipt says so.
|
|
821
855
|
const unlocked = new Set();
|
|
822
856
|
// Steps that failed, or were skipped for one that did, each with the failed
|
|
823
857
|
// step at the root of it.
|
|
824
858
|
const blocked = [];
|
|
825
859
|
const stamps = new Map();
|
|
826
860
|
const measure = (path) => sizeOf(path, { du: opts.du, timeoutMs: opts.sizeTimeoutMs });
|
|
861
|
+
const ctx = { git, probe, removedHere, measure, unlocked, stamps };
|
|
827
862
|
for (const [i, [step, a]] of plannedSteps.entries()) {
|
|
828
863
|
const cause = blocked.find((b) => dependsOn(step, a, b.step, b.a));
|
|
829
864
|
if (cause !== undefined) {
|
|
@@ -835,44 +870,123 @@ export function run(preview, opts = {}) {
|
|
|
835
870
|
continue;
|
|
836
871
|
}
|
|
837
872
|
opts.onStep?.(i, plannedSteps.length, step);
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
stamps,
|
|
844
|
-
});
|
|
845
|
-
if (done instanceof Gone) {
|
|
846
|
-
step.verification = done.verification;
|
|
847
|
-
step.gone = true;
|
|
848
|
-
}
|
|
849
|
-
else {
|
|
850
|
-
step.verification = done;
|
|
851
|
-
}
|
|
852
|
-
step.result = 'ok';
|
|
853
|
-
if (step.action === 'unlock-worktree')
|
|
854
|
-
unlocked.add(a.row.name);
|
|
855
|
-
}
|
|
856
|
-
catch (err) {
|
|
857
|
-
step.result = 'failed';
|
|
858
|
-
step.error = errorText(err);
|
|
859
|
-
if (a !== null && step.action !== 'unlock-worktree' && unlocked.has(a.row.name)) {
|
|
860
|
-
step.error += `; the lock on ${a.row.name} was cleared earlier in this run and is not restored`;
|
|
861
|
-
}
|
|
862
|
-
// Told before the save, so a receipt that cannot be written still
|
|
863
|
-
// leaves the step's outcome on screen.
|
|
864
|
-
opts.onStepDone?.(i, plannedSteps.length, step);
|
|
873
|
+
runStep(step, a, ctx, { job: planned.archives.get(step), options: archive, now: now() });
|
|
874
|
+
// Told before the save, so a receipt that cannot be written still
|
|
875
|
+
// leaves the step's outcome on screen.
|
|
876
|
+
opts.onStepDone?.(i, plannedSteps.length, step);
|
|
877
|
+
if (step.result === 'failed') {
|
|
865
878
|
// A failed spared-tip check voids the plan's premise: nothing else runs.
|
|
866
879
|
if (step.action === 'verify-remote')
|
|
867
880
|
return finish('failed');
|
|
868
881
|
blocked.push({ step, a, root: step });
|
|
869
|
-
save();
|
|
870
|
-
continue;
|
|
871
882
|
}
|
|
872
|
-
opts.onStepDone?.(i, plannedSteps.length, step);
|
|
873
883
|
save();
|
|
874
884
|
}
|
|
875
885
|
if (blocked.length > 0)
|
|
876
886
|
return finish('failed');
|
|
877
887
|
return finish('complete');
|
|
878
888
|
}
|
|
889
|
+
/** The row a candidate stands for. */
|
|
890
|
+
function rowOfCandidate(c) {
|
|
891
|
+
return makeRow({
|
|
892
|
+
kind: c.kind,
|
|
893
|
+
name: c.path,
|
|
894
|
+
verdict: c.verdict,
|
|
895
|
+
action: c.action,
|
|
896
|
+
why: c.why,
|
|
897
|
+
risks: c.risks,
|
|
898
|
+
blockers: c.blockers,
|
|
899
|
+
evidence: c.evidence,
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Delete one candidate as `run` takes one row: the archive first when
|
|
904
|
+
* `archive` is given and the row holds unlanded work, then the live-process
|
|
905
|
+
* and unsafe-force checks, the removal and its verification, stopping at the
|
|
906
|
+
* first failure. The caller has already re-checked the candidate; this
|
|
907
|
+
* refuses only what is unsafe now.
|
|
908
|
+
*
|
|
909
|
+
* A worktree whose removal needs `git worktree prune` is refused when the
|
|
910
|
+
* prune would also drop another worktree of its repository, since this sees
|
|
911
|
+
* only the one row.
|
|
912
|
+
*
|
|
913
|
+
* Does not throw for a refused or failed delete: see `CandidateRemoval`.
|
|
914
|
+
*/
|
|
915
|
+
export function removeCandidate(candidate, opts = {}) {
|
|
916
|
+
const now = opts.now ?? (() => new Date());
|
|
917
|
+
const refused = (error) => ({
|
|
918
|
+
steps: [],
|
|
919
|
+
ok: false,
|
|
920
|
+
archiveFailed: false,
|
|
921
|
+
error,
|
|
922
|
+
});
|
|
923
|
+
const row = rowOfCandidate(candidate);
|
|
924
|
+
if (!runnable(row))
|
|
925
|
+
return refused(`refused: ${candidate.id} ${candidate.why}`);
|
|
926
|
+
const cwd = opts.cwd ?? process.cwd();
|
|
927
|
+
// Anchored without folding `..`, as the sweep does, so a `..` after a symlink is judged where it really is.
|
|
928
|
+
const absCwd = isAbsolute(cwd) ? cwd : `${process.cwd()}${sep}${cwd}`;
|
|
929
|
+
if (row.kind === 'worktree' && nodeGuard.contains(row.name, absCwd)) {
|
|
930
|
+
return refused(`refused: ${candidate.id} is the worktree the caller stands in`);
|
|
931
|
+
}
|
|
932
|
+
const allow = new Set(opts.allow ?? []);
|
|
933
|
+
let judged;
|
|
934
|
+
try {
|
|
935
|
+
judged = judgeRisks(row, (risk) => allow.has(risk), opts.archive, (path) => new Git(path, { runner: opts.git }));
|
|
936
|
+
}
|
|
937
|
+
catch (err) {
|
|
938
|
+
return refused(`refused: ${candidate.id}: ${errorText(err)}`);
|
|
939
|
+
}
|
|
940
|
+
if (judged.missing.length > 0) {
|
|
941
|
+
return refused(`refused: ${candidate.id} needs ${judged.missing.join(', ')}`);
|
|
942
|
+
}
|
|
943
|
+
const a = {
|
|
944
|
+
repo: candidate.repo,
|
|
945
|
+
row,
|
|
946
|
+
discard: judged.discard,
|
|
947
|
+
abandon: judged.abandon,
|
|
948
|
+
discardNamed: allow.has('discard-changes'),
|
|
949
|
+
needs: judged.needs,
|
|
950
|
+
};
|
|
951
|
+
const steps = stepsFor(a).map((step) => [step, a]);
|
|
952
|
+
let job;
|
|
953
|
+
if (opts.archive !== undefined && mayContribute(row)) {
|
|
954
|
+
if (candidate.remote === null) {
|
|
955
|
+
return refused(`archive: ${candidate.repo} has no remote to push the archive to`);
|
|
956
|
+
}
|
|
957
|
+
const step = pending(candidate.repo, row.id, 'archive', shellJoin(['git', 'push', candidate.remote, 'refs/heads/archive/<repo>-local-<date>']));
|
|
958
|
+
job = {
|
|
959
|
+
remote: candidate.remote,
|
|
960
|
+
defaultRef: candidate.landedRef,
|
|
961
|
+
jobs: [{ id: row.id, row, discardAllowed: a.discardNamed }],
|
|
962
|
+
};
|
|
963
|
+
steps.unshift([step, null]);
|
|
964
|
+
}
|
|
965
|
+
const ctx = {
|
|
966
|
+
git: new Git(cwd, { runner: opts.git }),
|
|
967
|
+
probe: opts.probe ?? defaultProcessProbe(),
|
|
968
|
+
removedHere: new Set(row.kind === 'worktree' ? [resolve(row.name)] : []),
|
|
969
|
+
measure: (path) => sizeOf(path, { du: opts.du }),
|
|
970
|
+
unlocked: new Set(),
|
|
971
|
+
stamps: new Map(),
|
|
972
|
+
};
|
|
973
|
+
const taken = [];
|
|
974
|
+
for (const [step, accepted] of steps) {
|
|
975
|
+
taken.push(step);
|
|
976
|
+
runStep(step, accepted, ctx, {
|
|
977
|
+
job: step.action === 'archive' ? job : undefined,
|
|
978
|
+
options: opts.archive,
|
|
979
|
+
now: now(),
|
|
980
|
+
});
|
|
981
|
+
opts.onStepDone?.(step);
|
|
982
|
+
if (step.result === 'failed') {
|
|
983
|
+
return {
|
|
984
|
+
steps: taken,
|
|
985
|
+
ok: false,
|
|
986
|
+
archiveFailed: step.action === 'archive',
|
|
987
|
+
error: step.error ?? 'failed',
|
|
988
|
+
};
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
return { steps: taken, ok: true, archiveFailed: false, error: null };
|
|
992
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -31,6 +31,7 @@ import { NO_STATUS_LINE, describeStep, describeSweep, statusLine, } from "./stat
|
|
|
31
31
|
import { formatBytes } from "./size.js";
|
|
32
32
|
import { stepBoard } from "./step-board.js";
|
|
33
33
|
import { sweptWith } from "./scope.js";
|
|
34
|
+
import { DEFAULT_MAX_DEPTH } from "./resolve.js";
|
|
34
35
|
import { sweep as sweepTargets } from "./sweep.js";
|
|
35
36
|
import { KINDS, RISKS, RepoCleanerError, sweepNotes, } from "./types.js";
|
|
36
37
|
const EXIT_NOTHING_TO_SWEEP = 10;
|
|
@@ -77,8 +78,25 @@ const SWEEP_FLAGS = {
|
|
|
77
78
|
valueName: 'name',
|
|
78
79
|
help: 'with remote rows: where pull requests come from',
|
|
79
80
|
},
|
|
81
|
+
maxDepth: {
|
|
82
|
+
kind: 'string',
|
|
83
|
+
valueName: 'n',
|
|
84
|
+
help: `how many levels below a directory target a checkout may sit (default ${DEFAULT_MAX_DEPTH})`,
|
|
85
|
+
},
|
|
80
86
|
progress: { kind: 'boolean', negatable: true, help: 'no progress line on stderr' },
|
|
81
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* `--max-depth` as a number. Throws a `bad-input` for anything but a whole
|
|
90
|
+
* number, 1 or more, written in digits.
|
|
91
|
+
*/
|
|
92
|
+
function maxDepthOf(raw) {
|
|
93
|
+
if (raw === undefined)
|
|
94
|
+
return undefined;
|
|
95
|
+
if (!/^[0-9]+$/.test(raw) || Number(raw) < 1) {
|
|
96
|
+
throw new RepoCleanerError('bad-input', `--max-depth takes a whole number, 1 or more; got ${JSON.stringify(raw)}`);
|
|
97
|
+
}
|
|
98
|
+
return Number(raw);
|
|
99
|
+
}
|
|
82
100
|
/** A repeatable flag that takes a row (or `risk[=row]`) each time, never split on commas. */
|
|
83
101
|
const rowList = (valueName, help) => ({
|
|
84
102
|
kind: 'list',
|
|
@@ -353,6 +371,7 @@ function sweepOptions(v, ctx, deps) {
|
|
|
353
371
|
...(v.branch === undefined ? {} : { branch: v.branch }),
|
|
354
372
|
...(v.against === undefined ? {} : { against: v.against }),
|
|
355
373
|
...(v.provider === undefined ? {} : { provider: v.provider }),
|
|
374
|
+
...(v.maxDepth === undefined ? {} : { maxDepth: maxDepthOf(v.maxDepth) }),
|
|
356
375
|
cacheDir: defaultCacheDir(ctx.env),
|
|
357
376
|
};
|
|
358
377
|
}
|
|
@@ -487,7 +506,10 @@ function cleanConflict(v, targets) {
|
|
|
487
506
|
// Every sweep flag given, so a new one cannot be missed here. `progress`
|
|
488
507
|
// only draws.
|
|
489
508
|
const given = Object.keys(SWEEP_FLAGS).filter((k) => k !== 'progress' && v[k] !== undefined && v[k] !== false);
|
|
490
|
-
const fixed = [
|
|
509
|
+
const fixed = [
|
|
510
|
+
...(targets.length > 0 ? ['targets'] : []),
|
|
511
|
+
...given.map((k) => `--${k.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}`),
|
|
512
|
+
];
|
|
491
513
|
if (fixed.length > 0)
|
|
492
514
|
return `--plan already fixed what is swept; drop ${fixed.join(', ')}`;
|
|
493
515
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,14 +14,18 @@
|
|
|
14
14
|
* which is why every row carries its evidence and why `notes` is a list.
|
|
15
15
|
*/
|
|
16
16
|
export { sweep, inspectWorktree, type Runners, type SweepOptions } from './sweep.ts';
|
|
17
|
-
export { PLAN_VERSION, plan, readPlan, writePlan, type Plan, type PlanRepo, type PlanRow, } from './plan.ts';
|
|
17
|
+
export { PLAN_VERSION, PlanSchema, fingerprint, plan, readPlan, sameFingerprint, writePlan, type Plan, type PlanRepo, type PlanRow, } from './plan.ts';
|
|
18
18
|
export { DEFAULT_MAX_FILE_BYTES, type ArchiveOptions, type LeftOut } from './archive.ts';
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
19
|
+
export { DEFAULT_MAX_DEPTH } from './resolve.ts';
|
|
20
|
+
export { isGlob, type Allow, type Approval, type ResolvedApproval, type Resolved, } from './approval.ts';
|
|
21
|
+
export { globRegExp } from './util.ts';
|
|
22
|
+
export { check, removeCandidate, run, type CandidateRemoval, type CheckOptions, type Preview, type RemoveCandidateOptions, type RunOptions, } from './clean.ts';
|
|
23
|
+
export { candidatesOf, type CleanCandidate } from './candidates.ts';
|
|
24
|
+
export { writeJsonAtomic } from './write-json.ts';
|
|
21
25
|
export { RECEIPT_VERSION, ReceiptSchema, type DropReason, type Dropped, type ArchiveRecord, type Receipt, type Step, } from './receipt.ts';
|
|
22
26
|
export { render, type RunSummary, type Style } from './render.ts';
|
|
23
27
|
export { formatBytes, sizeOf, type SizeOfOptions } from './size.ts';
|
|
24
|
-
export { defaultProcessProbe, type ProcessHolder, type ProcessProbe } from './processes.ts';
|
|
28
|
+
export { busyHolders, defaultProcessProbe, type ProcessHolder, type ProcessProbe, } from './processes.ts';
|
|
25
29
|
export { providers, type PrProvider, type ProviderChoice } from './providers/index.ts';
|
|
26
30
|
export type { Annotate } from './hooks.ts';
|
|
27
31
|
export { KINDS, RISKS, RepoCleanerError, judgedRemotes, landedFor, refOf, type Action, type Blocker, type BranchEvidence, type BranchRow, type Bucket, type Counts, type ErrorCode, type Kind, type LandedAgainst, type LandingEvidence, type PrEvidence, type RemoteEvidence, type RemoteInfo, type RemoteRow, type RepoInfo, type RepoNote, type RepoSweep, type Reclaimable, type Risk, type Row, type RowId, type SubmoduleEvidence, type Sweep, type SweepProgress, type SweptWith, type Verdict, type WorktreeEvidence, type WorktreeRow, } from './types.ts';
|
package/dist/index.js
CHANGED
|
@@ -14,13 +14,17 @@
|
|
|
14
14
|
* which is why every row carries its evidence and why `notes` is a list.
|
|
15
15
|
*/
|
|
16
16
|
export { sweep, inspectWorktree } from "./sweep.js";
|
|
17
|
-
export { PLAN_VERSION, plan, readPlan, writePlan, } from "./plan.js";
|
|
17
|
+
export { PLAN_VERSION, PlanSchema, fingerprint, plan, readPlan, sameFingerprint, writePlan, } from "./plan.js";
|
|
18
18
|
export { DEFAULT_MAX_FILE_BYTES } from "./archive.js";
|
|
19
|
-
export {} from "./
|
|
20
|
-
export {
|
|
19
|
+
export { DEFAULT_MAX_DEPTH } from "./resolve.js";
|
|
20
|
+
export { isGlob, } from "./approval.js";
|
|
21
|
+
export { globRegExp } from "./util.js";
|
|
22
|
+
export { check, removeCandidate, run, } from "./clean.js";
|
|
23
|
+
export { candidatesOf } from "./candidates.js";
|
|
24
|
+
export { writeJsonAtomic } from "./write-json.js";
|
|
21
25
|
export { RECEIPT_VERSION, ReceiptSchema, } from "./receipt.js";
|
|
22
26
|
export { render } from "./render.js";
|
|
23
27
|
export { formatBytes, sizeOf } from "./size.js";
|
|
24
|
-
export { defaultProcessProbe } from "./processes.js";
|
|
28
|
+
export { busyHolders, defaultProcessProbe, } from "./processes.js";
|
|
25
29
|
export { providers } from "./providers/index.js";
|
|
26
30
|
export { KINDS, RISKS, RepoCleanerError, judgedRemotes, landedFor, refOf, } from "./types.js";
|
package/dist/reference.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
const TARGETS = `Targets
|
|
7
7
|
A target is what to sweep:
|
|
8
8
|
a checkout that repository; a linked worktree sweeps the repository it belongs to
|
|
9
|
-
a directory every checkout found under it, three levels deep at most
|
|
9
|
+
a directory every checkout found under it, three levels deep at most;
|
|
10
|
+
--max-depth changes that
|
|
10
11
|
a remote URL its remote branches only, through a clone kept in the cache
|
|
11
12
|
directory (https://, ssh://, file://, or user@host:path)
|
|
12
13
|
No target sweeps the directory you are in, read the same way; in a subdirectory
|
|
@@ -24,6 +25,10 @@ const SWEEP = `What to look at (status, plan and clean)
|
|
|
24
25
|
--local --remote=upstream.
|
|
25
26
|
--worktrees Only worktrees, of the local rows.
|
|
26
27
|
--branches Only local branches, of the local rows.
|
|
28
|
+
--max-depth <n> How many levels below a directory target a checkout may
|
|
29
|
+
sit and still be found. Default 3, a whole number, 1 or
|
|
30
|
+
more. A search that stops short says how many directories
|
|
31
|
+
it left unopened.
|
|
27
32
|
Scope flags add up: --worktrees --remote is worktrees and the default remote's
|
|
28
33
|
branches.
|
|
29
34
|
|
package/dist/render.js
CHANGED
|
@@ -163,7 +163,7 @@ export function renderScan(sweep) {
|
|
|
163
163
|
const line = `searched ${entries}: ${dirs} read, ${found} found.`;
|
|
164
164
|
if (scan.depthLimited === 0)
|
|
165
165
|
return line;
|
|
166
|
-
return `${line} ${count(scan.depthLimited)} left unopened at the depth limit.`;
|
|
166
|
+
return `${line} ${count(scan.depthLimited)} left unopened at the depth limit; --max-depth looks deeper.`;
|
|
167
167
|
}
|
|
168
168
|
/** The one-line verdict a person reads first, and often only. */
|
|
169
169
|
export function renderTotals(sweep, style = PLAIN) {
|
package/dist/resolve.d.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* entry; when that finds nothing in a directory the checkout around it tracks,
|
|
14
14
|
* `sweep` widens it to that checkout.
|
|
15
15
|
*/
|
|
16
|
-
import { type Git } from '@osdlc/typed-git';
|
|
16
|
+
import { DEFAULT_MAX_DEPTH, type Git } from '@osdlc/typed-git';
|
|
17
17
|
import { type ScanStats, type UnresolvedEntry } from './types.ts';
|
|
18
18
|
export interface ResolveOptions {
|
|
19
19
|
/** Base for a relative entry. Defaults to the process's cwd. */
|
|
@@ -24,7 +24,18 @@ export interface ResolveOptions {
|
|
|
24
24
|
* somewhere it should not. Defaults to typed-git's line on stderr.
|
|
25
25
|
*/
|
|
26
26
|
onWarn?: ((message: string) => void) | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* How many levels below a directory entry a checkout may sit and still be
|
|
29
|
+
* found. Defaults to {@link DEFAULT_MAX_DEPTH}. Must be a whole number, 1 or more.
|
|
30
|
+
*/
|
|
31
|
+
maxDepth?: number | undefined;
|
|
27
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* How deep a directory entry is searched by default: a checkout up to three
|
|
35
|
+
* levels below it is found, such as `repos/<owner>/<repo>` from `~/dev`.
|
|
36
|
+
* typed-git's default, where 1 is the entry's direct children.
|
|
37
|
+
*/
|
|
38
|
+
export { DEFAULT_MAX_DEPTH };
|
|
28
39
|
export interface Resolution {
|
|
29
40
|
/** Main-checkout roots, de-duplicated and sorted. */
|
|
30
41
|
repos: string[];
|
package/dist/resolve.js
CHANGED
|
@@ -15,9 +15,15 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { homedir } from 'node:os';
|
|
17
17
|
import { isAbsolute, join, resolve as resolvePath } from 'node:path';
|
|
18
|
-
import { checkoutRoot, scanForCheckouts } from '@osdlc/typed-git';
|
|
19
|
-
import { emptyScan } from "./types.js";
|
|
18
|
+
import { DEFAULT_MAX_DEPTH, checkoutRoot, scanForCheckouts } from '@osdlc/typed-git';
|
|
19
|
+
import { emptyScan, RepoCleanerError } from "./types.js";
|
|
20
20
|
import { isDir } from "./util.js";
|
|
21
|
+
/**
|
|
22
|
+
* How deep a directory entry is searched by default: a checkout up to three
|
|
23
|
+
* levels below it is found, such as `repos/<owner>/<repo>` from `~/dev`.
|
|
24
|
+
* typed-git's default, where 1 is the entry's direct children.
|
|
25
|
+
*/
|
|
26
|
+
export { DEFAULT_MAX_DEPTH };
|
|
21
27
|
/** `~` and `~/x` against this user's home. Any other path is returned as-is. */
|
|
22
28
|
export function expandTilde(path, home = homedir()) {
|
|
23
29
|
if (path === '~')
|
|
@@ -38,6 +44,9 @@ export function isCheckoutRoot(dir) {
|
|
|
38
44
|
* worse than one that says which it could not find.
|
|
39
45
|
*/
|
|
40
46
|
export function resolveEntries(entries, opts) {
|
|
47
|
+
if (opts.maxDepth !== undefined && (!Number.isInteger(opts.maxDepth) || opts.maxDepth < 1)) {
|
|
48
|
+
throw new RepoCleanerError('bad-input', `maxDepth must be a whole number, 1 or more; got ${String(opts.maxDepth)}`);
|
|
49
|
+
}
|
|
41
50
|
const base = opts.baseDir ?? process.cwd();
|
|
42
51
|
const unresolved = [];
|
|
43
52
|
const byMainCheckout = new Set();
|
|
@@ -66,7 +75,10 @@ export function resolveEntries(entries, opts) {
|
|
|
66
75
|
unresolved.push({ entry, reason: 'not a readable git checkout' });
|
|
67
76
|
continue;
|
|
68
77
|
}
|
|
69
|
-
const search = scanForCheckouts(path,
|
|
78
|
+
const search = scanForCheckouts(path, {
|
|
79
|
+
maxDepth: opts.maxDepth ?? DEFAULT_MAX_DEPTH,
|
|
80
|
+
...(opts.onWarn === undefined ? {} : { onWarn: opts.onWarn }),
|
|
81
|
+
});
|
|
70
82
|
scan.containers += 1;
|
|
71
83
|
scan.directoriesScanned += search.directoriesScanned;
|
|
72
84
|
scan.depthLimited += search.depthLimited;
|
package/dist/sweep.d.ts
CHANGED
|
@@ -81,6 +81,11 @@ export interface SweepOptions extends Runners {
|
|
|
81
81
|
onProgress?: ((progress: SweepProgress) => void) | undefined;
|
|
82
82
|
/** Told, mid-walk, that a target directory is enormous. Defaults to stderr. */
|
|
83
83
|
onWarn?: ((message: string) => void) | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* How many levels below a directory target a checkout may sit and still be
|
|
86
|
+
* found. Defaults to `DEFAULT_MAX_DEPTH`, 3.
|
|
87
|
+
*/
|
|
88
|
+
maxDepth?: number | undefined;
|
|
84
89
|
}
|
|
85
90
|
/**
|
|
86
91
|
* Sweep `targets`: checkouts, directories to search for checkouts, or remote
|
package/dist/sweep.js
CHANGED
|
@@ -65,6 +65,7 @@ export function sweep(targets, opts = {}) {
|
|
|
65
65
|
git: new Git(cwd, { runner: opts.git }),
|
|
66
66
|
baseDir: cwd,
|
|
67
67
|
...(opts.onWarn === undefined ? {} : { onWarn: opts.onWarn }),
|
|
68
|
+
...(opts.maxDepth === undefined ? {} : { maxDepth: opts.maxDepth }),
|
|
68
69
|
};
|
|
69
70
|
let resolution = entries.length === 0
|
|
70
71
|
? { repos: [], unresolved: [], scan: emptyScan() }
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** This package's version, from its package.json when it was built. */
|
|
2
|
-
export declare const VERSION = "0.
|
|
2
|
+
export declare const VERSION = "0.24.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@osdlc/repo-cleaner",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "What has been merged into the default branch, and what can go away. Inventories local branches, worktrees and remote branches across one repository or many, classifying each with the evidence behind the verdict and the command that would act on it. Plans and applies approved deletes, compare-and-swap.",
|
|
5
5
|
"license": "MIT OR Apache-2.0",
|
|
6
6
|
"author": "sksizer",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"@osdlc/command-seam": "^0.15.1",
|
|
54
54
|
"@osdlc/file-lock": "^0.4.0",
|
|
55
55
|
"@osdlc/path-guard": "^0.3.1",
|
|
56
|
-
"@osdlc/typed-gh": "^0.19.
|
|
57
|
-
"@osdlc/typed-git": "^0.
|
|
56
|
+
"@osdlc/typed-gh": "^0.19.2",
|
|
57
|
+
"@osdlc/typed-git": "^0.21.0",
|
|
58
58
|
"@osdlc/ux": "^0.1.1"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|