Skip to content

Commit 37f2bb7

Browse files
committed
beforeとafter逆だった
1 parent babd8e8 commit 37f2bb7

File tree

4 files changed

+31
-47
lines changed

4 files changed

+31
-47
lines changed

scripts/diff-match/for-multi.mjs

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,12 @@
11
/// <reference path="../util/type.mjs" />
2+
/// <reference path="./type.mjs" />
23

34
import path from 'path'
45
import { XMLParser } from 'fast-xml-parser'
56
import yargs from 'yargs'
67
import { RECORD_ACTION_PROP_NAMES } from '../util/constant.mjs'
78
import { readFile, writeFile } from '../util/file.mjs'
89

9-
/**
10-
* @typedef {object} DiffXml
11-
* @property {string} context
12-
* @property {DiffNode} root
13-
*/
14-
15-
/**
16-
* @typedef {object} DiffNode
17-
* @property {DiffNode | DiffNode[]} [tree]
18-
* @property {string} '@_type'
19-
* @property {string} [@_label]
20-
* @property {string} '@_pos'
21-
* @property {string} '@_length'
22-
* @property {string} [@_other_pos]
23-
* @property {string} [@_other_length]
24-
*/
25-
2610
const argv = await yargs(process.argv.slice(2))
2711
.option('file', {
2812
demandOption: true,
@@ -57,10 +41,10 @@ const idMapDir = argv.idMapDir
5741
const beforeTmpDir = argv.beforeTmpDir
5842
const afterTmpDir = argv.afterTmpDir
5943

60-
const rawXml = await readFile(`${fileName}.diff.xml`)
44+
const rawXml = await readFile(fileName)
6145

62-
console.log(`Processing file: ${fileName}.diff.xml`)
63-
console.log('file content:', rawXml)
46+
console.log(`Processing file: ${fileName}`)
47+
// console.log('file content:', rawXml)
6448

6549
/** @type {DiffXml} */
6650
const xml = new XMLParser({
@@ -158,8 +142,8 @@ const runXml = (xml, parent) => {
158142
break
159143
}
160144

161-
const afterPos = parseInt(xml['@_pos'])
162-
const beforePos = parseInt(xml['@_other_pos'])
145+
const beforePos = parseInt(xml['@_pos'])
146+
const afterPos = parseInt(xml['@_other_pos'])
163147
if (RECORD_ACTION_PROP_NAMES[identifier['@_label']]) {
164148
const parentPos = parseInt(parent['@_pos'])
165149

@@ -190,8 +174,8 @@ const runXml = (xml, parent) => {
190174
break
191175
}
192176

193-
const afterPos = parseInt(xml['@_pos'])
194-
const beforePos = parseInt(xml['@_other_pos'])
177+
const beforePos = parseInt(xml['@_pos'])
178+
const afterPos = parseInt(xml['@_other_pos'])
195179

196180
const normalizedBefore = normalizePos('before', beforePos)
197181
const normalizedAfter = normalizePos('after', afterPos)

scripts/diff-match/for-multi.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@ for commit in $commits; do
5252

5353
# Do diff matching
5454
docker run --rm -v "$left_tmp:/diff/left" -v "$right_tmp:/diff/right" -p 4567:4567 rozelin/gumtree:latest axmldiff left/$commit.tsx right/$commit.tsx > "$map_file_tmp_dir/$commit.diff.xml"
55-
node ./scripts/diff-match/main.mjs --file $map_file_tmp_dir/$commit.diff.xml --multiFiles $actual_files --projectRootDir $project_root_dir --idMapDir $map_file_dir --beforeTmpDir $left_tmp --afterTmpDir $right_tmp
55+
node ./scripts/diff-match/for-multi.mjs --file $map_file_tmp_dir/$commit.diff.xml --multiFiles $actual_files --projectRootDir $project_root_dir --idMapDir $map_file_dir --beforeTmpDir $left_tmp --afterTmpDir $right_tmp
5656
done

scripts/diff-match/main.mjs

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,11 @@
11
/// <reference path="../util/type.mjs" />
2+
/// <reference path="./type.mjs" />
23

34
import { XMLParser } from 'fast-xml-parser'
45
import yargs from 'yargs'
56
import { RECORD_ACTION_PROP_NAMES } from '../util/constant.mjs'
67
import { readFile, writeFile } from '../util/file.mjs'
78

8-
/**
9-
* @typedef {object} DiffXml
10-
* @property {string} context
11-
* @property {DiffNode} root
12-
*/
13-
14-
/**
15-
* @typedef {object} DiffNode
16-
* @property {DiffNode | DiffNode[]} [tree]
17-
* @property {string} '@_type'
18-
* @property {string} [@_label]
19-
* @property {string} '@_pos'
20-
* @property {string} '@_length'
21-
* @property {string} [@_other_pos]
22-
* @property {string} [@_other_length]
23-
*/
24-
259
const argv = await yargs(process.argv.slice(2))
2610
.option('file', {
2711
demandOption: true,
@@ -34,7 +18,7 @@ const fileName = argv.file
3418
const rawXml = await readFile(`${fileName}.diff.xml`)
3519

3620
console.log(`Processing file: ${fileName}.diff.xml`)
37-
console.log('file content:', rawXml)
21+
// console.log('file content:', rawXml)
3822

3923
/** @type {DiffXml} */
4024
const xml = new XMLParser({
@@ -76,8 +60,8 @@ const runXml = (xml, parent) => {
7660
break
7761
}
7862

79-
const afterPos = parseInt(xml['@_pos'])
80-
const beforePos = parseInt(xml['@_other_pos'])
63+
const beforePos = parseInt(xml['@_pos'])
64+
const afterPos = parseInt(xml['@_other_pos'])
8165
if (RECORD_ACTION_PROP_NAMES[identifier['@_label']]) {
8266
const parentPos = parseInt(parent['@_pos'])
8367

@@ -96,8 +80,8 @@ const runXml = (xml, parent) => {
9680
break
9781
}
9882

99-
const afterPos = parseInt(xml['@_pos'])
100-
const beforePos = parseInt(xml['@_other_pos'])
83+
const beforePos = parseInt(xml['@_pos'])
84+
const afterPos = parseInt(xml['@_other_pos'])
10185

10286
newIdMap[afterPos] = { ...idMap[beforePos], position: afterPos }
10387
break

scripts/diff-match/type.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @typedef {object} DiffXml
3+
* @property {string} context
4+
* @property {DiffNode} root
5+
*/
6+
7+
/**
8+
* @typedef {object} DiffNode
9+
* @property {DiffNode | DiffNode[]} [tree]
10+
* @property {string} '@_type'
11+
* @property {string} [@_label]
12+
* @property {string} '@_pos'
13+
* @property {string} '@_length'
14+
* @property {string} [@_other_pos]
15+
* @property {string} [@_other_length]
16+
*/

0 commit comments

Comments
 (0)