@zukhruf/git-hooks 0.8.19 → 0.8.21

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.
Files changed (65) hide show
  1. package/dist/build.d.ts +1 -1
  2. package/dist/build.d.ts.map +1 -1
  3. package/dist/build.js +44 -46
  4. package/dist/build.js.map +1 -1
  5. package/dist/codegen.d.ts.map +1 -1
  6. package/dist/codegen.js +41 -8
  7. package/dist/codegen.js.map +1 -1
  8. package/dist/commit.d.ts +30 -2
  9. package/dist/commit.d.ts.map +1 -1
  10. package/dist/commit.js +261 -22
  11. package/dist/commit.js.map +1 -1
  12. package/dist/git.d.ts +3 -0
  13. package/dist/git.d.ts.map +1 -0
  14. package/dist/git.js +20 -0
  15. package/dist/git.js.map +1 -0
  16. package/dist/index.d.ts +2 -0
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/npm/lockfile.d.ts +14 -0
  20. package/dist/npm/lockfile.d.ts.map +1 -0
  21. package/dist/npm/lockfile.js +77 -0
  22. package/dist/npm/lockfile.js.map +1 -0
  23. package/dist/push.d.ts +14 -7
  24. package/dist/push.d.ts.map +1 -1
  25. package/dist/push.js +26 -82
  26. package/dist/push.js.map +1 -1
  27. package/dist/ref-update.d.ts +1 -1
  28. package/dist/ref-update.d.ts.map +1 -1
  29. package/dist/scripts/commit-msg.d.ts.map +1 -1
  30. package/dist/scripts/commit-msg.js +9 -15
  31. package/dist/scripts/commit-msg.js.map +1 -1
  32. package/dist/scripts/host.d.ts +10 -0
  33. package/dist/scripts/host.d.ts.map +1 -0
  34. package/dist/scripts/host.js +37 -0
  35. package/dist/scripts/host.js.map +1 -0
  36. package/dist/scripts/pre-commit.d.ts.map +1 -1
  37. package/dist/scripts/pre-commit.js +35 -13
  38. package/dist/scripts/pre-commit.js.map +1 -1
  39. package/dist/scripts/pre-push.d.ts.map +1 -1
  40. package/dist/scripts/pre-push.js +24 -24
  41. package/dist/scripts/pre-push.js.map +1 -1
  42. package/dist/snapshot/drift.d.ts +0 -2
  43. package/dist/snapshot/drift.d.ts.map +1 -1
  44. package/dist/snapshot/drift.js +5 -57
  45. package/dist/snapshot/drift.js.map +1 -1
  46. package/dist/snapshot/installs.d.ts +1 -0
  47. package/dist/snapshot/installs.d.ts.map +1 -1
  48. package/dist/snapshot/installs.js +85 -29
  49. package/dist/snapshot/installs.js.map +1 -1
  50. package/dist/snapshot/snapshot.d.ts +21 -0
  51. package/dist/snapshot/snapshot.d.ts.map +1 -0
  52. package/dist/snapshot/snapshot.js +52 -0
  53. package/dist/snapshot/snapshot.js.map +1 -0
  54. package/dist/snapshot/snapshots.d.ts +30 -0
  55. package/dist/snapshot/snapshots.d.ts.map +1 -0
  56. package/dist/snapshot/snapshots.js +181 -0
  57. package/dist/snapshot/snapshots.js.map +1 -0
  58. package/dist/sync.d.ts.map +1 -1
  59. package/dist/sync.js +16 -16
  60. package/dist/sync.js.map +1 -1
  61. package/dist/tree.d.ts +24 -0
  62. package/dist/tree.d.ts.map +1 -0
  63. package/dist/tree.js +96 -0
  64. package/dist/tree.js.map +1 -0
  65. package/package.json +4 -4
