@simbo/git-changes 2.1.1 → 3.0.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 +29 -0
- package/README.md +54 -1
- package/dist/get-git-changes.js +9 -5
- package/dist/get-git-changes.js.map +1 -1
- package/dist/git-change-status.enum.d.ts +2 -0
- package/dist/git-change-status.enum.js +2 -0
- package/dist/git-change-status.enum.js.map +1 -1
- package/dist/git-changes.types.d.ts +12 -5
- package/dist/parse-git-change-status.d.ts +3 -0
- package/dist/parse-git-change-status.js +18 -1
- package/dist/parse-git-change-status.js.map +1 -1
- package/dist/parse-git-status-output.js +8 -8
- package/dist/parse-git-status-output.js.map +1 -1
- package/package.json +9 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @simbo/git-changes
|
|
2
2
|
|
|
3
|
+
## 3.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 97bc732: Fix and extend how Git changes are read and parsed.
|
|
8
|
+
|
|
9
|
+
- Renamed and copied files are now reported with the new path as `path` and
|
|
10
|
+
the original path as `originPath`. Previously, both paths were swapped.
|
|
11
|
+
- Untracked directories are now reported as individual files instead of a
|
|
12
|
+
single `dir/` entry, also when `status.showUntrackedFiles` is configured
|
|
13
|
+
otherwise.
|
|
14
|
+
- Add `GitChangeStatus.TypeChanged` (`T`) for files whose type changed, such
|
|
15
|
+
as a file replaced by a symlink. These files were previously missing.
|
|
16
|
+
- Add `GitChangeStatus.Unmerged` (`U`) for files with merge conflicts. Both
|
|
17
|
+
`staged` and `unstaged` are set to `Unmerged`. These files were previously
|
|
18
|
+
missing, and files added or deleted on both sides were reported as `Added`
|
|
19
|
+
or `Deleted`.
|
|
20
|
+
|
|
21
|
+
To migrate, remove workarounds that swap `path` and `originPath` or expand
|
|
22
|
+
untracked directories, and handle the new statuses where you check all status
|
|
23
|
+
values.
|
|
24
|
+
|
|
25
|
+
## 2.1.2
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- e235985: Update `execa` to ^10.2.0.
|
|
30
|
+
- @simbo/find-git-repository-root@2.0.0
|
|
31
|
+
|
|
3
32
|
## 2.1.1
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -20,12 +20,65 @@ npm i [-D] @simbo/git-changes
|
|
|
20
20
|
## Usage
|
|
21
21
|
|
|
22
22
|
```ts
|
|
23
|
-
import { getGitChanges } from '@simbo/git-changes';
|
|
23
|
+
import { getGitChanges, GitChangeStatus } from '@simbo/git-changes';
|
|
24
24
|
|
|
25
25
|
// get a map of changed files in the repository located at /path/to/repo
|
|
26
26
|
const changes = await getGitChanges('/path/to/repo');
|
|
27
|
+
|
|
28
|
+
for (const change of changes.values()) {
|
|
29
|
+
if (change.staged === GitChangeStatus.Renamed) {
|
|
30
|
+
console.log(`${change.originPath} → ${change.path}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`getGitChanges()` accepts any directory inside the repository and defaults to
|
|
36
|
+
the current working directory. It reads `git status --porcelain --null` and
|
|
37
|
+
returns a `ReadonlyMap` from file path to change. Example:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
Map {
|
|
41
|
+
'new.txt' => { path: 'new.txt', originPath: 'old.txt', staged: 'R', unstaged: undefined },
|
|
42
|
+
'src/index.ts' => { path: 'src/index.ts', staged: 'M', unstaged: 'M' },
|
|
43
|
+
'docs/draft.md' => { path: 'docs/draft.md', staged: undefined, unstaged: '?' },
|
|
44
|
+
}
|
|
27
45
|
```
|
|
28
46
|
|
|
47
|
+
### Changes
|
|
48
|
+
|
|
49
|
+
Each change has these properties:
|
|
50
|
+
|
|
51
|
+
| Property | Description |
|
|
52
|
+
| ------------ | --------------------------------------------------------------------------- |
|
|
53
|
+
| `path` | File path relative to the repository root; the new path for renames/copies. |
|
|
54
|
+
| `originPath` | Original path relative to the repository root; only for renames/copies. |
|
|
55
|
+
| `staged` | Status in the index, or `undefined` if the file has no staged change. |
|
|
56
|
+
| `unstaged` | Status in the working tree, or `undefined` if it has no unstaged change. |
|
|
57
|
+
|
|
58
|
+
### Statuses
|
|
59
|
+
|
|
60
|
+
| `GitChangeStatus` | Value | Meaning |
|
|
61
|
+
| ----------------- | ----- | ---------------------------------------------- |
|
|
62
|
+
| `Added` | `A` | File was added. |
|
|
63
|
+
| `Modified` | `M` | File was modified. |
|
|
64
|
+
| `TypeChanged` | `T` | File type changed, such as file to symlink. |
|
|
65
|
+
| `Deleted` | `D` | File was deleted. |
|
|
66
|
+
| `Renamed` | `R` | File was renamed; see `originPath`. |
|
|
67
|
+
| `Copied` | `C` | File was copied; see `originPath`. |
|
|
68
|
+
| `Unmerged` | `U` | File has merge conflicts; set for both fields. |
|
|
69
|
+
| `Untracked` | `?` | File is not tracked; only set for `unstaged`. |
|
|
70
|
+
|
|
71
|
+
### Notes
|
|
72
|
+
|
|
73
|
+
- Untracked directories are listed as individual files, regardless of the
|
|
74
|
+
`status.showUntrackedFiles` Git configuration. Ignored files are not listed.
|
|
75
|
+
- Copies are only detected if Git is configured to detect them
|
|
76
|
+
(`status.renames=copies`).
|
|
77
|
+
- Files with merge conflicts (for example both modified or both added) have
|
|
78
|
+
`staged` and `unstaged` set to `Unmerged`.
|
|
79
|
+
- The lower-level helpers `parseGitStatusOutput()` and `parseGitChangeStatus()`
|
|
80
|
+
are exported to parse existing `git status --porcelain --null` output.
|
|
81
|
+
|
|
29
82
|
For a complete API reference, see the
|
|
30
83
|
[documentation](https://simbo.de/packages/modules/_simbo_git-changes/).
|
|
31
84
|
|
package/dist/get-git-changes.js
CHANGED
|
@@ -17,19 +17,23 @@ export async function getGitChanges(workingDir = cwd()) {
|
|
|
17
17
|
/**
|
|
18
18
|
* This command provides a machine-readable, null-separated output of the
|
|
19
19
|
* current status of the Git repository, including staged and unstaged changes,
|
|
20
|
-
* as well as untracked files.
|
|
20
|
+
* as well as untracked files. Untracked directories are listed as individual
|
|
21
|
+
* files, regardless of the `status.showUntrackedFiles` configuration.
|
|
22
|
+
* Paths are relative to the repository root.
|
|
21
23
|
*
|
|
22
|
-
* Example output:
|
|
24
|
+
* Example output (renamed and copied entries list the new path first):
|
|
23
25
|
* '?? untracked.ts\0'
|
|
24
26
|
* ' M unstaged-modified.ts\0'
|
|
25
27
|
* 'M staged-modified.ts\0'
|
|
26
28
|
* 'MM both-modified.ts\0'
|
|
27
29
|
* ' D unstaged-deleted.ts\0'
|
|
28
30
|
* 'A staged-added.ts\0'
|
|
29
|
-
* '
|
|
30
|
-
* '
|
|
31
|
+
* ' T type-changed.ts\0'
|
|
32
|
+
* 'UU conflicted.ts\0'
|
|
33
|
+
* 'R new.ts\0old.ts\0'
|
|
34
|
+
* 'C copied.ts\0source.ts\0'
|
|
31
35
|
*/
|
|
32
|
-
const { stdout: output } = await execa({ cwd: repoRoot }) `git status --porcelain --
|
|
36
|
+
const { stdout: output } = await execa({ cwd: repoRoot }) `git status --porcelain --null --untracked-files=all`;
|
|
33
37
|
return parseGitStatusOutput(output);
|
|
34
38
|
}
|
|
35
39
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-git-changes.js","sourceRoot":"","sources":["../src/get-git-changes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,UAAU,GAAG,GAAG,EAAE;IACpD,MAAM,QAAQ,GAAG,MAAM,qBAAqB,CAAC,UAAU,CAAC,CAAC;IAEzD,IAAI,CAAC,QA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CAAC,CAAC;IAC5E,CAAC;AACH,CAAC"}
|
|
@@ -6,9 +6,11 @@ export var GitChangeStatus;
|
|
|
6
6
|
(function (GitChangeStatus) {
|
|
7
7
|
GitChangeStatus["Added"] = "A";
|
|
8
8
|
GitChangeStatus["Modified"] = "M";
|
|
9
|
+
GitChangeStatus["TypeChanged"] = "T";
|
|
9
10
|
GitChangeStatus["Deleted"] = "D";
|
|
10
11
|
GitChangeStatus["Renamed"] = "R";
|
|
11
12
|
GitChangeStatus["Copied"] = "C";
|
|
13
|
+
GitChangeStatus["Unmerged"] = "U";
|
|
12
14
|
GitChangeStatus["Untracked"] = "?";
|
|
13
15
|
})(GitChangeStatus || (GitChangeStatus = {}));
|
|
14
16
|
//# sourceMappingURL=git-change-status.enum.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git-change-status.enum.js","sourceRoot":"","sources":["../src/git-change-status.enum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"git-change-status.enum.js","sourceRoot":"","sources":["../src/git-change-status.enum.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAN,IAAY,eASX;AATD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,iCAAc,CAAA;IACd,oCAAiB,CAAA;IACjB,gCAAa,CAAA;IACb,gCAAa,CAAA;IACb,+BAAY,CAAA;IACZ,iCAAc,CAAA;IACd,kCAAe,CAAA;AACjB,CAAC,EATW,eAAe,KAAf,eAAe,QAS1B"}
|
|
@@ -2,7 +2,7 @@ import type { GitChangeStatus } from './git-change-status.enum.js';
|
|
|
2
2
|
/**
|
|
3
3
|
* Common Git change statuses for both staged and unstaged changes.
|
|
4
4
|
*/
|
|
5
|
-
export type GitChangeStatusCommon = GitChangeStatus.Modified | GitChangeStatus.Deleted;
|
|
5
|
+
export type GitChangeStatusCommon = GitChangeStatus.Modified | GitChangeStatus.TypeChanged | GitChangeStatus.Deleted;
|
|
6
6
|
/**
|
|
7
7
|
* Git change statuses that include an origin path.
|
|
8
8
|
*/
|
|
@@ -15,20 +15,26 @@ export type GitChangeStatusAdded = GitChangeStatus.Added;
|
|
|
15
15
|
* Untracked Git change status (only for unstaged changes).
|
|
16
16
|
*/
|
|
17
17
|
export type GitChangeStatusUntracked = GitChangeStatus.Untracked;
|
|
18
|
+
/**
|
|
19
|
+
* Unmerged Git change status (always set for both staged and unstaged changes
|
|
20
|
+
* of a file with merge conflicts).
|
|
21
|
+
*/
|
|
22
|
+
export type GitChangeStatusUnmerged = GitChangeStatus.Unmerged;
|
|
18
23
|
/**
|
|
19
24
|
* Combined type for staged changes field.
|
|
20
25
|
*/
|
|
21
|
-
export type GitChangeStagedStatus = GitChangeStatusCommon | GitChangeStatusAdded | GitChangeStatusWithOriginPath;
|
|
26
|
+
export type GitChangeStagedStatus = GitChangeStatusCommon | GitChangeStatusAdded | GitChangeStatusWithOriginPath | GitChangeStatusUnmerged;
|
|
22
27
|
/**
|
|
23
28
|
* Combined type for unstaged changes field.
|
|
24
29
|
*/
|
|
25
|
-
export type GitChangeUnstagedStatus = GitChangeStatusCommon | GitChangeStatusAdded | GitChangeStatusUntracked | GitChangeStatusWithOriginPath;
|
|
30
|
+
export type GitChangeUnstagedStatus = GitChangeStatusCommon | GitChangeStatusAdded | GitChangeStatusUntracked | GitChangeStatusWithOriginPath | GitChangeStatusUnmerged;
|
|
26
31
|
/**
|
|
27
32
|
* Interface for a change in a Git repository.
|
|
28
33
|
*/
|
|
29
34
|
export interface GitChange {
|
|
30
35
|
/**
|
|
31
|
-
* The file path of the change.
|
|
36
|
+
* The file path of the change, relative to the repository root.
|
|
37
|
+
* For renamed or copied files, this is the new path.
|
|
32
38
|
*/
|
|
33
39
|
path: string;
|
|
34
40
|
/**
|
|
@@ -42,7 +48,8 @@ export interface GitChange {
|
|
|
42
48
|
*/
|
|
43
49
|
unstaged?: GitChangeUnstagedStatus;
|
|
44
50
|
/**
|
|
45
|
-
* The original file path before the change (for renamed or copied files)
|
|
51
|
+
* The original file path before the change (for renamed or copied files),
|
|
52
|
+
* relative to the repository root.
|
|
46
53
|
*/
|
|
47
54
|
originPath?: string;
|
|
48
55
|
}
|
|
@@ -8,6 +8,9 @@ import type { GitChange } from './git-changes.types.js';
|
|
|
8
8
|
*
|
|
9
9
|
* If the status is '??', it indicates an untracked file.
|
|
10
10
|
*
|
|
11
|
+
* If the status is one of the unmerged combinations (DD, AU, UD, UA, DU, AA, UU),
|
|
12
|
+
* it indicates a file with merge conflicts and both statuses are `Unmerged`.
|
|
13
|
+
*
|
|
11
14
|
* This should match the output of `git status --porcelain`.
|
|
12
15
|
*
|
|
13
16
|
* @param status - A two-character string representing the Git change status.
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import { GitChangeStatus } from './git-change-status.enum.js';
|
|
2
|
-
const trackedStatuses = Object.values(GitChangeStatus).filter(value => value !== GitChangeStatus.Untracked);
|
|
2
|
+
const trackedStatuses = Object.values(GitChangeStatus).filter(value => value !== GitChangeStatus.Untracked && value !== GitChangeStatus.Unmerged);
|
|
3
|
+
/**
|
|
4
|
+
* Status combinations that mark a file with merge conflicts ("unmerged").
|
|
5
|
+
* - `DD`: both deleted
|
|
6
|
+
* - `AU`: added by us
|
|
7
|
+
* - `UD`: deleted by them
|
|
8
|
+
* - `UA`: added by them
|
|
9
|
+
* - `DU`: deleted by us
|
|
10
|
+
* - `AA`: both added
|
|
11
|
+
* - `UU`: both modified
|
|
12
|
+
*/
|
|
13
|
+
const unmergedStatuses = new Set(['DD', 'AU', 'UD', 'UA', 'DU', 'AA', 'UU']);
|
|
3
14
|
/**
|
|
4
15
|
* Parses a Git change status string into staged and unstaged statuses.
|
|
5
16
|
*
|
|
@@ -9,6 +20,9 @@ const trackedStatuses = Object.values(GitChangeStatus).filter(value => value !==
|
|
|
9
20
|
*
|
|
10
21
|
* If the status is '??', it indicates an untracked file.
|
|
11
22
|
*
|
|
23
|
+
* If the status is one of the unmerged combinations (DD, AU, UD, UA, DU, AA, UU),
|
|
24
|
+
* it indicates a file with merge conflicts and both statuses are `Unmerged`.
|
|
25
|
+
*
|
|
12
26
|
* This should match the output of `git status --porcelain`.
|
|
13
27
|
*
|
|
14
28
|
* @param status - A two-character string representing the Git change status.
|
|
@@ -21,6 +35,9 @@ export function parseGitChangeStatus(status) {
|
|
|
21
35
|
if (status.startsWith('??')) {
|
|
22
36
|
return { staged: undefined, unstaged: GitChangeStatus.Untracked };
|
|
23
37
|
}
|
|
38
|
+
if (unmergedStatuses.has(status.slice(0, 2))) {
|
|
39
|
+
return { staged: GitChangeStatus.Unmerged, unstaged: GitChangeStatus.Unmerged };
|
|
40
|
+
}
|
|
24
41
|
const staged = trackedStatuses.find((value) => value === status[0]);
|
|
25
42
|
const unstaged = trackedStatuses.find((value) => value === status[1]);
|
|
26
43
|
return { staged, unstaged };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-git-change-status.js","sourceRoot":"","sources":["../src/parse-git-change-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAG9D,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"parse-git-change-status.js","sourceRoot":"","sources":["../src/parse-git-change-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAG9D,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,MAAM,CAC3D,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,eAAe,CAAC,SAAS,IAAI,KAAK,KAAK,eAAe,CAAC,QAAQ,CACnF,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAE7E;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc;IACjD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACpD,CAAC;IAED,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,CAAC,SAAS,EAAE,CAAC;IACpE,CAAC;IAED,IAAI,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7C,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,QAAQ,EAAE,QAAQ,EAAE,eAAe,CAAC,QAAQ,EAAE,CAAC;IAClF,CAAC;IAED,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5E,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAE9E,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC9B,CAAC"}
|
|
@@ -18,21 +18,21 @@ export function parseGitStatusOutput(output) {
|
|
|
18
18
|
}
|
|
19
19
|
const { staged, unstaged } = parseGitChangeStatus(entry.slice(ENTRY_STATUS_INDEX, ENTRY_STATUS_LENGTH));
|
|
20
20
|
const path = entry.slice(ENTRY_PATH_INDEX);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
// For entries that are renamed or copied, the current entry contains the old path,
|
|
25
|
-
// and the next entry contains the new path.
|
|
21
|
+
// Renamed or copied entries contain the new path, followed by an entry with the original path.
|
|
22
|
+
// The original path is consumed even if the entry is invalid, so it is never parsed as an entry.
|
|
26
23
|
if (staged === GitChangeStatus.Renamed ||
|
|
27
24
|
staged === GitChangeStatus.Copied ||
|
|
28
25
|
unstaged === GitChangeStatus.Renamed ||
|
|
29
26
|
unstaged === GitChangeStatus.Copied) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
changes.set(
|
|
27
|
+
const originPath = entries[index++];
|
|
28
|
+
if (path && originPath) {
|
|
29
|
+
changes.set(path, { path, originPath, staged, unstaged });
|
|
33
30
|
}
|
|
34
31
|
continue;
|
|
35
32
|
}
|
|
33
|
+
if (!path || (!staged && !unstaged)) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
36
|
changes.set(path, { path, staged, unstaged });
|
|
37
37
|
}
|
|
38
38
|
return changes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-git-status-output.js","sourceRoot":"","sources":["../src/parse-git-status-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACvH,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc;IACjD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAqB,CAAC;IAC7C,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAE9C,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,OAAO,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAE/B,IAAI,CAAC,KAA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AAe,CAAC,OAAO;YACpC,QAAQ,KAAK,eAAe,CAAC,MAAM,EACnC,CAAC;YACD,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;YACpC,IAAI,IAAI,IAAI,UAAU,EAAE,CAAC;gBACvB,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;YAC5D,CAAC;YACD,SAAS;QACX,CAAC;QAED,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YACpC,SAAS;QACX,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simbo/git-changes",
|
|
3
3
|
"description": "A library to read, parse and provide Git changes information from `git status` for a local repository.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"git",
|
|
7
7
|
"changes",
|
|
@@ -37,22 +37,21 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@simbo/find-git-repository-root": "2.0.0",
|
|
40
|
-
"execa": "^10.0
|
|
40
|
+
"execa": "^10.2.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@ianvs/prettier-plugin-sort-imports": "^4.7.1",
|
|
44
|
-
"@simbo/eslint-config": "3.2.
|
|
44
|
+
"@simbo/eslint-config": "3.2.1",
|
|
45
45
|
"@simbo/prettier-config": "3.0.1",
|
|
46
46
|
"@simbo/tsconfig": "2.0.0",
|
|
47
|
-
"@types/node": "^24.19.
|
|
48
|
-
"@vitest/coverage-v8": "^5.0
|
|
49
|
-
"@vitest/ui": "^5.0
|
|
50
|
-
"
|
|
51
|
-
"eslint": "^10.11.0",
|
|
47
|
+
"@types/node": "^24.19.2",
|
|
48
|
+
"@vitest/coverage-v8": "^5.1.0",
|
|
49
|
+
"@vitest/ui": "^5.1.0",
|
|
50
|
+
"eslint": "^10.14.0",
|
|
52
51
|
"jiti": "^2.7.0",
|
|
53
|
-
"prettier": "^3.9.
|
|
52
|
+
"prettier": "^3.9.10",
|
|
54
53
|
"typescript": "^6.0.3",
|
|
55
|
-
"vitest": "^5.0
|
|
54
|
+
"vitest": "^5.1.0"
|
|
56
55
|
},
|
|
57
56
|
"scripts": {
|
|
58
57
|
"build": "tsc --project tsconfig.build.json",
|