@jameslnewell/git-diff 0.1.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/README.md +98 -0
- package/dist/diff.d.ts +79 -0
- package/dist/diff.js +219 -0
- package/dist/diff.js.map +1 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# @jameslnewell/git-diff
|
|
2
|
+
|
|
3
|
+
Utilities for obtaining the git diff status of files in a repository.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @jameslnewell/git-diff
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Diff Options
|
|
14
|
+
|
|
15
|
+
- `cwd?: string` The current working directory
|
|
16
|
+
- `base?: string` The base commit or branch to compare from
|
|
17
|
+
- `head?: string` The head commit or branch to compare to
|
|
18
|
+
|
|
19
|
+
### Async Diff
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import {diffAsync} from '@jameslnewell/git-diff';
|
|
23
|
+
|
|
24
|
+
const diff = await diffAsync({
|
|
25
|
+
base: 'main',
|
|
26
|
+
head: 'feature-branch',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const match = diff.match('prisma/*');
|
|
30
|
+
|
|
31
|
+
if (match.added || match.modified) {
|
|
32
|
+
// do something
|
|
33
|
+
// e.g. prisma generate && prisma migrate
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Sync Diff
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import {diffSync} from '@jameslnewell/git-diff';
|
|
41
|
+
|
|
42
|
+
const diff = diffSync({
|
|
43
|
+
base: 'main',
|
|
44
|
+
head: 'feature-branch',
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const match = diff.match('prisma/*');
|
|
48
|
+
|
|
49
|
+
if (match.added || match.modified) {
|
|
50
|
+
// do something
|
|
51
|
+
// e.g. prisma generate && prisma migrate
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Handling a non-existent `base`
|
|
56
|
+
|
|
57
|
+
A common use case is diffing against a mutable tag on CI/CD.
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import {diffAsync} from '@jameslnewell/git-diff';
|
|
61
|
+
|
|
62
|
+
const diff = await diffAsync({
|
|
63
|
+
base: 'last-deployment',
|
|
64
|
+
head: 'HEAD',
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
On the initial CI/CD run the mutable tag may not yet exist and `git diff` will error.
|
|
69
|
+
|
|
70
|
+
In order to handle this case its recommended you diff against the first commit instead.
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import {Diff, diffAsync, firstCommitAsync} from '@jameslnewell/git-diff';
|
|
74
|
+
|
|
75
|
+
const base = 'last-deployment';
|
|
76
|
+
const head = 'HEAD';
|
|
77
|
+
|
|
78
|
+
let diff: Diff;
|
|
79
|
+
try {
|
|
80
|
+
diff = await diffAsync({
|
|
81
|
+
base,
|
|
82
|
+
head,
|
|
83
|
+
});
|
|
84
|
+
} catch (error) {
|
|
85
|
+
if (error.code === 'BAD_REVISION') {
|
|
86
|
+
diff = await diffAsync({
|
|
87
|
+
base: await firstCommitAsync({ref: head}),
|
|
88
|
+
head,
|
|
89
|
+
});
|
|
90
|
+
} else {
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
MIT
|
package/dist/diff.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export type Path = string;
|
|
2
|
+
export type Status = 'A' | 'C' | 'D' | 'M' | 'R' | 'X';
|
|
3
|
+
export declare const Status: {
|
|
4
|
+
Added: "A";
|
|
5
|
+
Changed: "C";
|
|
6
|
+
Deleted: "D";
|
|
7
|
+
Modified: "M";
|
|
8
|
+
Renamed: "R";
|
|
9
|
+
Unknown: "X";
|
|
10
|
+
};
|
|
11
|
+
interface Match {
|
|
12
|
+
readonly added: boolean;
|
|
13
|
+
readonly changed: boolean;
|
|
14
|
+
readonly deleted: boolean;
|
|
15
|
+
readonly modified: boolean;
|
|
16
|
+
readonly renamed: boolean;
|
|
17
|
+
readonly unknown: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Cast a value to an array if its not already an array
|
|
21
|
+
*/
|
|
22
|
+
export declare function toArray<T>(value: T | T[] | undefined): T[];
|
|
23
|
+
/**
|
|
24
|
+
* A git diff result
|
|
25
|
+
*/
|
|
26
|
+
export declare class Diff implements Iterable<[Path, Status]> {
|
|
27
|
+
#private;
|
|
28
|
+
/**
|
|
29
|
+
* Constructs a diff
|
|
30
|
+
*/
|
|
31
|
+
constructor(diff?: Map<Path, Status> | Iterable<readonly [Path, Status]>);
|
|
32
|
+
[Symbol.iterator](): IterableIterator<[Path, Status]>;
|
|
33
|
+
/**
|
|
34
|
+
* Get the number of files in the diff
|
|
35
|
+
*/
|
|
36
|
+
size(): number;
|
|
37
|
+
/**
|
|
38
|
+
* Get the status and path for each entry in the diff
|
|
39
|
+
*/
|
|
40
|
+
entries(): MapIterator<[Path, Status]>;
|
|
41
|
+
/**
|
|
42
|
+
* Get the paths in the diff
|
|
43
|
+
*/
|
|
44
|
+
paths(): MapIterator<Path>;
|
|
45
|
+
/**
|
|
46
|
+
* Get the statuses in the diff
|
|
47
|
+
*/
|
|
48
|
+
statuses(): MapIterator<Status>;
|
|
49
|
+
/**
|
|
50
|
+
* Match the path(s)
|
|
51
|
+
*/
|
|
52
|
+
match(pathOrPaths: Path | Path[]): Match;
|
|
53
|
+
}
|
|
54
|
+
export interface DiffOptions {
|
|
55
|
+
cwd?: string | undefined;
|
|
56
|
+
base?: string | undefined;
|
|
57
|
+
head?: string | undefined;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Executes `git diff` to get the diff status of files
|
|
61
|
+
*/
|
|
62
|
+
export declare function diffAsync(options?: DiffOptions): Promise<Diff>;
|
|
63
|
+
/**
|
|
64
|
+
* Executes `git diff` to get the diff status of files
|
|
65
|
+
*/
|
|
66
|
+
export declare function diffSync(options?: DiffOptions): Diff;
|
|
67
|
+
interface FirstCommitOptions {
|
|
68
|
+
cwd?: string | undefined;
|
|
69
|
+
ref?: string | undefined;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Get then SHA of the first commit in the repository
|
|
73
|
+
*/
|
|
74
|
+
export declare function firstCommitAsync(options?: FirstCommitOptions): Promise<string>;
|
|
75
|
+
/**
|
|
76
|
+
* Get then SHA of the first commit in the repository
|
|
77
|
+
*/
|
|
78
|
+
export declare function firstCommitSync(options?: FirstCommitOptions): string;
|
|
79
|
+
export {};
|
package/dist/diff.js
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { promisify } from 'node:util';
|
|
2
|
+
import { execFile, execFileSync } from 'node:child_process';
|
|
3
|
+
import glob from 'picomatch';
|
|
4
|
+
import debug from 'debug';
|
|
5
|
+
const execAsyncLog = debug('git-diff:execAsync');
|
|
6
|
+
const execSyncLog = debug('git-diff:execSync');
|
|
7
|
+
const execFileAsync = promisify(execFile);
|
|
8
|
+
const errorName = 'GitDiffError';
|
|
9
|
+
const badRevisionErrorCode = 'BAD_REVISION';
|
|
10
|
+
export const Status = {
|
|
11
|
+
Added: 'A',
|
|
12
|
+
Changed: 'C',
|
|
13
|
+
Deleted: 'D',
|
|
14
|
+
Modified: 'M',
|
|
15
|
+
Renamed: 'R',
|
|
16
|
+
Unknown: 'X',
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Cast a value to an array if its not already an array
|
|
20
|
+
*/
|
|
21
|
+
export function toArray(value) {
|
|
22
|
+
return Array.isArray(value) ? value : value ? [value] : [];
|
|
23
|
+
}
|
|
24
|
+
async function execAsync(cmd, args, options) {
|
|
25
|
+
execAsyncLog('exec: %s %s %o', cmd, args.join(' '), options);
|
|
26
|
+
try {
|
|
27
|
+
const result = await execFileAsync(cmd, args, options);
|
|
28
|
+
execAsyncLog('exec result: %s', result);
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
execAsyncLog('exec error: %s', error);
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function execSync(cmd, args, options) {
|
|
37
|
+
execSyncLog('exec: %s %s %o', cmd, args.join(' '), options);
|
|
38
|
+
return execFileSync(cmd, args, options).toString();
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A git diff result
|
|
42
|
+
*/
|
|
43
|
+
export class Diff {
|
|
44
|
+
#diff;
|
|
45
|
+
/**
|
|
46
|
+
* Constructs a diff
|
|
47
|
+
*/
|
|
48
|
+
constructor(diff = new Map()) {
|
|
49
|
+
this.#diff = diff instanceof Map ? diff : new Map(diff);
|
|
50
|
+
}
|
|
51
|
+
[Symbol.iterator]() {
|
|
52
|
+
return this.#diff[Symbol.iterator]();
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Get the number of files in the diff
|
|
56
|
+
*/
|
|
57
|
+
size() {
|
|
58
|
+
return this.#diff.size;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get the status and path for each entry in the diff
|
|
62
|
+
*/
|
|
63
|
+
entries() {
|
|
64
|
+
return this.#diff.entries();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get the paths in the diff
|
|
68
|
+
*/
|
|
69
|
+
paths() {
|
|
70
|
+
return this.#diff.keys();
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get the statuses in the diff
|
|
74
|
+
*/
|
|
75
|
+
statuses() {
|
|
76
|
+
return this.#diff.values();
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Match the path(s)
|
|
80
|
+
*/
|
|
81
|
+
match(pathOrPaths) {
|
|
82
|
+
const diff = this.#diff;
|
|
83
|
+
const matcher = glob(toArray(pathOrPaths));
|
|
84
|
+
return {
|
|
85
|
+
get added() {
|
|
86
|
+
return diff.entries().some(([path, status]) => {
|
|
87
|
+
return status === Status.Added && matcher(path);
|
|
88
|
+
});
|
|
89
|
+
},
|
|
90
|
+
get changed() {
|
|
91
|
+
return diff.entries().some(([path, status]) => {
|
|
92
|
+
return status === Status.Changed && matcher(path);
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
get deleted() {
|
|
96
|
+
return diff.entries().some(([path, status]) => {
|
|
97
|
+
return status === Status.Deleted && matcher(path);
|
|
98
|
+
});
|
|
99
|
+
},
|
|
100
|
+
get modified() {
|
|
101
|
+
return diff.entries().some(([path, status]) => {
|
|
102
|
+
return status === Status.Modified && matcher(path);
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
get renamed() {
|
|
106
|
+
return diff.entries().some(([path, status]) => {
|
|
107
|
+
return status === Status.Renamed && matcher(path);
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
get unknown() {
|
|
111
|
+
return diff.entries().some(([path, status]) => {
|
|
112
|
+
return status === Status.Unknown && matcher(path);
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Chceks whether the error has a `stderr` property
|
|
120
|
+
*/
|
|
121
|
+
function isErrorWithStderr(error) {
|
|
122
|
+
return error instanceof Error && !!error.stderr;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Throws a git diff error
|
|
126
|
+
*/
|
|
127
|
+
function throwGitDiffError(error) {
|
|
128
|
+
if (isErrorWithStderr(error)) {
|
|
129
|
+
const match = /fatal: bad revision '(.*)'/.exec(error.stderr);
|
|
130
|
+
if (match) {
|
|
131
|
+
const error = new Error(`The ref does not exist: ${match[1]}`);
|
|
132
|
+
error.name = errorName;
|
|
133
|
+
error.code = badRevisionErrorCode;
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/** Parse the stdout of `git diff` and populate a Diff class */
|
|
139
|
+
function parse(stdout) {
|
|
140
|
+
const map = new Map();
|
|
141
|
+
for (const line of stdout.split('\n')) {
|
|
142
|
+
if (!line)
|
|
143
|
+
continue;
|
|
144
|
+
const match = line.match(/^([^\W]*)\W+(.*)$/);
|
|
145
|
+
if (match) {
|
|
146
|
+
const status = match[1]?.trim();
|
|
147
|
+
const path = match[2]?.trim();
|
|
148
|
+
if (status && path) {
|
|
149
|
+
map.set(path, status);
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
throw new Error(`Invalid line in diff output: ${line}`);
|
|
154
|
+
}
|
|
155
|
+
return new Diff(map);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Executes `git diff` to get the diff status of files
|
|
159
|
+
*/
|
|
160
|
+
export async function diffAsync(options = {}) {
|
|
161
|
+
try {
|
|
162
|
+
const { stdout } = await execAsync(...diffArgs(options));
|
|
163
|
+
return parse(stdout);
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
throwGitDiffError(error);
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Executes `git diff` to get the diff status of files
|
|
172
|
+
*/
|
|
173
|
+
export function diffSync(options = {}) {
|
|
174
|
+
try {
|
|
175
|
+
const stdout = execSync(...diffArgs(options));
|
|
176
|
+
return parse(stdout);
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
throwGitDiffError(error);
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/** Convert options into arguments */
|
|
184
|
+
function diffArgs(options) {
|
|
185
|
+
return [
|
|
186
|
+
'git',
|
|
187
|
+
[
|
|
188
|
+
'diff',
|
|
189
|
+
'--name-status',
|
|
190
|
+
...(options.base ? [options.base] : []),
|
|
191
|
+
...(options.head ? [options.head] : []),
|
|
192
|
+
'--', // this is required to avoid amniguous revision errors
|
|
193
|
+
// ...(options.paths || []),
|
|
194
|
+
],
|
|
195
|
+
{ encoding: 'utf8', cwd: options.cwd },
|
|
196
|
+
];
|
|
197
|
+
}
|
|
198
|
+
function firstCommitArgs(options) {
|
|
199
|
+
return [
|
|
200
|
+
'git',
|
|
201
|
+
['rev-list', '--max-parents=0', options.ref || 'HEAD'],
|
|
202
|
+
{ encoding: 'utf8', cwd: options.cwd },
|
|
203
|
+
];
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Get then SHA of the first commit in the repository
|
|
207
|
+
*/
|
|
208
|
+
export async function firstCommitAsync(options = {}) {
|
|
209
|
+
const { stdout } = await execAsync(...firstCommitArgs(options));
|
|
210
|
+
return stdout.trim();
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Get then SHA of the first commit in the repository
|
|
214
|
+
*/
|
|
215
|
+
export function firstCommitSync(options = {}) {
|
|
216
|
+
const stdout = execSync(...firstCommitArgs(options));
|
|
217
|
+
return stdout.trim();
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=diff.js.map
|
package/dist/diff.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff.js","sourceRoot":"","sources":["../src/diff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AACpC,OAAO,EAAC,QAAQ,EAAE,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAC1D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,YAAY,GAAG,KAAK,CAAC,oBAAoB,CAAC,CAAC;AACjD,MAAM,WAAW,GAAG,KAAK,CAAC,mBAAmB,CAAC,CAAC;AAE/C,MAAM,aAAa,GAAG,SAAS,C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QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAC;KACrC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,UAA8B,EAAE;IAEhC,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM,SAAS,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9D,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,UAA8B,EAAE;IAC9D,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;IACrD,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jameslnewell/git-diff",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/diff.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/jameslnewell/git-diff.git"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@jameslnewell/prettier-config": "^1.2.1",
|
|
18
|
+
"@jameslnewell/typescript-config": "^5.0.1",
|
|
19
|
+
"@types/debug": "^4.1.12",
|
|
20
|
+
"@types/node": "^22.15.21",
|
|
21
|
+
"prettier": "^3.5.3",
|
|
22
|
+
"typescript": "^5.8.3"
|
|
23
|
+
},
|
|
24
|
+
"prettier": "@jameslnewell/prettier-config",
|
|
25
|
+
"scripts": {
|
|
26
|
+
"formatting": "prettier --check .",
|
|
27
|
+
"formatting:fix": "prettier --write .",
|
|
28
|
+
"build": "tsc --project tsconfig.build.json",
|
|
29
|
+
"build:watch": "tsc --project tsconfig.build.json --watch",
|
|
30
|
+
"test": "node --no-warnings --disable-warning=ExperimentalWarning --experimental-strip-types --test \"src/**/*.test.ts\"",
|
|
31
|
+
"test:watch": "node --no-warnings --disable-warning=ExperimentalWarning --experimental-strip-types --test --watch \"src/**/*.test.ts\"",
|
|
32
|
+
"dev": "node --no-warnings --disable-warning=ExperimentalWarning --experimental-strip-types dev.ts"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@types/picomatch": "^4.0.0",
|
|
36
|
+
"debug": "^4.4.1",
|
|
37
|
+
"fast-glob": "^3.3.3",
|
|
38
|
+
"picomatch": "^4.0.2"
|
|
39
|
+
}
|
|
40
|
+
}
|