@@ -0,0 +1,181 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { mkdir, mkdtempDisposable, realpath } from 'node:fs/promises';
3
+ import { tmpdir } from 'node:os';
4
+ import { join } from 'node:path';
5
+ import { Latch, poll } from '@zukhruf/async';
6
+ import { FileLock } from '@zukhruf/fs';
7
+ import { gitIn } from "../git.js";
8
+ import { hasInstallDrift } from "./drift.js";
9
+ import { installFor, leaseInstall } from "./installs.js";
10
+ import { linkPackages } from "./packages.js";
11
+ export class MissingLockfileError extends Error {
12
+ constructor(commit) {
13
+ super(`${commit} has no package-lock.json`);
14
+ this.name = 'MissingLockfileError';
15
+ }
16
+ }
17
+ // The folder `git-hooks` in the common git folder of the repo, where both
18
+ // hooks keep the installs, the locks and the nx caches. Linked worktrees use
19
+ // the same one.
20
+ export async function stateFolder(git) {
21
+ const state = join((await git('rev-parse', '--path-format=absolute', '--git-common-dir')).trim(), 'git-hooks');
22
+ await mkdir(state, { recursive: true });
23
+ return state;
24
+ }
25
+ // The snapshots of one run of a hook: one clone of the repo for each commit,
26
+ // made at the first ask. The clone shares the objects of the repo
27
+ // (`git clone --shared`), so git copies none, and git commands in it see a
28
+ // clean checkout of the commit. A later ask for packages links a node_modules into the same clone. Disposing
29
+ // deletes each clone and lets each lock go.
30
+ export class Snapshots {
31
+ toolEnvironment;
32
+ #hook;
33
+ #root;
34
+ #git;
35
+ #notice;
36
+ #clock;
37
+ #stack = new AsyncDisposableStack();
38
+ #opened = new Map();
39
+ // The build lock, taken at the first open of a pre-push snapshot.
40
+ #holdBuildLock = memoized(() => this.#acquireBuildLock());
41
+ constructor({ hook, root, git, toolEnvironment, notice, clock, }) {
42
+ this.toolEnvironment = toolEnvironment;
43
+ this.#hook = hook;
44
+ this.#root = root;
45
+ this.#git = git;
46
+ this.#notice = notice;
47
+ this.#clock = clock;
48
+ }
49
+ // The clone of `commit`, with a node_modules when `packages` is true.
50
+ // `name` names the commit in a notice or an error.
51
+ async open(commit, name, packages) {
52
+ if (this.#hook === 'pre-push') {
53
+ await this.#holdBuildLock();
54
+ await this.#evictOtherThan(commit);
55
+ }
56
+ const opened = this.#opened.get(commit) ?? this.#start(commit);
57
+ const clone = await settled(opened.clone);
58
+ if (packages) {
59
+ opened.packages ??= outcomeOf(() => this.#link(clone, name, opened.resources));
60
+ await settled(opened.packages);
61
+ }
62
+ return clone;
63
+ }
64
+ // A clone of `commit` with packages that no other caller shares: a step
65
+ // that writes files writes them there, so the steps that read the shared
66
+ // snapshot never see them. Disposing it deletes the clone.
67
+ async openPrivate(commit, name) {
68
+ const resources = new AsyncDisposableStack();
69
+ try {
70
+ const clone = await this.#clone(commit, resources);
71
+ await this.#link(clone, name, resources);
72
+ return {
73
+ ...clone,
74
+ [Symbol.asyncDispose]: () => resources.disposeAsync(),
75
+ };
76
+ }
77
+ catch (error) {
78
+ await resources.disposeAsync();
79
+ throw error;
80
+ }
81
+ }
82
+ async [Symbol.asyncDispose]() {
83
+ for (const opened of this.#opened.values())
84
+ await opened.resources.disposeAsync();
85
+ this.#opened.clear();
86
+ await this.#stack.disposeAsync();
87
+ }
88
+ #start(commit) {
89
+ const resources = new AsyncDisposableStack();
90
+ const opened = {
91
+ clone: outcomeOf(() => this.#clone(commit, resources)),
92
+ packages: undefined,
93
+ resources,
94
+ };
95
+ this.#opened.set(commit, opened);
96
+ return opened;
97
+ }
98
+ // A push with many heads builds one head after another: the clone of an
99
+ // earlier head goes before the next one is made, as one build at a time
100
+ // used one folder at a time.
101
+ async #evictOtherThan(commit) {
102
+ for (const [other, opened] of this.#opened)
103
+ if (other !== commit) {
104
+ this.#opened.delete(other);
105
+ await opened.resources.disposeAsync();
106
+ }
107
+ }
108
+ async #acquireBuildLock() {
109
+ const lock = await acquire(join(await stateFolder(this.#git), 'build.lock'), () => this.#notice('waiting for another pre-push build in this repo'), this.#clock);
110
+ this.#stack.use(lock);
111
+ }
112
+ async #clone(commit, resources) {
113
+ const cache = join(await stateFolder(this.#git), this.#hook === 'pre-push' ? 'nx' : 'nx-pre-commit');
114
+ const temporary = resources.use(await mkdtempDisposable(join(tmpdir(), 'git-hooks-snapshot-')));
115
+ const folder = join(await realpath(temporary.path), 'tree');
116
+ await gitIn(temporary.path, this.toolEnvironment)('clone', '--shared', '--no-checkout', '--quiet', this.#root, folder);
117
+ await gitIn(folder, this.toolEnvironment)('checkout', '--detach', '--quiet', commit);
118
+ return {
119
+ folder,
120
+ nxCacheDirectory: cache,
121
+ environment: {
122
+ ...this.toolEnvironment,
123
+ NX_DAEMON: 'false',
124
+ NX_CACHE_DIRECTORY: cache,
125
+ NX_WORKSPACE_DATA_DIRECTORY: join(cache, 'workspace-data'),
126
+ },
127
+ };
128
+ }
129
+ // Uses the packages that the repo installed when they match the lockfile
130
+ // of the commit, and else an install of that lockfile in the state folder.
131
+ // The install, its prune and the lease on it happen under one lock, so a
132
+ // hook never deletes an install that a snapshot of another hook links to.
133
+ async #link(clone, name, resources) {
134
+ const lockfile = join(clone.folder, 'package-lock.json');
135
+ if (!existsSync(lockfile))
136
+ throw new MissingLockfileError(name);
137
+ if (!(await hasInstallDrift(lockfile, join(this.#root, 'node_modules/.package-lock.json'))))
138
+ return linkPackages(this.#root, clone.folder);
139
+ const state = await stateFolder(this.#git);
140
+ let installed;
141
+ {
142
+ using _ = await acquire(join(state, 'installs.lock'), () => this.#notice(`${name}: waiting for an install of another hook`), this.#clock);
143
+ installed = await installFor(state, clone.folder, this.toolEnvironment, () => this.#notice(`${name}: the installed packages differ from package-lock.json; installing it with npm ci (first time for this lockfile)`), this.#clock);
144
+ resources.use(leaseInstall(installed));
145
+ }
146
+ await linkPackages(installed, clone.folder);
147
+ }
148
+ }
149
+ // Takes the lock on the file at `path`, and waits while another process
150
+ // holds it.
151
+ async function acquire(path, waiting, clock) {
152
+ const lock = FileLock.open(path);
153
+ if (!lock.tryLock()) {
154
+ waiting();
155
+ await poll(async () => (lock.tryLock() ? true : undefined), {
156
+ interval: 200,
157
+ clock,
158
+ signal: undefined,
159
+ });
160
+ }
161
+ return lock;
162
+ }
163
+ // `work`, run at the first call; each later call waits for the same outcome.
164
+ function memoized(work) {
165
+ let outcome;
166
+ return () => settled((outcome ??= outcomeOf(work)));
167
+ }
168
+ // The outcome of `work`: it starts now, and each caller waits for the same
169
+ // outcome.
170
+ function outcomeOf(work) {
171
+ const outcome = new Latch();
172
+ void Promise.allSettled([Promise.try(work)]).then(([result]) => outcome.open(result));
173
+ return outcome;
174
+ }
175
+ async function settled(outcome) {
176
+ const result = await outcome.wait();
177
+ if (result.status === 'rejected')
178
+ throw result.reason;
179
+ return result.value;
180
+ }
181
+ //# sourceMappingURL=snapshots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshots.js","sourceRoot":"","sources":["../../src/snapshot/snapshots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAA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,MAAM,CAAC,EAAE,EAAE,CAC7D,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CACrB,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,KAAK,UAAU,OAAO,CAAI,OAAmB;IAC3C,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;IACpC,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU;QAAE,MAAM,MAAM,CAAC,MAAM,CAAC;IACtD,OAAO,MAAM,CAAC,KAAK,CAAC;AACtB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,KAAK,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAU/C,qBAAa,IAAK,SAAQ,IAAI,CAAC,MAAM,CAAC;;IACpC,QAAQ,CAAC,IAAI,UAAU;gBAGX,EACV,KAA6B,GAC9B,GAAE;QAAE,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;KAAO;IAK/B,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAmB5C"}
1
+ {"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,KAAK,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAQ/C,qBAAa,IAAK,SAAQ,IAAI,CAAC,MAAM,CAAC;;IACpC,QAAQ,CAAC,IAAI,UAAU;gBAGX,EACV,KAA6B,GAC9B,GAAE;QAAE,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;KAAO;IAK/B,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAuB5C"}
package/dist/sync.js CHANGED
@@ -1,13 +1,10 @@
1
- import { matchesGlob } from 'node:path';
2
1
  import { Step } from "./step.js";
3
- // Runs `nx sync`, then stages the files that it wrote. `sync.applyChanges`
4
- // in nx.json applies only in an interactive terminal, so a commit from a GUI
5
- // client or an agent shell would miss the synced files.
6
- //
7
- // A file counts as synced when it changed during the run and matches `stage`:
8
- // the file names that the repo's sync generators write. Any other change
9
- // during the run, or a file that was already modified before it, belongs to
10
- // another session that edits the same working tree.
2
+ // Runs `nx sync` on the staged commit, then stages the files that it wrote
3
+ // there and that match `stage`: the file names that the repo's sync
4
+ // generators write. `sync.applyChanges` in nx.json applies only in an
5
+ // interactive terminal, so a commit from a GUI client or an agent shell would
6
+ // miss the synced files. nx syncs the staged tree, not the working tree, so a
7
+ // file that another session edits is judged as the commit holds it.
11
8
  export class Sync extends Step {
12
9
  name = 'sync';
13
10
  #globs;
@@ -16,9 +13,13 @@ export class Sync extends Step {
16
13
  this.#globs = stage;
17
14
  }
18
15
  async run(commit) {
19
- const before = new Set(await commit.modified());
16
+ let generated;
20
17
  try {
21
- await commit.nx('sync');
18
+ generated = await commit.generate(this.#globs, async (snapshot) => {
19
+ const { status, stdout, stderr } = await snapshot.bin('nx', ['sync']);
20
+ if (status !== 0)
21
+ throw new Error(`nx sync exited with ${status}:\n${`${stdout}${stderr}`.trimEnd()}`);
22
+ });
22
23
  }
23
24
  catch (error) {
24
25
  // A failed sync is the step's outcome: the author reads nx's reason, not
@@ -27,12 +28,11 @@ export class Sync extends Step {
27
28
  throw error;
28
29
  return this.fail(error.message.trimEnd());
29
30
  }
30
- const synced = (await commit.modified()).filter((path) => !before.has(path) &&
31
- this.#globs.some((glob) => matchesGlob(path, glob)));
32
- if (synced.length === 0)
31
+ if (generated.kind === 'not-staged')
32
+ return this.fail(generated.reason);
33
+ if (generated.entries.length === 0)
33
34
  return this.pass('nx sync wrote nothing to stage');
34
- await commit.stage(synced);
35
- return this.pass(`staged what nx sync wrote: ${synced.join(', ')}`);
35
+ return this.pass(`staged what nx sync wrote: ${generated.entries.map(({ path }) => path).join(', ')}`);
36
36
  }
37
37
  }
38
38
  //# sourceMappingURL=sync.js.map
package/dist/sync.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sync.js","sourceRoot":"","sources":["../src/sync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,OAAO,EAAgB,IAAI,EAAE,MAAM,WAAW,CAAC;AAE/C,2EAA2E;AAC3E,6EAA6E;AAC7E,wDAAwD;AACxD,EAAE;AACF,8EAA8E;AAC9E,yEAAyE;AACzE,4EAA4E;AAC5E,oDAAoD;AACpD,MAAM,OAAO,IAAK,SAAQ,IAAY;IAC3B,IAAI,GAAG,MAAM,CAAC;IACd,MAAM,CAAoB;IAEnC,YAAY,EACV,KAAK,GAAG,CAAC,mBAAmB,CAAC,MACI,EAAE;QACnC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,MAAc;QACtB,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;QAChD,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,yEAAyE;YACzE,6BAA6B;YAC7B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;gBAAE,MAAM,KAAK,CAAC;YACvC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5C,CAAC;QACD,MAAM,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,CAC7C,CAAC,IAAI,EAAE,EAAE,CACP,CAAC,MAAM,CAAC,GAAG,CAAC,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,GAAG,MAAM,GAAG,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,CACpE,CAAC;YACN,CAAC,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,yEAAyE;YACzE,6BAA6B;YAC7B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;gBAAE,MAAM,KAAK,CAAC;YACvC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5C,CAAC;QACD,IAAI,SAAS,CAAC,IAAI,KAAK,YAAY;YAAE,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACxE,IAAI,SAAS,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC;YAChC,OAAO,IAAI,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC,IAAI,CACd,8BAA8B,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACrF,CAAC;IACJ,CAAC;CACF"}
package/dist/tree.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ import type { Git } from './git.ts';
2
+ export interface TreeEntry {
3
+ readonly path: string;
4
+ readonly kind: 'file' | 'link' | 'submodule';
5
+ }
6
+ export type DiffEntry = {
7
+ readonly change: 'added' | 'modified' | 'type-changed';
8
+ readonly path: string;
9
+ readonly kind: TreeEntry['kind'];
10
+ } | {
11
+ readonly change: 'deleted';
12
+ readonly path: string;
13
+ };
14
+ export declare class Tree {
15
+ #private;
16
+ readonly id: string;
17
+ private constructor();
18
+ static list(id: string, git: Git): Promise<Tree>;
19
+ entries(globs?: readonly string[]): readonly TreeEntry[];
20
+ read(path: string): Promise<string | undefined>;
21
+ }
22
+ export declare function matches(path: string, globs: readonly string[]): boolean;
23
+ export declare function changesBetween(git: Git, from: string | undefined, to: string): Promise<DiffEntry[]>;
24
+ //# sourceMappingURL=tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../src/tree.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAIpC,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,WAAW,CAAC;CAC9C;AAKD,MAAM,MAAM,SAAS,GACjB;IACE,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,UAAU,GAAG,cAAc,CAAC;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;CAClC,GACD;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAU1D,qBAAa,IAAI;;IACf,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAIpB,OAAO;WAWM,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAetD,OAAO,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,SAAS,EAAE;IAalD,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;CAKtD;AAID,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAEvE;AAKD,wBAAsB,cAAc,CAClC,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,SAAS,EAAE,CAAC,CAmBtB"}
package/dist/tree.js ADDED
@@ -0,0 +1,96 @@
1
+ import { posix } from 'node:path';
2
+ // Git's tree object: the paths of a commit, with the mode and the content of
3
+ // each. A tree does not change, so it lists its entries one time, when it is
4
+ // made, and a step that reads it judges one state of the commit, also when
5
+ // the index changes while the hook runs.
6
+ export class Tree {
7
+ id;
8
+ #git;
9
+ #entries;
10
+ constructor(id, git, entries) {
11
+ this.id = id;
12
+ this.#git = git;
13
+ this.#entries = entries;
14
+ }
15
+ // The tree `id` of the repo that `git` reads.
16
+ static async list(id, git) {
17
+ const output = await git('ls-tree', '-r', '-z', '--full-tree', id);
18
+ const entries = new Map();
19
+ for (const record of output.split('\0')) {
20
+ if (record === '')
21
+ continue;
22
+ // `<mode> SP <type> SP <object> TAB <path>`
23
+ const tab = record.indexOf('\t');
24
+ const [mode = '', , object = ''] = record.slice(0, tab).split(' ');
25
+ const path = record.slice(tab + 1);
26
+ entries.set(path, { path, kind: kindOf(mode), object });
27
+ }
28
+ return new Tree(id, git, entries);
29
+ }
30
+ // The entries whose path matches one of the globs, or each entry.
31
+ entries(globs) {
32
+ const entries = [...this.#entries.values()].map(({ path, kind }) => ({
33
+ path,
34
+ kind,
35
+ }));
36
+ return globs === undefined
37
+ ? entries
38
+ : entries.filter(({ path }) => matches(path, globs));
39
+ }
40
+ // The content of the file or the link at `path`, as UTF-8 text: the text of
41
+ // a link is the path that it points to. A submodule has no content in this
42
+ // repo.
43
+ async read(path) {
44
+ const entry = this.#entries.get(path);
45
+ if (entry === undefined || entry.kind === 'submodule')
46
+ return undefined;
47
+ return this.#git('cat-file', 'blob', entry.object);
48
+ }
49
+ }
50
+ // Whether `path` matches one of the globs. A path of a tree always uses `/`,
51
+ // so the globs match as on POSIX, also on Windows.
52
+ export function matches(path, globs) {
53
+ return globs.some((glob) => posix.matchesGlob(path, glob));
54
+ }
55
+ // The diff entries from the tree `from` to the tree `to`. With no `from`, the
56
+ // diff starts from the empty tree, so each entry of `to` is added. A rename is
57
+ // a deleted entry and an added entry.
58
+ export async function changesBetween(git, from, to) {
59
+ const base = from ?? (await git('hash-object', '-t', 'tree', '--stdin')).trim();
60
+ const output = await git('diff-tree', '-r', '-z', '--no-renames', base, to);
61
+ // `:<old mode> SP <new mode> SP <old object> SP <new object> SP <letter>`,
62
+ // then the path, each ended by NUL.
63
+ const fields = output.split('\0');
64
+ const changes = [];
65
+ for (let index = 0; index + 1 < fields.length; index += 2) {
66
+ const [, mode = '', , , letter = ''] = (fields[index] ?? '').split(' ');
67
+ const path = fields[index + 1] ?? '';
68
+ const change = changeOf(letter);
69
+ changes.push(change === 'deleted'
70
+ ? { change, path }
71
+ : { change, path, kind: kindOf(mode) });
72
+ }
73
+ return changes;
74
+ }
75
+ function kindOf(mode) {
76
+ if (mode === '120000')
77
+ return 'link';
78
+ if (mode === '160000')
79
+ return 'submodule';
80
+ return 'file';
81
+ }
82
+ function changeOf(letter) {
83
+ switch (letter) {
84
+ case 'A':
85
+ return 'added';
86
+ case 'M':
87
+ return 'modified';
88
+ case 'T':
89
+ return 'type-changed';
90
+ case 'D':
91
+ return 'deleted';
92
+ default:
93
+ throw new TypeError(`git diff-tree gave the change "${letter}", which a diff of two trees without renames never has`);
94
+ }
95
+ }
96
+ //# sourceMappingURL=tree.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tree.js","sourceRoot":"","sources":["../src/tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AA0BlC,6EAA6E;AAC7E,6EAA6E;AAC7E,2EAA2E;AAC3E,yCAAyC;AACzC,MAAM,OAAO,IAAI;IACN,EAAE,CAAS;IACX,IAAI,CAAM;IACV,QAAQ,CAA8B;IAE/C,YACE,EAAU,EACV,GAAQ,EACR,OAAoC;QAEpC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAChB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC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
- "version": "0.8.19",
3
+ "version": "0.8.21",
4
4
  "description": "Git hooks in TypeScript, a class per step. Pre-commit checks staged files with Prettier, stages only what nx sync wrote, and builds generated files. Commit-msg stops a subject whose scope nx release misreads. Pre-push builds pushed commits in snapshots.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -47,8 +47,8 @@
47
47
  "access": "public"
48
48
  },
49
49
  "dependencies": {
50
- "@zukhruf/async": "^0.8.19",
51
- "@zukhruf/fs": "^0.8.19"
50
+ "@zukhruf/async": "^0.8.21",
51
+ "@zukhruf/fs": "^0.8.21"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "eslint": "^9.30.0 || ^10.0.0",
@@ -64,7 +64,7 @@
64
64
  }
65
65
  },
66
66
  "devDependencies": {
67
- "@zukhruf/testing": "^0.8.19",
67
+ "@zukhruf/testing": "^0.8.21",
68
68
  "eslint": "^10.12.0",
69
69
  "jsonc-eslint-parser": "^3.3.0",
70
70
  "prettier": "^3.9.9"