@preventive/compare 1.2.8 → 1.2.9
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/compare.d.ts +8 -5
- package/package.json +1 -1
- package/src/chunks.js +16 -12
- package/src/renames.js +2 -1
package/compare.d.ts
CHANGED
|
@@ -120,11 +120,14 @@ export interface LineOptions {
|
|
|
120
120
|
// lowercase letters alone), as `index-CyWAfh-p.js` and `index-hRvO4yU2.js`
|
|
121
121
|
// are, or `main.3f9a2c1d.chunk.js` and `main.8b7e6a5f.chunk.js`. Minified onto
|
|
122
122
|
// a line, such a chunk scores little as git splits it, so it is scored with
|
|
123
|
-
// its spans ending after `,` `;` `=` `{` `}` too, and taken
|
|
124
|
-
//
|
|
125
|
-
//
|
|
126
|
-
//
|
|
127
|
-
//
|
|
123
|
+
// its spans ending after `,` `;` `=` `{` `}` too, and taken however it scores
|
|
124
|
+
// where each is the other's only such chunk, as a pair by path is (a build's
|
|
125
|
+
// chunk rewritten: playwright's dashboard `index-*.js`, 31% alike from 1.61.1
|
|
126
|
+
// to 1.62.0), else at git's stricter score for a basename, halfway from -M's
|
|
127
|
+
// to 100%: the best pairs first, its similarity that score, giving way as a
|
|
128
|
+
// pair by path does but only where git takes the candidate it gives way to,
|
|
129
|
+
// and none past the rename limit, as they are scored. git has no such passes,
|
|
130
|
+
// so false is git's own -M.
|
|
128
131
|
//
|
|
129
132
|
// `renameLimit` is git's diff.renameLimit: when more deleted files times added
|
|
130
133
|
// files are left, in a group, after the renames that need no scoring than its
|
package/package.json
CHANGED
package/src/chunks.js
CHANGED
|
@@ -32,25 +32,29 @@ function oneChunk(a, b) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
// Chunks git's scored pass has yet to claim, by directory, extension and
|
|
35
|
-
// name's length, each pair at least `bar
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
//
|
|
35
|
+
// name's length, each pair at least `bar` -- or however it scores, where each
|
|
36
|
+
// is the other's only such chunk, as a pair by path is: the build's own chunk,
|
|
37
|
+
// rewritten (playwright's dashboard `index-*.js`, 31% alike from 1.61 to 1.62):
|
|
38
|
+
// the best first, as git takes its candidates, but for a pair `outdone` by a
|
|
39
|
+
// file's other candidate, set aside and returned, best first, for git to pair
|
|
40
|
+
// that candidate with another file: it holds its files, so that a later pair
|
|
41
|
+
// of either is set aside behind it.
|
|
39
42
|
export function chunkRenames({ sources, dests, pairs, used, record, punctuatedScoreOf }, { remaining, open }, bar, outdone) {
|
|
40
43
|
const names = (files, indices) => new Map(indices.filter((i) => files[i].type === 'file').map((i) => [i, nameOf(files[i].path)]))
|
|
41
44
|
const destNames = names(dests, open), sourceNames = names(sources, remaining)
|
|
42
45
|
const byKey = Map.groupBy(sourceNames.keys(), (s) => sourceNames.get(s).key)
|
|
43
46
|
const opens = Map.groupBy(destNames.keys(), (d) => destNames.get(d).key)
|
|
44
|
-
const
|
|
47
|
+
const chunks = []
|
|
45
48
|
for (const [key, ds] of opens) {
|
|
46
49
|
const ss = byKey.get(key) ?? []
|
|
47
|
-
for (const d of ds) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
for (const d of ds) for (const s of ss) if (oneChunk(sourceNames.get(s).name, destNames.get(d).name)) chunks.push({ s, d })
|
|
51
|
+
}
|
|
52
|
+
const byDest = Map.groupBy(chunks, ({ d }) => d), bySource = Map.groupBy(chunks, ({ s }) => s)
|
|
53
|
+
const candidates = []
|
|
54
|
+
for (const { s, d } of chunks) {
|
|
55
|
+
const only = bySource.get(s).length === 1 && byDest.get(d).length === 1
|
|
56
|
+
const score = punctuatedScoreOf(s, d, only ? 0 : bar)
|
|
57
|
+
if (only || score >= bar) candidates.push({ s, d, score })
|
|
54
58
|
}
|
|
55
59
|
const aside = [], heldDests = new Set(), heldSources = new Set()
|
|
56
60
|
for (const pair of candidates.sort((x, y) => y.score - x.score)) {
|
package/src/renames.js
CHANGED
|
@@ -193,7 +193,8 @@ const unpaired = ({ sources, dests, pairs, used }) => ({
|
|
|
193
193
|
})
|
|
194
194
|
|
|
195
195
|
// git's stricter score, halfway from -M's to 100%, for a pair that names alone
|
|
196
|
-
// put forward: a basename both sides have once, or a chunk's
|
|
196
|
+
// put forward: a basename both sides have once, or a chunk's of a name either
|
|
197
|
+
// side has more of.
|
|
197
198
|
const stricter = (minimum) => minimum + Math.trunc(0.5 * (MAX_SCORE - minimum))
|
|
198
199
|
|
|
199
200
|
// Each added file's rename by its index in `dests`: { source, score }. A
|