watskeburt 0.12.1 → 0.12.2
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +1 -1
- package/dist/main.js +4 -3
- package/dist/map-change-type.js +16 -0
- package/dist/parse-diff-lines.js +25 -0
- package/dist/parse-status-lines.js +30 -0
- package/dist/version.js +1 -1
- package/package.json +9 -10
- package/dist/convert-to-change-object.js +0 -68
package/LICENSE
CHANGED
package/dist/main.js
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
import {
|
1
|
+
import { parseDiffLines } from "./parse-diff-lines.js";
|
2
|
+
import { parseStatusLines } from "./parse-status-lines.js";
|
2
3
|
import * as primitives from "./git-primitives.js";
|
3
4
|
import format from "./formatters/format.js";
|
4
5
|
export async function list(pOldRevision, pNewRevision, pOptions) {
|
@@ -8,9 +9,9 @@ export async function list(pOldRevision, pNewRevision, pOptions) {
|
|
8
9
|
primitives.getDiffLines(lOldRevision, pNewRevision),
|
9
10
|
!lOptions.trackedOnly ? primitives.getStatusShort() : "",
|
10
11
|
]);
|
11
|
-
let lChanges =
|
12
|
+
let lChanges = parseDiffLines(lDiffLines);
|
12
13
|
if (!lOptions.trackedOnly) {
|
13
|
-
lChanges = lChanges.concat(
|
14
|
+
lChanges = lChanges.concat(parseStatusLines(lStatusLines).filter(({ changeType }) => changeType === "untracked"));
|
14
15
|
}
|
15
16
|
return format(lChanges, lOptions.outputType);
|
16
17
|
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
const CHANGE_CHAR_2_CHANGE_TYPE = new Map([
|
2
|
+
["A", "added"],
|
3
|
+
["C", "copied"],
|
4
|
+
["D", "deleted"],
|
5
|
+
["M", "modified"],
|
6
|
+
["R", "renamed"],
|
7
|
+
["T", "type changed"],
|
8
|
+
["U", "unmerged"],
|
9
|
+
["B", "pairing broken"],
|
10
|
+
[" ", "unmodified"],
|
11
|
+
["?", "untracked"],
|
12
|
+
["!", "ignored"],
|
13
|
+
]);
|
14
|
+
export function changeChar2ChangeType(pChar) {
|
15
|
+
return CHANGE_CHAR_2_CHANGE_TYPE.get(pChar) ?? "unknown";
|
16
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { EOL } from "node:os";
|
2
|
+
import { changeChar2ChangeType } from "./map-change-type.js";
|
3
|
+
const DIFF_NAME_STATUS_LINE_PATTERN = /^(?<changeType>[ACDMRTUXB])(?<similarity>[0-9]{3})?[ \t]+(?<name>[^ \t]+)[ \t]*(?<newName>[^ \t]+)?$/;
|
4
|
+
export function parseDiffLines(pString) {
|
5
|
+
return pString
|
6
|
+
.split(EOL)
|
7
|
+
.filter(Boolean)
|
8
|
+
.map(parseDiffLine)
|
9
|
+
.filter(({ name, changeType }) => Boolean(name) && Boolean(changeType));
|
10
|
+
}
|
11
|
+
export function parseDiffLine(pString) {
|
12
|
+
const lMatchResult = pString.match(DIFF_NAME_STATUS_LINE_PATTERN);
|
13
|
+
const lReturnValue = {};
|
14
|
+
if (lMatchResult?.groups) {
|
15
|
+
lReturnValue.changeType = changeChar2ChangeType(lMatchResult.groups.changeType);
|
16
|
+
if (lMatchResult.groups.newName) {
|
17
|
+
lReturnValue.name = lMatchResult.groups.newName;
|
18
|
+
lReturnValue.oldName = lMatchResult.groups.name;
|
19
|
+
}
|
20
|
+
else {
|
21
|
+
lReturnValue.name = lMatchResult.groups.name;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
return lReturnValue;
|
25
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { EOL } from "node:os";
|
2
|
+
import { changeChar2ChangeType } from "./map-change-type.js";
|
3
|
+
const DIFF_SHORT_STATUS_LINE_PATTERN = /^(?<stagedChangeType>[ ACDMRTUXB?!])(?<unStagedChangeType>[ ACDMRTUXB?!])[ \t]+(?<name>[^ \t]+)(( -> )(?<newName>[^ \t]+))?$/;
|
4
|
+
export function parseStatusLines(pString) {
|
5
|
+
return pString
|
6
|
+
.split(EOL)
|
7
|
+
.filter(Boolean)
|
8
|
+
.map(parseStatusLine)
|
9
|
+
.filter(({ name, changeType }) => Boolean(name) && Boolean(changeType));
|
10
|
+
}
|
11
|
+
export function parseStatusLine(pString) {
|
12
|
+
const lMatchResult = pString.match(DIFF_SHORT_STATUS_LINE_PATTERN);
|
13
|
+
const lReturnValue = {};
|
14
|
+
if (lMatchResult?.groups) {
|
15
|
+
const lStagedChangeType = changeChar2ChangeType(lMatchResult.groups.stagedChangeType);
|
16
|
+
const lUnStagedChangeType = changeChar2ChangeType(lMatchResult.groups.unStagedChangeType);
|
17
|
+
lReturnValue.changeType =
|
18
|
+
lStagedChangeType === "unmodified"
|
19
|
+
? lUnStagedChangeType
|
20
|
+
: lStagedChangeType;
|
21
|
+
if (lMatchResult.groups.newName) {
|
22
|
+
lReturnValue.name = lMatchResult.groups.newName;
|
23
|
+
lReturnValue.oldName = lMatchResult.groups.name;
|
24
|
+
}
|
25
|
+
else {
|
26
|
+
lReturnValue.name = lMatchResult.groups.name;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
return lReturnValue;
|
30
|
+
}
|
package/dist/version.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const VERSION = "0.12.
|
1
|
+
export const VERSION = "0.12.2";
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "watskeburt",
|
3
|
-
"version": "0.12.
|
3
|
+
"version": "0.12.2",
|
4
4
|
"description": "List files changed since a git revision",
|
5
5
|
"keywords": [
|
6
6
|
"git",
|
@@ -42,22 +42,22 @@
|
|
42
42
|
"README.md"
|
43
43
|
],
|
44
44
|
"devDependencies": {
|
45
|
-
"@types/node": "20.
|
46
|
-
"@typescript-eslint/eslint-plugin": "6.
|
45
|
+
"@types/node": "20.5.1",
|
46
|
+
"@typescript-eslint/eslint-plugin": "6.4.1",
|
47
47
|
"c8": "8.0.1",
|
48
|
-
"dependency-cruiser": "13.1.
|
49
|
-
"eslint": "8.
|
48
|
+
"dependency-cruiser": "13.1.4",
|
49
|
+
"eslint": "8.47.0",
|
50
50
|
"eslint-config-moving-meadow": "4.0.2",
|
51
|
-
"eslint-config-prettier": "
|
51
|
+
"eslint-config-prettier": "9.0.0",
|
52
52
|
"eslint-plugin-budapestian": "5.0.1",
|
53
53
|
"eslint-plugin-eslint-comments": "3.2.0",
|
54
|
-
"eslint-plugin-import": "2.28.
|
54
|
+
"eslint-plugin-import": "2.28.1",
|
55
55
|
"eslint-plugin-mocha": "10.1.0",
|
56
56
|
"eslint-plugin-node": "11.1.0",
|
57
57
|
"eslint-plugin-security": "1.7.1",
|
58
58
|
"eslint-plugin-unicorn": "48.0.1",
|
59
59
|
"npm-run-all": "4.1.5",
|
60
|
-
"prettier": "3.0.
|
60
|
+
"prettier": "3.0.2",
|
61
61
|
"ts-node": "10.9.1",
|
62
62
|
"typescript": "5.1.6",
|
63
63
|
"upem": "8.0.0"
|
@@ -72,9 +72,8 @@
|
|
72
72
|
"build:dist": "tsc",
|
73
73
|
"check": "npm-run-all --parallel --aggregate-output lint depcruise test:cover",
|
74
74
|
"clean": "rm -rf dist",
|
75
|
-
"test": "node --no-warnings --loader 'ts-node/esm' --test-reporter dot --test src/*.spec.ts src/**/*.spec.ts",
|
75
|
+
"test": "node --no-warnings --loader 'ts-node/esm' --test-reporter ./tools/dot-with-summary.reporter.js --test src/*.spec.ts src/**/*.spec.ts",
|
76
76
|
"test:cover": "c8 npm test",
|
77
|
-
"test:only-for-node-16-without-the-test-reporter": "node --no-warnings --loader 'ts-node/esm' --test src/*.spec.ts src/**/*.spec.ts",
|
78
77
|
"depcruise": "depcruise dist src types",
|
79
78
|
"depcruise:graph": "depcruise src types --include-only '^(dist|src|types)' --output-type dot | dot -T svg | tee docs/dependency-graph.svg | depcruise-wrap-stream-in-html > docs/dependency-graph.html",
|
80
79
|
"depcruise:graph:archi": "depcruise src --include-only '^(dist|src|types)' --output-type archi | dot -T svg | depcruise-wrap-stream-in-html > docs/high-level-dependency-graph.html",
|
@@ -1,68 +0,0 @@
|
|
1
|
-
import { EOL } from "node:os";
|
2
|
-
const DIFF_NAME_STATUS_LINE_PATTERN = /^(?<changeType>[ACDMRTUXB])(?<similarity>[0-9]{3})?[ \t]+(?<name>[^ \t]+)[ \t]*(?<newName>[^ \t]+)?$/;
|
3
|
-
const DIFF_SHORT_STATUS_LINE_PATTERN = /^(?<stagedChangeType>[ ACDMRTUXB?!])(?<unStagedChangeType>[ ACDMRTUXB?!])[ \t]+(?<name>[^ \t]+)(( -> )(?<newName>[^ \t]+))?$/;
|
4
|
-
const CHANGE_CHAR_2_CHANGE_TYPE = new Map([
|
5
|
-
["A", "added"],
|
6
|
-
["C", "copied"],
|
7
|
-
["D", "deleted"],
|
8
|
-
["M", "modified"],
|
9
|
-
["R", "renamed"],
|
10
|
-
["T", "type changed"],
|
11
|
-
["U", "unmerged"],
|
12
|
-
["B", "pairing broken"],
|
13
|
-
[" ", "unmodified"],
|
14
|
-
["?", "untracked"],
|
15
|
-
["!", "ignored"],
|
16
|
-
]);
|
17
|
-
export function convertStatusLines(pString) {
|
18
|
-
return pString
|
19
|
-
.split(EOL)
|
20
|
-
.filter(Boolean)
|
21
|
-
.map(convertStatusLine)
|
22
|
-
.filter(({ name, changeType }) => Boolean(name) && Boolean(changeType));
|
23
|
-
}
|
24
|
-
export function convertStatusLine(pString) {
|
25
|
-
const lMatchResult = pString.match(DIFF_SHORT_STATUS_LINE_PATTERN);
|
26
|
-
const lReturnValue = {};
|
27
|
-
if (lMatchResult?.groups) {
|
28
|
-
const lStagedChangeType = changeChar2ChangeType(lMatchResult.groups.stagedChangeType);
|
29
|
-
const lUnStagedChangeType = changeChar2ChangeType(lMatchResult.groups.unStagedChangeType);
|
30
|
-
lReturnValue.changeType =
|
31
|
-
lStagedChangeType === "unmodified"
|
32
|
-
? lUnStagedChangeType
|
33
|
-
: lStagedChangeType;
|
34
|
-
if (lMatchResult.groups.newName) {
|
35
|
-
lReturnValue.name = lMatchResult.groups.newName;
|
36
|
-
lReturnValue.oldName = lMatchResult.groups.name;
|
37
|
-
}
|
38
|
-
else {
|
39
|
-
lReturnValue.name = lMatchResult.groups.name;
|
40
|
-
}
|
41
|
-
}
|
42
|
-
return lReturnValue;
|
43
|
-
}
|
44
|
-
export function convertDiffLines(pString) {
|
45
|
-
return pString
|
46
|
-
.split(EOL)
|
47
|
-
.filter(Boolean)
|
48
|
-
.map(convertDiffLine)
|
49
|
-
.filter(({ name, changeType }) => Boolean(name) && Boolean(changeType));
|
50
|
-
}
|
51
|
-
export function convertDiffLine(pString) {
|
52
|
-
const lMatchResult = pString.match(DIFF_NAME_STATUS_LINE_PATTERN);
|
53
|
-
const lReturnValue = {};
|
54
|
-
if (lMatchResult?.groups) {
|
55
|
-
lReturnValue.changeType = changeChar2ChangeType(lMatchResult.groups.changeType);
|
56
|
-
if (lMatchResult.groups.newName) {
|
57
|
-
lReturnValue.name = lMatchResult.groups.newName;
|
58
|
-
lReturnValue.oldName = lMatchResult.groups.name;
|
59
|
-
}
|
60
|
-
else {
|
61
|
-
lReturnValue.name = lMatchResult.groups.name;
|
62
|
-
}
|
63
|
-
}
|
64
|
-
return lReturnValue;
|
65
|
-
}
|
66
|
-
function changeChar2ChangeType(pChar) {
|
67
|
-
return CHANGE_CHAR_2_CHANGE_TYPE.get(pChar) ?? "unknown";
|
68
|
-
}
|