ddd-ts-kit 0.113.1 → 0.113.2
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 +39 -0
- package/dist/help/work-notes.d.ts.map +1 -1
- package/dist/help/work-notes.js +7 -5
- package/dist/help/work-notes.js.map +1 -1
- package/dist/init/manifest/versions.js +25 -25
- package/dist/merge/declarations/binds-the-name.d.ts +8 -0
- package/dist/merge/declarations/binds-the-name.d.ts.map +1 -0
- package/dist/merge/declarations/binds-the-name.js +40 -0
- package/dist/merge/declarations/binds-the-name.js.map +1 -0
- package/dist/merge/declarations/close-of.d.ts +3 -0
- package/dist/merge/declarations/close-of.d.ts.map +1 -0
- package/dist/merge/declarations/close-of.js +15 -0
- package/dist/merge/declarations/close-of.js.map +1 -0
- package/dist/merge/declarations/declarations-of.d.ts +2 -0
- package/dist/merge/declarations/declarations-of.d.ts.map +1 -1
- package/dist/merge/declarations/declarations-of.js +1 -1
- package/dist/merge/declarations/declarations-of.js.map +1 -1
- package/dist/merge/declarations/declares-a-member.d.ts +7 -0
- package/dist/merge/declarations/declares-a-member.d.ts.map +1 -0
- package/dist/merge/declarations/declares-a-member.js +29 -0
- package/dist/merge/declarations/declares-a-member.js.map +1 -0
- package/dist/merge/declarations/enclosing-group.d.ts +8 -0
- package/dist/merge/declarations/enclosing-group.d.ts.map +1 -0
- package/dist/merge/declarations/enclosing-group.js +16 -0
- package/dist/merge/declarations/enclosing-group.js.map +1 -0
- package/dist/merge/declarations/imports-read-as-merged.d.ts +9 -0
- package/dist/merge/declarations/imports-read-as-merged.d.ts.map +1 -0
- package/dist/merge/declarations/imports-read-as-merged.js +23 -0
- package/dist/merge/declarations/imports-read-as-merged.js.map +1 -0
- package/dist/merge/declarations/inverts-a-reference.d.ts +12 -0
- package/dist/merge/declarations/inverts-a-reference.d.ts.map +1 -0
- package/dist/merge/declarations/inverts-a-reference.js +25 -0
- package/dist/merge/declarations/inverts-a-reference.js.map +1 -0
- package/dist/merge/declarations/lead-of.d.ts +15 -0
- package/dist/merge/declarations/lead-of.d.ts.map +1 -0
- package/dist/merge/declarations/lead-of.js +19 -0
- package/dist/merge/declarations/lead-of.js.map +1 -0
- package/dist/merge/declarations/lines-of-both-sides.d.ts +10 -0
- package/dist/merge/declarations/lines-of-both-sides.d.ts.map +1 -0
- package/dist/merge/declarations/lines-of-both-sides.js +22 -0
- package/dist/merge/declarations/lines-of-both-sides.js.map +1 -0
- package/dist/merge/declarations/merge-declarations.d.ts.map +1 -1
- package/dist/merge/declarations/merge-declarations.js +1 -15
- package/dist/merge/declarations/merge-declarations.js.map +1 -1
- package/dist/merge/declarations/merged-file.d.ts +15 -0
- package/dist/merge/declarations/merged-file.d.ts.map +1 -0
- package/dist/merge/declarations/merged-file.js +55 -0
- package/dist/merge/declarations/merged-file.js.map +1 -0
- package/dist/merge/declarations/merged-lines.d.ts +5 -11
- package/dist/merge/declarations/merged-lines.d.ts.map +1 -1
- package/dist/merge/declarations/merged-lines.js +6 -39
- package/dist/merge/declarations/merged-lines.js.map +1 -1
- package/dist/merge/declarations/merged-region.d.ts +2 -1
- package/dist/merge/declarations/merged-region.d.ts.map +1 -1
- package/dist/merge/declarations/merged-region.js +60 -22
- package/dist/merge/declarations/merged-region.js.map +1 -1
- package/dist/merge/declarations/reads-a-removed.d.ts +8 -0
- package/dist/merge/declarations/reads-a-removed.d.ts.map +1 -0
- package/dist/merge/declarations/reads-a-removed.js +27 -0
- package/dist/merge/declarations/reads-a-removed.js.map +1 -0
- package/dist/merge/declarations/reads-the-name.d.ts +10 -0
- package/dist/merge/declarations/reads-the-name.d.ts.map +1 -0
- package/dist/merge/declarations/reads-the-name.js +23 -0
- package/dist/merge/declarations/reads-the-name.js.map +1 -0
- package/dist/merge/declarations/settle-declarations.d.ts +9 -5
- package/dist/merge/declarations/settle-declarations.d.ts.map +1 -1
- package/dist/merge/declarations/settle-declarations.js +39 -13
- package/dist/merge/declarations/settle-declarations.js.map +1 -1
- package/dist/merge/declarations/sides-of-region.d.ts +5 -0
- package/dist/merge/declarations/sides-of-region.d.ts.map +1 -0
- package/dist/merge/declarations/sides-of-region.js +19 -0
- package/dist/merge/declarations/sides-of-region.js.map +1 -0
- package/dist/merge/declarations/union-in-doubt.d.ts +17 -0
- package/dist/merge/declarations/union-in-doubt.d.ts.map +1 -0
- package/dist/merge/declarations/union-in-doubt.js +84 -0
- package/dist/merge/declarations/union-in-doubt.js.map +1 -0
- package/dist/merge/declarations/union-reads-as-merged.d.ts +23 -0
- package/dist/merge/declarations/union-reads-as-merged.d.ts.map +1 -0
- package/dist/merge/declarations/union-reads-as-merged.js +155 -0
- package/dist/merge/declarations/union-reads-as-merged.js.map +1 -0
- package/dist/merge/resolve-conflict.d.ts +2 -1
- package/dist/merge/resolve-conflict.d.ts.map +1 -1
- package/dist/merge/resolve-conflict.js +5 -3
- package/dist/merge/resolve-conflict.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -6
- package/templates/pipeline/package-scripts.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-declarations.d.ts","sourceRoot":"","sources":["../../../src/merge/declarations/merge-declarations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"merge-declarations.d.ts","sourceRoot":"","sources":["../../../src/merge/declarations/merge-declarations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,8DAA8D;AAC9D,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;CAC/B;AAED,uGAAuG;AACvG,MAAM,MAAM,iBAAiB,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAA;CAAE,GAC5D;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAC;CAC1C,CAAC;AAEN;;;;;GAKG;AACH,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAEhE,gGAAgG;AAChG,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,MAAM,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC9C,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;CAC7B;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,GAAG,YAAY,GAAG;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,CA6BjH"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { holdsEveryLine } from './holds-every-line.js';
|
|
2
|
+
import { leadOf } from './lead-of.js';
|
|
2
3
|
/**
|
|
3
4
|
* The declarations of a region merged three ways, each whole: what one side added, changed or
|
|
4
5
|
* removed is taken when the other left that declaration as the base holds it, a declaration both
|
|
@@ -53,21 +54,6 @@ function mayBeOne(one, other) {
|
|
|
53
54
|
return (one.lines[0] === other.lines[0] &&
|
|
54
55
|
(holdsEveryLine(one.lines, other.lines) || holdsEveryLine(other.lines, one.lines)));
|
|
55
56
|
}
|
|
56
|
-
/**
|
|
57
|
-
* The side whose order the merged region follows: ours, unless the trunk alone changed the order
|
|
58
|
-
* of the declarations both sides hold. Undefined when the two sides order them differently and
|
|
59
|
-
* the base does not say that one of them left that order alone.
|
|
60
|
-
*/
|
|
61
|
-
function leadOf({ ours, base, theirs }) {
|
|
62
|
-
const shared = new Set(ours.declarations.map(({ key }) => key).filter((key) => byKey(theirs).has(key)));
|
|
63
|
-
const orderOf = (side, among = shared) => side.declarations.flatMap(({ key }) => (among.has(key) ? [key] : [])).join('\0');
|
|
64
|
-
if (orderOf(ours) === orderOf(theirs)) {
|
|
65
|
-
return ours;
|
|
66
|
-
}
|
|
67
|
-
const kept = new Set(base.declarations.map(({ key }) => key).filter((key) => shared.has(key)));
|
|
68
|
-
const moved = [ours, theirs].filter((side) => orderOf(side, kept) !== orderOf(base, kept));
|
|
69
|
-
return moved.length === 1 ? moved[0] : undefined;
|
|
70
|
-
}
|
|
71
57
|
function placed(key, items) {
|
|
72
58
|
return items.map((item) => ({ key, item }));
|
|
73
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-declarations.js","sourceRoot":"","sources":["../../../src/merge/declarations/merge-declarations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"merge-declarations.js","sourceRoot":"","sources":["../../../src/merge/declarations/merge-declarations.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAkCnC;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAoB,EAAE,SAAoB;IAC1E,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,IAAI,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAA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EAAE,GAAG,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AACpH,CAAC;AAED,SAAS,IAAI,CAAC,WAAoC;IAChD,OAAO,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED,SAAS,IAAI,CAAC,GAA4B,EAAE,KAA8B;IACxE,OAAO,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** The three versions of one declaration, as lines. */
|
|
2
|
+
export interface Versions {
|
|
3
|
+
readonly ours: readonly string[];
|
|
4
|
+
readonly base: readonly string[];
|
|
5
|
+
readonly theirs: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The file three versions of a declaration merge into, as lines, by the `git merge-tree` that
|
|
9
|
+
* computes the merge of the tree: each version is written as an object of the repository, no ref
|
|
10
|
+
* names it. With `hunks`, each conflict is written as diff3 markers, as merge-trunk reads those of
|
|
11
|
+
* a file. Undefined on a conflict when no hunk is asked for, or when git cannot write or merge the
|
|
12
|
+
* versions (a git without `--merge-base`).
|
|
13
|
+
*/
|
|
14
|
+
export declare function mergedFile(top: string, versions: Versions, hunks: boolean): string[] | undefined;
|
|
15
|
+
//# sourceMappingURL=merged-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merged-file.d.ts","sourceRoot":"","sources":["../../../src/merge/declarations/merged-file.ts"],"names":[],"mappings":"AAGA,uDAAuD;AACvD,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAMD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,GAAG,SAAS,CAsBhG"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { gitProcess } from '../git-process.js';
|
|
2
|
+
import { objectBytes } from '../object-bytes.js';
|
|
3
|
+
const FILE = 'declaration';
|
|
4
|
+
const AUTHOR = ['-c', 'user.name=ddd-ts-kit', '-c', 'user.email=ddd-ts-kit@localhost', '-c', 'commit.gpgsign=false'];
|
|
5
|
+
const OBJECT = /^[0-9a-f]{40,64}$/;
|
|
6
|
+
/**
|
|
7
|
+
* The file three versions of a declaration merge into, as lines, by the `git merge-tree` that
|
|
8
|
+
* computes the merge of the tree: each version is written as an object of the repository, no ref
|
|
9
|
+
* names it. With `hunks`, each conflict is written as diff3 markers, as merge-trunk reads those of
|
|
10
|
+
* a file. Undefined on a conflict when no hunk is asked for, or when git cannot write or merge the
|
|
11
|
+
* versions (a git without `--merge-base`).
|
|
12
|
+
*/
|
|
13
|
+
export function mergedFile(top, versions, hunks) {
|
|
14
|
+
const commits = commitsOf(top, versions);
|
|
15
|
+
if (commits === undefined) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const merge = [
|
|
19
|
+
'merge-tree',
|
|
20
|
+
'--write-tree',
|
|
21
|
+
'--no-messages',
|
|
22
|
+
`--merge-base=${commits.base}`,
|
|
23
|
+
commits.ours,
|
|
24
|
+
commits.theirs,
|
|
25
|
+
];
|
|
26
|
+
const answer = gitProcess(top, hunks ? ['-c', 'merge.conflictStyle=diff3', ...merge] : merge);
|
|
27
|
+
const [tree = ''] = answer.stdout.split('\n');
|
|
28
|
+
const name = `${tree}:${FILE}`;
|
|
29
|
+
const merged = (answer.status === 0 || (hunks && answer.status === 1)) && OBJECT.test(tree);
|
|
30
|
+
return merged ? objectBytes(top, [name]).get(name)?.toString('utf8').replace(/\n$/, '').split('\n') : undefined;
|
|
31
|
+
}
|
|
32
|
+
/** A commit for each version, ours and theirs on the base; undefined when git does not write one. */
|
|
33
|
+
function commitsOf(top, { ours, base, theirs }) {
|
|
34
|
+
const origin = commitOf(top, base);
|
|
35
|
+
const mine = origin === undefined ? undefined : commitOf(top, ours, origin);
|
|
36
|
+
const other = origin === undefined ? undefined : commitOf(top, theirs, origin);
|
|
37
|
+
return origin === undefined || mine === undefined || other === undefined
|
|
38
|
+
? undefined
|
|
39
|
+
: { base: origin, ours: mine, theirs: other };
|
|
40
|
+
}
|
|
41
|
+
/** A commit that holds the lines as one file, on `parent` when it has one; undefined when git does not write it. */
|
|
42
|
+
function commitOf(top, lines, parent) {
|
|
43
|
+
const blob = written(top, ['hash-object', '-w', '--stdin'], `${lines.join('\n')}\n`);
|
|
44
|
+
const tree = blob === undefined ? undefined : written(top, ['mktree'], `100644 blob ${blob}\t${FILE}\n`);
|
|
45
|
+
return tree === undefined
|
|
46
|
+
? undefined
|
|
47
|
+
: written(top, [...AUTHOR, 'commit-tree', tree, ...(parent === undefined ? [] : ['-p', parent]), '-m', FILE]);
|
|
48
|
+
}
|
|
49
|
+
/** The object git wrote, by its id. */
|
|
50
|
+
function written(top, args, input) {
|
|
51
|
+
const answer = gitProcess(top, args, input);
|
|
52
|
+
const id = answer.status === 0 ? answer.stdout.trim() : '';
|
|
53
|
+
return OBJECT.test(id) ? id : undefined;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=merged-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merged-file.js","sourceRoot":"","sources":["../../../src/merge/declarations/merged-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,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CAAC,CAAC,SAAS;QACX,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,GAAG,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAClH,CAAC;AAED,uCAAuC;AACvC,SAAS,OAAO,CAAC,GAAW,EAAE,IAAuB,EAAE,KAAc;IACnE,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5C,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAE3D,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AAC1C,CAAC"}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export interface Versions {
|
|
3
|
-
readonly ours: readonly string[];
|
|
4
|
-
readonly base: readonly string[];
|
|
5
|
-
readonly theirs: readonly string[];
|
|
6
|
-
}
|
|
1
|
+
import { type Versions } from './merged-file.js';
|
|
7
2
|
/** What merges the lines of the three versions of a declaration; undefined when they do not merge without a conflict. */
|
|
8
3
|
export type LineMerge = (versions: Versions) => readonly string[] | undefined;
|
|
9
4
|
/**
|
|
10
|
-
* The lines of a declaration both sides changed, merged as git merges a file
|
|
11
|
-
*
|
|
12
|
-
* merge
|
|
13
|
-
* them: the declaration is then left to a person.
|
|
5
|
+
* The lines of a declaration both sides changed, merged as git merges a file, as merge-trunk
|
|
6
|
+
* computes the merge of the tree. Undefined when the versions conflict, or when git cannot write
|
|
7
|
+
* or merge them: the declaration is then left to a person.
|
|
14
8
|
*/
|
|
15
|
-
export declare function mergedLines(top: string,
|
|
9
|
+
export declare function mergedLines(top: string, versions: Versions): string[] | undefined;
|
|
16
10
|
//# sourceMappingURL=merged-lines.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merged-lines.d.ts","sourceRoot":"","sources":["../../../src/merge/declarations/merged-lines.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"merged-lines.d.ts","sourceRoot":"","sources":["../../../src/merge/declarations/merged-lines.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE1D,yHAAyH;AACzH,MAAM,MAAM,SAAS,GAAG,CAAC,QAAQ,EAAE,QAAQ,KAAK,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;AAE9E;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,SAAS,CAEjF"}
|
|
@@ -1,43 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { objectBytes } from '../object-bytes.js';
|
|
3
|
-
const FILE = 'declaration';
|
|
4
|
-
const AUTHOR = ['-c', 'user.name=ddd-ts-kit', '-c', 'user.email=ddd-ts-kit@localhost', '-c', 'commit.gpgsign=false'];
|
|
1
|
+
import { mergedFile } from './merged-file.js';
|
|
5
2
|
/**
|
|
6
|
-
* The lines of a declaration both sides changed, merged as git merges a file
|
|
7
|
-
*
|
|
8
|
-
* merge
|
|
9
|
-
* them: the declaration is then left to a person.
|
|
3
|
+
* The lines of a declaration both sides changed, merged as git merges a file, as merge-trunk
|
|
4
|
+
* computes the merge of the tree. Undefined when the versions conflict, or when git cannot write
|
|
5
|
+
* or merge them: the declaration is then left to a person.
|
|
10
6
|
*/
|
|
11
|
-
export function mergedLines(top,
|
|
12
|
-
|
|
13
|
-
const mine = origin === undefined ? undefined : commitOf(top, ours, origin);
|
|
14
|
-
const other = origin === undefined ? undefined : commitOf(top, theirs, origin);
|
|
15
|
-
return origin === undefined || mine === undefined || other === undefined
|
|
16
|
-
? undefined
|
|
17
|
-
: mergedFile(top, { base: origin, ours: mine, theirs: other });
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* The file three commits merge into, as lines, by the `git merge-tree` that computes the merge of
|
|
21
|
-
* the tree; undefined on a conflict, or when git does not merge them (a git without `--merge-base`).
|
|
22
|
-
*/
|
|
23
|
-
function mergedFile(top, { base, ours, theirs }) {
|
|
24
|
-
const tree = written(top, ['merge-tree', '--write-tree', '--no-messages', `--merge-base=${base}`, ours, theirs]);
|
|
25
|
-
const name = `${tree ?? ''}:${FILE}`;
|
|
26
|
-
const text = tree === undefined ? undefined : objectBytes(top, [name]).get(name)?.toString('utf8');
|
|
27
|
-
return text?.replace(/\n$/, '').split('\n');
|
|
28
|
-
}
|
|
29
|
-
/** A commit that holds the lines as one file, on `parent` when it has one; undefined when git does not write it. */
|
|
30
|
-
function commitOf(top, lines, parent) {
|
|
31
|
-
const blob = written(top, ['hash-object', '-w', '--stdin'], `${lines.join('\n')}\n`);
|
|
32
|
-
const tree = blob === undefined ? undefined : written(top, ['mktree'], `100644 blob ${blob}\t${FILE}\n`);
|
|
33
|
-
return tree === undefined
|
|
34
|
-
? undefined
|
|
35
|
-
: written(top, [...AUTHOR, 'commit-tree', tree, ...(parent === undefined ? [] : ['-p', parent]), '-m', FILE]);
|
|
36
|
-
}
|
|
37
|
-
/** The object git wrote, by its id. */
|
|
38
|
-
function written(top, args, input) {
|
|
39
|
-
const answer = gitProcess(top, args, input);
|
|
40
|
-
const id = answer.status === 0 ? answer.stdout.trim() : '';
|
|
41
|
-
return /^[0-9a-f]{40,64}$/.test(id) ? id : undefined;
|
|
7
|
+
export function mergedLines(top, versions) {
|
|
8
|
+
return mergedFile(top, versions, false);
|
|
42
9
|
}
|
|
43
10
|
//# sourceMappingURL=merged-lines.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merged-lines.js","sourceRoot":"","sources":["../../../src/merge/declarations/merged-lines.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"merged-lines.js","sourceRoot":"","sources":["../../../src/merge/declarations/merged-lines.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAiB,MAAM,eAAe,CAAC;AAK1D;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,QAAkB;IACzD,OAAO,UAAU,CAAC,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;AAC1C,CAAC"}
|
|
@@ -25,7 +25,8 @@ interface Given {
|
|
|
25
25
|
* lines hold a conflict for each declaration the two sides do not agree on. Nothing is written,
|
|
26
26
|
* and the conflicts git wrote stay for a person, when the region is not read with certainty: a
|
|
27
27
|
* side, the base among them, does not hold it once or cannot be read, the declarations of the
|
|
28
|
-
* sides cannot be paired or ordered,
|
|
28
|
+
* sides cannot be paired or ordered, the merged lines do not read back as the declarations merged, a
|
|
29
|
+
* side removed a declaration the other started to read, or a declaration would stand above one it reads.
|
|
29
30
|
*/
|
|
30
31
|
export declare function mergedRegion(name: string, path: ConflictedPath, { top, labels, blocks }: Given): RegionOutcome;
|
|
31
32
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merged-region.d.ts","sourceRoot":"","sources":["../../../src/merge/declarations/merged-region.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"merged-region.d.ts","sourceRoot":"","sources":["../../../src/merge/declarations/merged-region.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGzD,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,kBAAkB,CAAC;AAUtE,wDAAwD;AACxD,MAAM,WAAW,UAAU;IACzB,wBAAwB;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,gGAAgG;AAChG,MAAM,MAAM,aAAa,GACrB;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACrC;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;AAEjF,iHAAiH;AACjH,UAAU,KAAK;IACb,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK,GAAG,aAAa,CA8B9G"}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { regionsOf } from '../../markers/index.js';
|
|
2
|
-
import { declarationsOf } from './declarations-of.js';
|
|
3
1
|
import { declaredLines } from './declared-lines.js';
|
|
4
2
|
import { mergeDeclarations } from './merge-declarations.js';
|
|
5
3
|
import { mergedLines } from './merged-lines.js';
|
|
4
|
+
import { invertsAReference } from './inverts-a-reference.js';
|
|
5
|
+
import { readsARemoved } from './reads-a-removed.js';
|
|
6
6
|
import { readsAsMerged } from './reads-as-merged.js';
|
|
7
7
|
import { shownOf } from './shown-of.js';
|
|
8
|
+
import { sidesOfRegion } from './sides-of-region.js';
|
|
8
9
|
import { mergedImports } from './merged-imports.js';
|
|
9
10
|
/**
|
|
10
11
|
* A region of a conflicted file merged from its three sides, declaration by declaration. Its
|
|
11
12
|
* lines hold a conflict for each declaration the two sides do not agree on. Nothing is written,
|
|
12
13
|
* and the conflicts git wrote stay for a person, when the region is not read with certainty: a
|
|
13
14
|
* side, the base among them, does not hold it once or cannot be read, the declarations of the
|
|
14
|
-
* sides cannot be paired or ordered,
|
|
15
|
+
* sides cannot be paired or ordered, the merged lines do not read back as the declarations merged, a
|
|
16
|
+
* side removed a declaration the other started to read, or a declaration would stand above one it reads.
|
|
15
17
|
*/
|
|
16
18
|
export function mergedRegion(name, path, { top, labels, blocks }) {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const base = sideOf(path.base, name);
|
|
20
|
-
if (ours === undefined || theirs === undefined || base === undefined) {
|
|
19
|
+
const sides = sidesOfRegion(name, path);
|
|
20
|
+
if (sides === undefined) {
|
|
21
21
|
return unread(name, blocks);
|
|
22
22
|
}
|
|
23
|
-
const imports = name === 'imports' ? mergedImports(
|
|
23
|
+
const imports = name === 'imports' ? mergedImports(sides) : undefined;
|
|
24
24
|
if (imports !== undefined) {
|
|
25
25
|
return { lines: imports };
|
|
26
26
|
}
|
|
27
|
-
const outcome = mergeDeclarations(
|
|
28
|
-
const why = whyNot(outcome);
|
|
27
|
+
const outcome = mergeDeclarations(sides, (versions) => mergedLines(top, versions));
|
|
28
|
+
const why = whyNot(outcome, sides);
|
|
29
29
|
if ('refused' in outcome || why !== undefined) {
|
|
30
30
|
return unread(name, blocks, why);
|
|
31
31
|
}
|
|
@@ -33,18 +33,46 @@ export function mergedRegion(name, path, { top, labels, blocks }) {
|
|
|
33
33
|
const conflicts = outcome.merged.flatMap((item) => (item.kind === 'conflict' ? [item] : []));
|
|
34
34
|
return conflicts.length === 0
|
|
35
35
|
? { lines }
|
|
36
|
-
: {
|
|
36
|
+
: {
|
|
37
|
+
lines,
|
|
38
|
+
held: { advice: `${adviceOf(name, conflicts)}${renamedOf(conflicts, sides)}`, blocks: conflicts.length },
|
|
39
|
+
};
|
|
37
40
|
}
|
|
38
|
-
/**
|
|
39
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Why a region is not written as merged: its declarations were not merged, they do not read
|
|
43
|
+
* back, a side removed one the other started to read, the merged region sets one above a
|
|
44
|
+
* declaration it reads against the sides, or they give the file two default exports.
|
|
45
|
+
*/
|
|
46
|
+
function whyNot(outcome, sides) {
|
|
40
47
|
if ('refused' in outcome) {
|
|
41
|
-
return outcome.refused;
|
|
48
|
+
return outcome.refused === 'unnamed' && !oneSideAlone(sides) ? 'gone' : outcome.refused;
|
|
42
49
|
}
|
|
43
50
|
if (!readsAsMerged(outcome.merged, outcome.lead)) {
|
|
44
51
|
return 'unread';
|
|
45
52
|
}
|
|
53
|
+
if (readsARemoved(sides)) {
|
|
54
|
+
return 'removed';
|
|
55
|
+
}
|
|
56
|
+
const declarations = outcome.merged.flatMap((item) => shownOf(item) ?? []);
|
|
57
|
+
if (invertsAReference({ declarations, trailing: 0 }, sides)) {
|
|
58
|
+
return 'above';
|
|
59
|
+
}
|
|
46
60
|
return outcome.merged.filter(exportsADefault).length > 1 ? 'defaults' : undefined;
|
|
47
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Whether a side changed or removed a statement of the base that declares no name and the other
|
|
64
|
+
* did not do the same: one side alone holds it as the base does, or a side wrote a statement the
|
|
65
|
+
* base does not hold, which may be that one changed. Otherwise both removed it.
|
|
66
|
+
*/
|
|
67
|
+
function oneSideAlone({ ours, base, theirs }) {
|
|
68
|
+
const keys = (side) => new Set(side.declarations.map(({ key }) => key));
|
|
69
|
+
const inOurs = keys(ours);
|
|
70
|
+
const inTheirs = keys(theirs);
|
|
71
|
+
const inBase = keys(base);
|
|
72
|
+
const nameless = (side) => side.declarations.filter(({ name }) => name === undefined);
|
|
73
|
+
return (nameless(base).some(({ key }) => inOurs.has(key) !== inTheirs.has(key)) ||
|
|
74
|
+
[...nameless(ours), ...nameless(theirs)].some(({ key }) => !inBase.has(key)));
|
|
75
|
+
}
|
|
48
76
|
/** A default export in either spelling: `export default ...` or `export { name as default }`. */
|
|
49
77
|
const DEFAULT_EXPORT = /^\s*export\s+(?:default\b|(?:type\s+)?\{[^}]*\bas\s+default\b)/;
|
|
50
78
|
/** Whether a declaration of the merged region, in the version of a side when it is left to a person, gives the file its default export. */
|
|
@@ -59,6 +87,9 @@ const WHY = {
|
|
|
59
87
|
entries: `holds lines that end no statement (entries of a list, or statements written without \`;\`) on which the two sides differ, which the kit does not merge one by one${WHOLE}.`,
|
|
60
88
|
twice: 'holds two statements with no declared name that open alike, one holding every line of the other, which the kit cannot tell from one statement written twice, and its hunks show lines, not whole statements: write it once if it is one statement, each whole if they are two.',
|
|
61
89
|
order: `holds declarations the two sides set in two different orders${WHOLE}, in the order that holds for both.`,
|
|
90
|
+
gone: `holds a statement that declares no name and that both sides removed, which the kit does not merge${WHOLE}.`,
|
|
91
|
+
above: `holds a declaration that would stand above one it reads once the two sides are merged${WHOLE}, in the order that holds for both.`,
|
|
92
|
+
removed: `holds a declaration one side removed and that a declaration the other side wrote reads${WHOLE}, the one removed kept or the other written without it.`,
|
|
62
93
|
defaults: 'holds a default export of each side, and a file has one: write the one the file keeps, whole, and export what the other side declared under a name.',
|
|
63
94
|
};
|
|
64
95
|
function unread(name, blocks, why = 'unread') {
|
|
@@ -72,13 +103,20 @@ function adviceOf(name, conflicts) {
|
|
|
72
103
|
: `on ${names.map((declared) => `\`${declared}\``).join(', ')} in the region \`${name}\`: for each`;
|
|
73
104
|
return `the two sides do not agree ${what}, write the one declaration that keeps the intent of both, whole, or remove it.`;
|
|
74
105
|
}
|
|
75
|
-
/**
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
106
|
+
/**
|
|
107
|
+
* What is said more when one side removed a declaration the other changed and that side also
|
|
108
|
+
* wrote one neither the base nor the other side holds: the kit cannot tell a declaration given
|
|
109
|
+
* another name from one replaced by another.
|
|
110
|
+
*/
|
|
111
|
+
function renamedOf(conflicts, sides) {
|
|
112
|
+
const keys = (side) => new Set(side.declarations.map(({ key }) => key));
|
|
113
|
+
const inBase = keys(sides.base);
|
|
114
|
+
const wroteAnother = (side, other) => side.declarations.some(({ key }) => !inBase.has(key) && !keys(other).has(key));
|
|
115
|
+
const renamed = conflicts.some(({ ours, base, theirs }) => base !== undefined &&
|
|
116
|
+
((ours === undefined && wroteAnother(sides.ours, sides.theirs)) ||
|
|
117
|
+
(theirs === undefined && wroteAnother(sides.theirs, sides.ours))));
|
|
118
|
+
return renamed
|
|
119
|
+
? ' If a declaration of the side that removed it is this one under another name, write the change there and remove the hunk.'
|
|
120
|
+
: '';
|
|
83
121
|
}
|
|
84
122
|
//# sourceMappingURL=merged-region.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merged-region.js","sourceRoot":"","sources":["../../../src/merge/declarations/merged-region.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"merged-region.js","sourceRoot":"","sources":["../../../src/merge/declarations/merged-region.ts"],"names":[],"mappings":"AAGA,OAAO,EAAuB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAA8C,iBAAiB,EAAgB,MAAM,sBAAsB,CAAC;AACnH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAsBjD;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,IAAoB,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAS;IAC7F,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAExC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,IAAI,E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AM,YAAY,GAAG,CAAC,IAAkB,EAAE,KAAmB,EAAW,EAAE,CACxE,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IAEjF,MAAM,OAAO,GAAG,SAAS,CAAC,IAAI,CAC5B,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CACzB,IAAI,KAAK,SAAS;QAClB,CAAC,CAAC,IAAI,KAAK,SAAS,IAAI,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;YAC7D,CAAC,MAAM,KAAK,SAAS,IAAI,YAAY,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CACtE,CAAC;IAEF,OAAO,OAAO;QACZ,CAAC,CAAC,2HAA2H;QAC7H,CAAC,CAAC,EAAE,CAAC;AACT,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DeclaredSides } from './merge-declarations.js';
|
|
2
|
+
/**
|
|
3
|
+
* Whether a side removed a declaration the other left as the base holds it, while that other
|
|
4
|
+
* side wrote or changed a declaration that reads it and whose base version, if any, did not: one
|
|
5
|
+
* removed what the other started to read, and no merge of the two holds for both.
|
|
6
|
+
*/
|
|
7
|
+
export declare function readsARemoved({ ours, base, theirs }: DeclaredSides): boolean;
|
|
8
|
+
//# sourceMappingURL=reads-a-removed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reads-a-removed.d.ts","sourceRoot":"","sources":["../../../src/merge/declarations/reads-a-removed.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,aAAa,GAAG,OAAO,CAE5E"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { readsTheName } from './reads-the-name.js';
|
|
2
|
+
/**
|
|
3
|
+
* Whether a side removed a declaration the other left as the base holds it, while that other
|
|
4
|
+
* side wrote or changed a declaration that reads it and whose base version, if any, did not: one
|
|
5
|
+
* removed what the other started to read, and no merge of the two holds for both.
|
|
6
|
+
*/
|
|
7
|
+
export function readsARemoved({ ours, base, theirs }) {
|
|
8
|
+
return startedToRead(ours, base, theirs) || startedToRead(theirs, base, ours);
|
|
9
|
+
}
|
|
10
|
+
/** Whether a side started to read a declaration it left alone and the other side removed. */
|
|
11
|
+
function startedToRead(keeper, base, remover) {
|
|
12
|
+
const inBase = byKey(base);
|
|
13
|
+
const removed = new Set(remover.declarations.map(({ key }) => key));
|
|
14
|
+
const gone = keeper.declarations.filter((kept) => kept.name !== undefined && !removed.has(kept.key) && same(kept, inBase.get(kept.key)));
|
|
15
|
+
return keeper.declarations.some((written) => {
|
|
16
|
+
const before = inBase.get(written.key);
|
|
17
|
+
return (!same(written, before) &&
|
|
18
|
+
gone.some(({ key, name }) => key !== written.key && readsTheName(written, name) && !(before !== undefined && readsTheName(before, name))));
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function byKey(side) {
|
|
22
|
+
return new Map(side.declarations.map((declaration) => [declaration.key, declaration]));
|
|
23
|
+
}
|
|
24
|
+
function same(one, other) {
|
|
25
|
+
return one.lines.join('\n') === other?.lines.join('\n');
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=reads-a-removed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reads-a-removed.js","sourceRoot":"","sources":["../../../src/merge/declarations/reads-a-removed.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD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C;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,KAAK,CAAC,IAAkB;IAC/B,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;AACzF,CAAC;AAED,SAAS,IAAI,CAAC,GAAgB,EAAE,KAA8B;IAC5D,OAAO,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Declaration } from './declaration.js';
|
|
2
|
+
/**
|
|
3
|
+
* Whether the code of a declaration reads a name: it holds it as a whole word, comments and
|
|
4
|
+
* strings left out, a type that names it and a spread of it among them (`typeof orders`,
|
|
5
|
+
* `...orders`). A member of another value (`other.orders`, `other?.orders`) is not a read of it,
|
|
6
|
+
* nor a member the code declares under that name. No scope is read: a declaration that binds the
|
|
7
|
+
* name itself is not taken to read the outer one at all.
|
|
8
|
+
*/
|
|
9
|
+
export declare function readsTheName({ lines }: Declaration, name: string | undefined): boolean;
|
|
10
|
+
//# sourceMappingURL=reads-the-name.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reads-the-name.d.ts","sourceRoot":"","sources":["../../../src/merge/declarations/reads-the-name.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAGjD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAetF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { scan } from '../../check/scan/scan.js';
|
|
2
|
+
import { bindsTheName } from './binds-the-name.js';
|
|
3
|
+
import { declaresAMember } from './declares-a-member.js';
|
|
4
|
+
/**
|
|
5
|
+
* Whether the code of a declaration reads a name: it holds it as a whole word, comments and
|
|
6
|
+
* strings left out, a type that names it and a spread of it among them (`typeof orders`,
|
|
7
|
+
* `...orders`). A member of another value (`other.orders`, `other?.orders`) is not a read of it,
|
|
8
|
+
* nor a member the code declares under that name. No scope is read: a declaration that binds the
|
|
9
|
+
* name itself is not taken to read the outer one at all.
|
|
10
|
+
*/
|
|
11
|
+
export function readsTheName({ lines }, name) {
|
|
12
|
+
const code = scan(lines.join('\n')).code;
|
|
13
|
+
if (name === undefined || bindsTheName(code, name)) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const word = new RegExp(`(?<![\\w$])${name.replaceAll('$', '\\$')}(?![\\w$])`, 'g');
|
|
17
|
+
return [...code.matchAll(word)].some(({ index }) => {
|
|
18
|
+
const before = code.slice(0, index).trimEnd();
|
|
19
|
+
const member = before.endsWith('.') && !before.endsWith('...');
|
|
20
|
+
return !member && !declaresAMember(code, index, name);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=reads-the-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reads-the-name.js","sourceRoot":"","sources":["../../../src/merge/declarations/reads-the-name.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,EAAE,KAAK,EAAe,EAAE,IAAwB;IAC3E,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAEzC,IAAI,IAAI,KAAK,SAAS,IAAI,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC;QACnD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,MAAM,CAAC,cAAc,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IAEpF,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE;QACjD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAE/D,OAAO,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -11,11 +11,15 @@ export interface SettledDeclarations {
|
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* Merges, in the text a merge wrote for a file, each generated region in which the lines of both
|
|
14
|
-
* sides, kept, would leave a declaration open: git sets two
|
|
15
|
-
* added at one place side by side and keeps the lines they
|
|
16
|
-
* lines no longer pairs their brackets.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
14
|
+
* sides, kept, would not give the two sides merged. They leave a declaration open: git sets two
|
|
15
|
+
* tables, two models or two functions added at one place side by side and keeps the lines they
|
|
16
|
+
* share once, so that the union of the lines no longer pairs their brackets. Or they pair them
|
|
17
|
+
* and the region they give, read back, is not the declarations of the three sides merged one by
|
|
18
|
+
* one: a line of one side stands inside a declaration of the other, a declaration lacks a line,
|
|
19
|
+
* stands twice, came back, or stands above one it reads. Such a region is merged from the
|
|
20
|
+
* three sides of the file, declaration by declaration. Any other region is left to the union of
|
|
21
|
+
* lines, untouched: `top` is the repository the lines of a declaration both sides changed are
|
|
22
|
+
* merged in.
|
|
19
23
|
*/
|
|
20
24
|
export declare function settleDeclarations(path: ConflictedPath, top: string): SettledDeclarations;
|
|
21
25
|
//# sourceMappingURL=settle-declarations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settle-declarations.d.ts","sourceRoot":"","sources":["../../../src/merge/declarations/settle-declarations.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"settle-declarations.d.ts","sourceRoot":"","sources":["../../../src/merge/declarations/settle-declarations.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAMzD,OAAO,EAAE,KAAK,UAAU,EAAgB,MAAM,iBAAiB,CAAC;AAMhE,0DAA0D;AAC1D,MAAM,WAAW,mBAAmB;IAClC,6FAA6F;IAC7F,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,sHAAsH;IACtH,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IAC/C,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,GAAG,mBAAmB,CA4BzF"}
|