@emiliosp/pi-maestro 0.2.0 → 0.4.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.
@@ -1,68 +0,0 @@
1
- /**
2
- * Objective: Check whether product files differ from a commit.
3
- * Used: Before verifier handoffs and owner finding resolutions.
4
- */
5
-
6
- import { relative } from 'node:path';
7
- import { runGitCommand } from '#git/command.ts';
8
- import { getRepositoryStatus } from '#git/repository/getRepositoryStatus.ts';
9
-
10
- type HasProductChangesInput = {
11
- repositoryRoot: string;
12
- candidateCommit: string;
13
- workflowPath: string;
14
- handoffPath: string;
15
- };
16
-
17
- export const hasProductChanges = async ({
18
- repositoryRoot,
19
- candidateCommit,
20
- workflowPath,
21
- handoffPath,
22
- }: HasProductChangesInput): Promise<boolean> => {
23
- /*
24
- * Compare both the checkout and index with the candidate. The second diff
25
- * catches a product file that the verifier staged and then restored only on
26
- * disk.
27
- */
28
- const [diff, stagedDiff, status] = await Promise.all([
29
- runGitCommand({
30
- arguments: [
31
- 'diff',
32
- '--no-renames',
33
- '--name-only',
34
- '-z',
35
- candidateCommit,
36
- '--',
37
- ],
38
- cwd: repositoryRoot,
39
- }),
40
- runGitCommand({
41
- arguments: [
42
- 'diff',
43
- '--cached',
44
- '--no-renames',
45
- '--name-only',
46
- '-z',
47
- candidateCommit,
48
- '--',
49
- ],
50
- cwd: repositoryRoot,
51
- }),
52
- getRepositoryStatus(repositoryRoot),
53
- ]);
54
-
55
- const allowedPaths = new Set([
56
- relative(repositoryRoot, workflowPath),
57
- relative(repositoryRoot, handoffPath),
58
- ]);
59
-
60
- const changedTrackedPaths = [diff.stdout, stagedDiff.stdout]
61
- .flatMap((output) => output.split('\0'))
62
- .filter((path) => path.length > 0);
63
-
64
- return (
65
- changedTrackedPaths.some((path) => !allowedPaths.has(path)) ||
66
- status.untracked.some((path) => !allowedPaths.has(path))
67
- );
68
- };