@teambit/merging 1.0.330 → 1.0.331
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/artifacts/__bit_junit.xml +1 -1
- package/artifacts/schema.json +454 -867
- package/dist/merge-files.d.ts +1 -1
- package/dist/merge-files.js +5 -12
- package/dist/merge-files.js.map +1 -1
- package/dist/merge-version/merge-version.js +4 -4
- package/dist/merge-version/merge-version.js.map +1 -1
- package/dist/merge-version/three-way-merge.d.ts +1 -1
- package/dist/merge-version/three-way-merge.js +23 -14
- package/dist/merge-version/three-way-merge.js.map +1 -1
- package/dist/merging.main.runtime.js +12 -12
- package/dist/merging.main.runtime.js.map +1 -1
- package/merge-version/merge-version.ts +1 -1
- package/merge-version/three-way-merge.ts +3 -2
- package/package.json +24 -17
- /package/dist/{preview-1720513025675.js → preview-1720667996237.js} +0 -0
package/dist/merge-files.d.ts
CHANGED
package/dist/merge-files.js
CHANGED
|
@@ -25,16 +25,9 @@ function _logger() {
|
|
|
25
25
|
};
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
const data =
|
|
30
|
-
|
|
31
|
-
return data;
|
|
32
|
-
};
|
|
33
|
-
return data;
|
|
34
|
-
}
|
|
35
|
-
function _gitExecutable() {
|
|
36
|
-
const data = _interopRequireDefault(require("@teambit/legacy/dist/utils/git/git-executable"));
|
|
37
|
-
_gitExecutable = function () {
|
|
28
|
+
function _gitModules() {
|
|
29
|
+
const data = require("@teambit/git.modules.git-executable");
|
|
30
|
+
_gitModules = function () {
|
|
38
31
|
return data;
|
|
39
32
|
};
|
|
40
33
|
return data;
|
|
@@ -60,7 +53,7 @@ async function mergeFiles({
|
|
|
60
53
|
output: null,
|
|
61
54
|
conflict: null
|
|
62
55
|
};
|
|
63
|
-
const gitExecutablePath = (0,
|
|
56
|
+
const gitExecutablePath = (0, _gitModules().getGitExecutablePath)();
|
|
64
57
|
try {
|
|
65
58
|
const result = await (0, _execa().default)('git', ['merge-file', '-L', currentFile.label, '-L', 'Base File', '-L', otherFile.label, currentFile.path, baseFile.path, otherFile.path, '-p'], {
|
|
66
59
|
stripFinalNewline: false
|
|
@@ -79,7 +72,7 @@ async function mergeFiles({
|
|
|
79
72
|
}
|
|
80
73
|
if (err.exitCodeName === 'ENOENT') {
|
|
81
74
|
_logger().default.error(`failed running Git at ${gitExecutablePath}. full command: ${err.command}`);
|
|
82
|
-
throw new (
|
|
75
|
+
throw new (_gitModules().GitNotFound)(gitExecutablePath, err);
|
|
83
76
|
}
|
|
84
77
|
throw new Error(`failed merging "${filePath}" by Git.
|
|
85
78
|
|
package/dist/merge-files.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_execa","_logger","
|
|
1
|
+
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_execa","_logger","_gitModules","e","__esModule","default","mergeFiles","filePath","currentFile","baseFile","otherFile","mergeResult","output","conflict","gitExecutablePath","getGitExecutablePath","result","execa","label","path","stripFinalNewline","stdout","err","exitCode","Number","isInteger","stderr","includes","isBinaryConflict","exitCodeName","logger","error","command","GitNotFound","Error","chalk","bold","message"],"sources":["merge-files.ts"],"sourcesContent":["import chalk from 'chalk';\nimport execa from 'execa';\nimport logger from '@teambit/legacy/dist/logger/logger';\nimport { GitNotFound, getGitExecutablePath } from '@teambit/git.modules.git-executable';\nimport { PathLinux, PathOsBased } from '@teambit/legacy.utils';\n\nexport type MergeFileResult = {\n filePath: PathLinux;\n output: string | null | undefined;\n conflict: string | null | undefined;\n isBinaryConflict?: boolean;\n};\nexport type MergeFileParams = {\n filePath: PathLinux;\n currentFile: {\n label: string;\n path: PathOsBased;\n };\n baseFile: {\n path: PathOsBased;\n };\n otherFile: {\n label: string;\n path: PathOsBased;\n };\n};\n\n/**\n * use git `merge-file` command. From the command help:\n * `git merge-file <current-file> <base-file> <other-file>\n * git merge-file incorporates all changes that lead from the <base-file> to <other-file> into\n * <current-file>. The result ordinarily goes into <current-file>.`\n *\n * Here, we are not going to write the result into current-file. Instead, we'll use the \"-p\" flag,\n * to just return the results.\n */\nexport async function mergeFiles({\n filePath,\n currentFile,\n baseFile,\n otherFile,\n}: MergeFileParams): Promise<MergeFileResult> {\n const mergeResult: MergeFileResult = { filePath, output: null, conflict: null };\n const gitExecutablePath = getGitExecutablePath();\n try {\n const result = await execa(\n 'git',\n [\n 'merge-file',\n '-L',\n currentFile.label,\n '-L',\n 'Base File',\n '-L',\n otherFile.label,\n currentFile.path,\n baseFile.path,\n otherFile.path,\n '-p',\n ],\n { stripFinalNewline: false }\n );\n mergeResult.output = result.stdout;\n return mergeResult;\n } catch (err: any) {\n if (err.exitCode && Number.isInteger(err.exitCode) && err.stdout) {\n // merge has been succeeded, return the diff results.\n mergeResult.conflict = err.stdout;\n return mergeResult;\n }\n if (err.exitCode && err.exitCode === 255 && err.stderr && err.stderr.includes('Cannot merge binary files')) {\n mergeResult.isBinaryConflict = true;\n return mergeResult;\n }\n if (err.exitCodeName === 'ENOENT') {\n logger.error(`failed running Git at ${gitExecutablePath}. full command: ${err.command}`);\n throw new GitNotFound(gitExecutablePath, err);\n }\n throw new Error(`failed merging \"${filePath}\" by Git.\n\n${chalk.bold('command:')} ${err.command}\n${chalk.bold('message:')} ${err.message}\n${chalk.bold('original error:')} ${err.stderr}`);\n throw err;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAA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,IAAIW,GAAG,CAACC,QAAQ,IAAID,GAAG,CAACC,QAAQ,KAAK,GAAG,IAAID,GAAG,CAACI,MAAM,IAAIJ,GAAG,CAACI,MAAM,CAACC,QAAQ,CAAC,2BAA2B,CAAC,EAAE;MAC1GhB,WAAW,CAACiB,gBAAgB,GAAG,IAAI;MACnC,OAAOjB,WAAW;IACpB;IACA,IAAIW,GAAG,CAACO,YAAY,KAAK,QAAQ,EAAE;MACjCC,iBAAM,CAACC,KAAK,CAAC,yBAAyBjB,iBAAiB,mBAAmBQ,GAAG,CAACU,OAAO,EAAE,CAAC;MACxF,MAAM,KAAIC,yBAAW,EAACnB,iBAAiB,EAAEQ,GAAG,CAAC;IAC/C;IACA,MAAM,IAAIY,KAAK,CAAC,mBAAmB3B,QAAQ;AAC/C;AACA,EAAE4B,gBAAK,CAACC,IAAI,CAAC,UAAU,CAAC,IAAId,GAAG,CAACU,OAAO;AACvC,EAAEG,gBAAK,CAACC,IAAI,CAAC,UAAU,CAAC,IAAId,GAAG,CAACe,OAAO;AACvC,EAAEF,gBAAK,CAACC,IAAI,CAAC,iBAAiB,CAAC,IAAId,GAAG,CAACI,MAAM,EAAE,CAAC;IAC5C,MAAMJ,GAAG;EACX;AACF","ignoreList":[]}
|
|
@@ -21,9 +21,9 @@ function _bitError() {
|
|
|
21
21
|
};
|
|
22
22
|
return data;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
const data = require("@teambit/legacy
|
|
26
|
-
|
|
24
|
+
function _legacyCli() {
|
|
25
|
+
const data = require("@teambit/legacy.cli.prompts");
|
|
26
|
+
_legacyCli = function () {
|
|
27
27
|
return data;
|
|
28
28
|
};
|
|
29
29
|
return data;
|
|
@@ -55,7 +55,7 @@ const FileStatus = exports.FileStatus = {
|
|
|
55
55
|
};
|
|
56
56
|
async function getMergeStrategyInteractive() {
|
|
57
57
|
try {
|
|
58
|
-
const result = await (0,
|
|
58
|
+
const result = await (0, _legacyCli().resolveConflictPrompt)();
|
|
59
59
|
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
60
60
|
return mergeOptionsCli[result.mergeStrategy];
|
|
61
61
|
} catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_bitError","
|
|
1
|
+
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_bitError","_legacyCli","e","__esModule","default","mergeOptionsCli","exports","o","t","m","MergeOptions","ours","theirs","manual","FileStatus","merged","chalk","green","red","binaryConflict","updated","added","removed","overridden","yellow","unchanged","remainDeleted","deletedConflict","getMergeStrategyInteractive","result","resolveConflictPrompt","mergeStrategy","err","BitError","getMergeStrategy"],"sources":["merge-version.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { BitError } from '@teambit/bit-error';\nimport { resolveConflictPrompt } from '@teambit/legacy.cli.prompts';\n\nexport const mergeOptionsCli = { o: 'ours', t: 'theirs', m: 'manual' };\nexport const MergeOptions = { ours: 'ours', theirs: 'theirs', manual: 'manual' };\n// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\nexport type MergeStrategy = keyof typeof MergeOptions;\nexport const FileStatus = {\n merged: chalk.green('auto-merged'),\n manual: chalk.red('CONFLICT'),\n binaryConflict: chalk.red('unchanged-BINARY-CONFLICT'),\n updated: chalk.green('updated'),\n added: chalk.green('added'),\n removed: chalk.green('removed'),\n overridden: chalk.yellow('overridden'),\n unchanged: chalk.green('unchanged'),\n remainDeleted: chalk.green('remain-deleted'),\n deletedConflict: chalk.red('CONFLICT-deleted-and-modified'),\n};\n\nexport async function getMergeStrategyInteractive(): Promise<MergeStrategy> {\n try {\n const result = await resolveConflictPrompt();\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n return mergeOptionsCli[result.mergeStrategy];\n } catch (err: any) {\n // probably user clicked ^C\n throw new BitError('the action has been canceled');\n }\n}\n\nexport function getMergeStrategy(ours: boolean, theirs: boolean, manual: boolean): MergeStrategy | null | undefined {\n if ((ours && theirs) || (ours && manual) || (theirs && manual)) {\n throw new BitError('please choose only one of the following: ours, theirs or manual');\n }\n if (ours) return MergeOptions.ours as any;\n if (theirs) return MergeOptions.theirs as any;\n if (manual) return MergeOptions.manual as any;\n return null;\n}\n"],"mappings":";;;;;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,UAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,WAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,UAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAoE,SAAAC,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE7D,MAAMG,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAG;EAAEE,CAAC,EAAE,MAAM;EAAEC,CAAC,EAAE,QAAQ;EAAEC,CAAC,EAAE;AAAS,CAAC;AAC/D,MAAMC,YAAY,GAAAJ,OAAA,CAAAI,YAAA,GAAG;EAAEC,IAAI,EAAE,MAAM;EAAEC,MAAM,EAAE,QAAQ;EAAEC,MAAM,EAAE;AAAS,CAAC;AAChF;;AAEO,MAAMC,UAAU,GAAAR,OAAA,CAAAQ,UAAA,GAAG;EACxBC,MAAM,EAAEC,gBAAK,CAACC,KAAK,CAAC,aAAa,CAAC;EAClCJ,MAAM,EAAEG,gBAAK,CAACE,GAAG,CAAC,UAAU,CAAC;EAC7BC,cAAc,EAAEH,gBAAK,CAACE,GAAG,CAAC,2BAA2B,CAAC;EACtDE,OAAO,EAAEJ,gBAAK,CAACC,KAAK,CAAC,SAAS,CAAC;EAC/BI,KAAK,EAAEL,gBAAK,CAACC,KAAK,CAAC,OAAO,CAAC;EAC3BK,OAAO,EAAEN,gBAAK,CAACC,KAAK,CAAC,SAAS,CAAC;EAC/BM,UAAU,EAAEP,gBAAK,CAACQ,MAAM,CAAC,YAAY,CAAC;EACtCC,SAAS,EAAET,gBAAK,CAACC,KAAK,CAAC,WAAW,CAAC;EACnCS,aAAa,EAAEV,gBAAK,CAACC,KAAK,CAAC,gBAAgB,CAAC;EAC5CU,eAAe,EAAEX,gBAAK,CAACE,GAAG,CAAC,+BAA+B;AAC5D,CAAC;AAEM,eAAeU,2BAA2BA,CAAA,EAA2B;EAC1E,IAAI;IACF,MAAMC,MAAM,GAAG,MAAM,IAAAC,kCAAqB,EAAC,CAAC;IAC5C;IACA,OAAOzB,eAAe,CAACwB,MAAM,CAACE,aAAa,CAAC;EAC9C,CAAC,CAAC,OAAOC,GAAQ,EAAE;IACjB;IACA,MAAM,KAAIC,oBAAQ,EAAC,8BAA8B,CAAC;EACpD;AACF;AAEO,SAASC,gBAAgBA,CAACvB,IAAa,EAAEC,MAAe,EAAEC,MAAe,EAAoC;EAClH,IAAKF,IAAI,IAAIC,MAAM,IAAMD,IAAI,IAAIE,MAAO,IAAKD,MAAM,IAAIC,MAAO,EAAE;IAC9D,MAAM,KAAIoB,oBAAQ,EAAC,iEAAiE,CAAC;EACvF;EACA,IAAItB,IAAI,EAAE,OAAOD,YAAY,CAACC,IAAI;EAClC,IAAIC,MAAM,EAAE,OAAOF,YAAY,CAACE,MAAM;EACtC,IAAIC,MAAM,EAAE,OAAOH,YAAY,CAACG,MAAM;EACtC,OAAO,IAAI;AACb","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Version } from '@teambit/legacy/dist/scope/models';
|
|
2
2
|
import { SourceFileModel } from '@teambit/legacy/dist/scope/models/version';
|
|
3
|
-
import { PathLinux } from '@teambit/
|
|
3
|
+
import { PathLinux } from '@teambit/toolbox.path.path';
|
|
4
4
|
import Component from '@teambit/legacy/dist/consumer/component';
|
|
5
5
|
import { SourceFile } from '@teambit/legacy/dist/consumer/component/sources';
|
|
6
6
|
import { Scope } from '@teambit/legacy/dist/scope';
|
|
@@ -18,23 +18,30 @@ function _repositories() {
|
|
|
18
18
|
};
|
|
19
19
|
return data;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
const data = require("@teambit/
|
|
23
|
-
|
|
21
|
+
function _toolboxCrypto() {
|
|
22
|
+
const data = require("@teambit/toolbox.crypto.sha1");
|
|
23
|
+
_toolboxCrypto = function () {
|
|
24
24
|
return data;
|
|
25
25
|
};
|
|
26
26
|
return data;
|
|
27
27
|
}
|
|
28
|
-
function
|
|
29
|
-
const data = require("
|
|
30
|
-
|
|
28
|
+
function _toolboxPath() {
|
|
29
|
+
const data = require("@teambit/toolbox.path.path");
|
|
30
|
+
_toolboxPath = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
function eol() {
|
|
36
|
+
const data = _interopRequireWildcard(require("@teambit/toolbox.string.eol"));
|
|
37
|
+
eol = function () {
|
|
31
38
|
return data;
|
|
32
39
|
};
|
|
33
40
|
return data;
|
|
34
41
|
}
|
|
35
|
-
function
|
|
36
|
-
const data = require("
|
|
37
|
-
|
|
42
|
+
function _mergeFiles() {
|
|
43
|
+
const data = require("../merge-files");
|
|
44
|
+
_mergeFiles = function () {
|
|
38
45
|
return data;
|
|
39
46
|
};
|
|
40
47
|
return data;
|
|
@@ -53,6 +60,8 @@ function _lodash() {
|
|
|
53
60
|
};
|
|
54
61
|
return data;
|
|
55
62
|
}
|
|
63
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
64
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
56
65
|
/**
|
|
57
66
|
* to do the actual merge we use git, specifically `merge-file` command, so we try to use the same
|
|
58
67
|
* terminology as git. From the command help:
|
|
@@ -89,7 +98,7 @@ async function threeWayMerge({
|
|
|
89
98
|
const otherFiles = otherComponent.files;
|
|
90
99
|
const currentFiles = currentComponent.cloneFilesWithSharedDir();
|
|
91
100
|
currentFiles.forEach(fsFile => {
|
|
92
|
-
fsFile.contents =
|
|
101
|
+
fsFile.contents = eol().lf(fsFile.contents);
|
|
93
102
|
});
|
|
94
103
|
const results = {
|
|
95
104
|
addFiles: [],
|
|
@@ -103,9 +112,9 @@ async function threeWayMerge({
|
|
|
103
112
|
hasConflicts: false
|
|
104
113
|
};
|
|
105
114
|
const getFileResult = async (fsFile, baseFile, otherFile) => {
|
|
106
|
-
const filePath = (0,
|
|
115
|
+
const filePath = (0, _toolboxPath().pathNormalizeToLinux)(fsFile.relative);
|
|
107
116
|
// @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
|
|
108
|
-
const fsFileHash = (0,
|
|
117
|
+
const fsFileHash = (0, _toolboxCrypto().sha1)(fsFile.contents);
|
|
109
118
|
if (!otherFile) {
|
|
110
119
|
// if !otherFile && !baseFile, the file was created after the last tag, no need to do any
|
|
111
120
|
// calculation, the file should be added
|
|
@@ -163,12 +172,12 @@ async function threeWayMerge({
|
|
|
163
172
|
});
|
|
164
173
|
};
|
|
165
174
|
await Promise.all(currentFiles.map(async fsFile => {
|
|
166
|
-
const relativePath = (0,
|
|
175
|
+
const relativePath = (0, _toolboxPath().pathNormalizeToLinux)(fsFile.relative);
|
|
167
176
|
const baseFile = baseFiles.find(file => file.relativePath === relativePath);
|
|
168
177
|
const otherFile = otherFiles.find(file => file.relativePath === relativePath);
|
|
169
178
|
await getFileResult(fsFile, baseFile, otherFile);
|
|
170
179
|
}));
|
|
171
|
-
const fsFilesPaths = currentFiles.map(fsFile => (0,
|
|
180
|
+
const fsFilesPaths = currentFiles.map(fsFile => (0, _toolboxPath().pathNormalizeToLinux)(fsFile.relative));
|
|
172
181
|
const baseFilesPaths = baseFiles.map(baseFile => baseFile.relativePath);
|
|
173
182
|
const isOtherSameAsBase = otherFile => {
|
|
174
183
|
const baseFile = baseFiles.find(file => file.relativePath === otherFile.relativePath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_bitError","data","require","_repositories","_utils","_mergeFiles","_path","_sources","_lodash","threeWayMerge","scope","otherComponent","otherLabel","currentComponent","currentLabel","baseComponent","baseFiles","files","otherFiles","currentFiles","cloneFilesWithSharedDir","forEach","fsFile","contents","eol","lf","results","addFiles","removeFiles","remainDeletedFiles","deletedConflictFiles","modifiedFiles","unModifiedFiles","overrideFiles","updatedFiles","hasConflicts","getFileResult","baseFile","otherFile","filePath","pathNormalizeToLinux","relative","fsFileHash","sha1","push","baseFileHash","file","hash","otherFileHash","content","load","objects","label","output","conflict","Promise","all","map","relativePath","find","fsFilesPaths","baseFilesPaths","isOtherSameAsBase","Error","deletedFromFs","filter","includes","deletedAndModified","addedOnOther","SourceFile","loadFromSourceFileModel","isEmpty","conflictResults","getMergeResults","conflictResult","modifiedFile","BitError","isBinaryConflict","tmp","Tmp","conflictResultsP","fsFilePathP","save","writeFile","toString","baseFilePathP","otherFilePathP","fsFilePath","baseFilePath","otherFilePath","mergeFilesParams","currentFile","path","mergeFiles"],"sources":["three-way-merge.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport { Source, Version } from '@teambit/legacy/dist/scope/models';\nimport { SourceFileModel } from '@teambit/legacy/dist/scope/models/version';\nimport { Tmp } from '@teambit/legacy/dist/scope/repositories';\nimport { eol, sha1 } from '@teambit/legacy/dist/utils';\nimport { mergeFiles, MergeFileParams, MergeFileResult } from '../merge-files';\nimport { PathLinux, pathNormalizeToLinux, PathOsBased } from '@teambit/legacy/dist/utils/path';\nimport Component from '@teambit/legacy/dist/consumer/component';\nimport { SourceFile } from '@teambit/legacy/dist/consumer/component/sources';\nimport { Scope } from '@teambit/legacy/dist/scope';\nimport { isEmpty } from 'lodash';\n\nexport type MergeResultsThreeWay = {\n addFiles: Array<{\n filePath: PathLinux;\n fsFile: SourceFile;\n }>;\n removeFiles: Array<{\n filePath: PathLinux;\n }>;\n remainDeletedFiles: Array<{\n filePath: PathLinux;\n }>;\n deletedConflictFiles: Array<{\n filePath: PathLinux;\n fsFile?: SourceFile;\n }>;\n modifiedFiles: Array<{\n filePath: PathLinux;\n fsFile: SourceFile;\n baseFile?: SourceFileModel;\n otherFile: SourceFileModel;\n output: string | null | undefined;\n conflict: string | null | undefined;\n isBinaryConflict?: boolean;\n }>;\n unModifiedFiles: Array<{\n filePath: PathLinux;\n fsFile: SourceFile;\n }>;\n overrideFiles: Array<{\n filePath: PathLinux;\n fsFile: SourceFile;\n }>;\n updatedFiles: Array<{\n filePath: PathLinux;\n otherFile: SourceFileModel;\n content: Buffer;\n }>;\n hasConflicts: boolean;\n};\n\n/**\n * to do the actual merge we use git, specifically `merge-file` command, so we try to use the same\n * terminology as git. From the command help:\n * `git merge-file <current-file> <base-file> <other-file>\n * git merge-file incorporates all changes that lead from the <base-file> to <other-file> into\n * <current-file>. The result ordinarily goes into <current-file>.`\n *\n * see checkout-version.getBaseVersion() for a case when a component is modified and then the base-file is not the\n * common file before other-file and current-file.\n * otherwise, Git terminology pretty much reflects what we do here. current-file is the one that is currently written\n * to the filesystem. other-file is the one the user wants to checkout to. base-file is the original file where both:\n * base-file and other-file were originated from.\n */\nexport async function threeWayMerge({\n scope,\n otherComponent,\n otherLabel,\n currentComponent,\n currentLabel,\n baseComponent,\n}: {\n scope: Scope;\n otherComponent: Version;\n otherLabel: string;\n currentComponent: Component;\n currentLabel: string;\n baseComponent: Version;\n}): Promise<MergeResultsThreeWay> {\n // baseFiles and currentFiles come from the model, therefore their paths include the\n // sharedOriginallyDir. fsFiles come from the Fs, therefore their paths don't include the\n // sharedOriginallyDir.\n // option 1) strip sharedOriginallyDir from baseFiles and currentFiles. the problem is that the\n // sharedDir can be different if the dependencies were changes for example, as a result, it won't\n // be possible to compare between the files as the paths are different.\n // in the previous it was implemented this way and caused a bug, which now has an e2e-test to\n // block it. see https://github.com/teambit/bit/pull/2070 PR.\n // option 2) add sharedOriginallyDir to the fsFiles. we must go with this option.\n // one thing we have to change is the end-of-line, it should be set as LF, same way we do before\n // saving the file as an object.\n const baseFiles: SourceFileModel[] = baseComponent.files;\n const otherFiles: SourceFileModel[] = otherComponent.files;\n const currentFiles: SourceFile[] = currentComponent.cloneFilesWithSharedDir();\n currentFiles.forEach((fsFile) => {\n fsFile.contents = eol.lf(fsFile.contents) as Buffer;\n });\n const results: MergeResultsThreeWay = {\n addFiles: [],\n removeFiles: [],\n remainDeletedFiles: [],\n deletedConflictFiles: [],\n modifiedFiles: [],\n unModifiedFiles: [],\n overrideFiles: [],\n updatedFiles: [],\n hasConflicts: false,\n };\n const getFileResult = async (fsFile: SourceFile, baseFile?: SourceFileModel, otherFile?: SourceFileModel) => {\n const filePath: PathLinux = pathNormalizeToLinux(fsFile.relative);\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const fsFileHash = sha1(fsFile.contents);\n if (!otherFile) {\n // if !otherFile && !baseFile, the file was created after the last tag, no need to do any\n // calculation, the file should be added\n if (!baseFile) {\n results.addFiles.push({ filePath, fsFile });\n return;\n }\n const baseFileHash = baseFile.file.hash;\n if (fsFileHash === baseFileHash) {\n results.removeFiles.push({ filePath });\n return;\n }\n results.deletedConflictFiles.push({ filePath });\n return;\n }\n const otherFileHash = otherFile.file.hash;\n if (fsFileHash === otherFileHash) {\n // if fs === other, no need to take any action (regardless the base)\n results.unModifiedFiles.push({ filePath, fsFile });\n return;\n }\n if (baseFile && fsFileHash === baseFile.file.hash) {\n // the file has no local modification.\n // the file currently in the fs, is not the same as the file we want to write (other).\n // but no need to check whether it has conflicts because we always want to write the other.\n const content = (await otherFile.file.load(scope.objects)) as Source;\n results.updatedFiles.push({ filePath, otherFile, content: content.contents });\n return;\n }\n // it was changed in both, there is a chance for conflict. (regardless the base)\n fsFile.label = currentLabel;\n // @ts-ignore it's a hack to pass the data, version is not a valid attribute.\n otherFile.label = otherLabel;\n results.modifiedFiles.push({ filePath, fsFile, baseFile, otherFile, output: null, conflict: null });\n };\n\n await Promise.all(\n currentFiles.map(async (fsFile) => {\n const relativePath = pathNormalizeToLinux(fsFile.relative);\n const baseFile = baseFiles.find((file) => file.relativePath === relativePath);\n const otherFile = otherFiles.find((file) => file.relativePath === relativePath);\n await getFileResult(fsFile, baseFile, otherFile);\n })\n );\n const fsFilesPaths = currentFiles.map((fsFile) => pathNormalizeToLinux(fsFile.relative));\n const baseFilesPaths = baseFiles.map((baseFile) => baseFile.relativePath);\n const isOtherSameAsBase = (otherFile: SourceFileModel) => {\n const baseFile = baseFiles.find((file) => file.relativePath === otherFile.relativePath);\n if (!baseFile) throw new Error('isOtherSameAsBase expect the base to be there');\n return baseFile.file.hash === otherFile.file.hash;\n };\n const deletedFromFs = otherFiles.filter(\n (otherFile) =>\n !fsFilesPaths.includes(otherFile.relativePath) &&\n baseFilesPaths.includes(otherFile.relativePath) &&\n isOtherSameAsBase(otherFile)\n );\n const deletedAndModified = otherFiles.filter(\n (otherFile) =>\n !fsFilesPaths.includes(otherFile.relativePath) &&\n baseFilesPaths.includes(otherFile.relativePath) &&\n !isOtherSameAsBase(otherFile)\n );\n const addedOnOther = otherFiles.filter(\n (otherFile) => !fsFilesPaths.includes(otherFile.relativePath) && !baseFilesPaths.includes(otherFile.relativePath)\n );\n deletedFromFs.forEach((file) => results.remainDeletedFiles.push({ filePath: file.relativePath }));\n deletedAndModified.forEach((file) => results.deletedConflictFiles.push({ filePath: file.relativePath }));\n\n await Promise.all(\n addedOnOther.map(async (file) => {\n const fsFile = await SourceFile.loadFromSourceFileModel(file, scope.objects);\n results.addFiles.push({ filePath: file.relativePath, fsFile });\n })\n );\n await Promise.all(\n deletedAndModified.map(async (file) => {\n const fsFile = await SourceFile.loadFromSourceFileModel(file, scope.objects);\n results.deletedConflictFiles.push({ filePath: file.relativePath, fsFile });\n })\n );\n if (isEmpty(results.modifiedFiles)) return results;\n\n const conflictResults = await getMergeResults(scope, results.modifiedFiles);\n conflictResults.forEach((conflictResult: MergeFileResult) => {\n const modifiedFile = results.modifiedFiles.find((file) => file.filePath === conflictResult.filePath);\n if (!modifiedFile) throw new BitError(`unable to find ${conflictResult.filePath} in modified files array`);\n modifiedFile.output = conflictResult.output;\n modifiedFile.conflict = conflictResult.conflict;\n modifiedFile.isBinaryConflict = conflictResult.isBinaryConflict;\n if (conflictResult.conflict || conflictResult.isBinaryConflict) results.hasConflicts = true;\n });\n\n return results;\n}\n\nasync function getMergeResults(\n scope: Scope,\n modifiedFiles: MergeResultsThreeWay['modifiedFiles']\n): Promise<MergeFileResult[]> {\n const tmp = new Tmp(scope);\n const conflictResultsP = modifiedFiles.map(async (modifiedFile) => {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const fsFilePathP = tmp.save(modifiedFile.fsFile.contents);\n const writeFile = async (file: SourceFileModel): Promise<PathOsBased> => {\n const content = await file.file.load(scope.objects);\n // @ts-ignore\n return tmp.save(content.contents.toString());\n };\n const baseFilePathP = modifiedFile.baseFile ? writeFile(modifiedFile.baseFile) : tmp.save('');\n const otherFilePathP = writeFile(modifiedFile.otherFile);\n const [fsFilePath, baseFilePath, otherFilePath] = await Promise.all([fsFilePathP, baseFilePathP, otherFilePathP]);\n const mergeFilesParams: MergeFileParams = {\n filePath: modifiedFile.filePath,\n currentFile: {\n label: modifiedFile.fsFile.label,\n path: fsFilePath,\n },\n baseFile: {\n path: baseFilePath,\n },\n otherFile: {\n // @ts-ignore\n label: modifiedFile.otherFile.label,\n path: otherFilePath,\n },\n };\n return mergeFiles(mergeFilesParams);\n });\n return Promise.all(conflictResultsP);\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAE,cAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,aAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,MAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,MAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,KAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,SAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,QAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAO,QAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,OAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AA0CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeQ,aAAaA,CAAC;EAClCC,KAAK;EACLC,cAAc;EACd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AAY,CAACtC,QAAQ,CAAC,GAAGyC,GAAG,CAACI,IAAI,CAAC,EAAE,CAAC;IAC7F,MAAMI,cAAc,GAAGH,SAAS,CAACR,YAAY,CAACrC,SAAS,CAAC;IACxD,MAAM,CAACiD,UAAU,EAAEC,YAAY,EAAEC,aAAa,CAAC,GAAG,MAAMlC,OAAO,CAACC,GAAG,CAAC,CAACyB,WAAW,EAAEI,aAAa,EAAEC,cAAc,CAAC,CAAC;IACjH,MAAMI,gBAAiC,GAAG;MACxCnD,QAAQ,EAAEoC,YAAY,CAACpC,QAAQ;MAC/BoD,WAAW,EAAE;QACXvC,KAAK,EAAEuB,YAAY,CAACrD,MAAM,CAAC8B,KAAK;QAChCwC,IAAI,EAAEL;MACR,CAAC;MACDlD,QAAQ,EAAE;QACRuD,IAAI,EAAEJ;MACR,CAAC;MACDlD,SAAS,EAAE;QACT;QACAc,KAAK,EAAEuB,YAAY,CAACrC,SAAS,CAACc,KAAK;QACnCwC,IAAI,EAAEH;MACR;IACF,CAAC;IACD,OAAO,IAAAI,wBAAU,EAACH,gBAAgB,CAAC;EACrC,CAAC,CAAC;EACF,OAAOnC,OAAO,CAACC,GAAG,CAACwB,gBAAgB,CAAC;AACtC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_bitError","data","require","_repositories","_toolboxCrypto","_toolboxPath","eol","_interopRequireWildcard","_mergeFiles","_sources","_lodash","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","threeWayMerge","scope","otherComponent","otherLabel","currentComponent","currentLabel","baseComponent","baseFiles","files","otherFiles","currentFiles","cloneFilesWithSharedDir","forEach","fsFile","contents","lf","results","addFiles","removeFiles","remainDeletedFiles","deletedConflictFiles","modifiedFiles","unModifiedFiles","overrideFiles","updatedFiles","hasConflicts","getFileResult","baseFile","otherFile","filePath","pathNormalizeToLinux","relative","fsFileHash","sha1","push","baseFileHash","file","hash","otherFileHash","content","load","objects","label","output","conflict","Promise","all","map","relativePath","find","fsFilesPaths","baseFilesPaths","isOtherSameAsBase","Error","deletedFromFs","filter","includes","deletedAndModified","addedOnOther","SourceFile","loadFromSourceFileModel","isEmpty","conflictResults","getMergeResults","conflictResult","modifiedFile","BitError","isBinaryConflict","tmp","Tmp","conflictResultsP","fsFilePathP","save","writeFile","toString","baseFilePathP","otherFilePathP","fsFilePath","baseFilePath","otherFilePath","mergeFilesParams","currentFile","path","mergeFiles"],"sources":["three-way-merge.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport { Source, Version } from '@teambit/legacy/dist/scope/models';\nimport { SourceFileModel } from '@teambit/legacy/dist/scope/models/version';\nimport { Tmp } from '@teambit/legacy/dist/scope/repositories';\nimport { sha1 } from '@teambit/toolbox.crypto.sha1';\nimport { PathLinux, pathNormalizeToLinux, PathOsBased } from '@teambit/toolbox.path.path';\nimport * as eol from '@teambit/toolbox.string.eol';\nimport { mergeFiles, MergeFileParams, MergeFileResult } from '../merge-files';\nimport Component from '@teambit/legacy/dist/consumer/component';\nimport { SourceFile } from '@teambit/legacy/dist/consumer/component/sources';\nimport { Scope } from '@teambit/legacy/dist/scope';\nimport { isEmpty } from 'lodash';\n\nexport type MergeResultsThreeWay = {\n addFiles: Array<{\n filePath: PathLinux;\n fsFile: SourceFile;\n }>;\n removeFiles: Array<{\n filePath: PathLinux;\n }>;\n remainDeletedFiles: Array<{\n filePath: PathLinux;\n }>;\n deletedConflictFiles: Array<{\n filePath: PathLinux;\n fsFile?: SourceFile;\n }>;\n modifiedFiles: Array<{\n filePath: PathLinux;\n fsFile: SourceFile;\n baseFile?: SourceFileModel;\n otherFile: SourceFileModel;\n output: string | null | undefined;\n conflict: string | null | undefined;\n isBinaryConflict?: boolean;\n }>;\n unModifiedFiles: Array<{\n filePath: PathLinux;\n fsFile: SourceFile;\n }>;\n overrideFiles: Array<{\n filePath: PathLinux;\n fsFile: SourceFile;\n }>;\n updatedFiles: Array<{\n filePath: PathLinux;\n otherFile: SourceFileModel;\n content: Buffer;\n }>;\n hasConflicts: boolean;\n};\n\n/**\n * to do the actual merge we use git, specifically `merge-file` command, so we try to use the same\n * terminology as git. From the command help:\n * `git merge-file <current-file> <base-file> <other-file>\n * git merge-file incorporates all changes that lead from the <base-file> to <other-file> into\n * <current-file>. The result ordinarily goes into <current-file>.`\n *\n * see checkout-version.getBaseVersion() for a case when a component is modified and then the base-file is not the\n * common file before other-file and current-file.\n * otherwise, Git terminology pretty much reflects what we do here. current-file is the one that is currently written\n * to the filesystem. other-file is the one the user wants to checkout to. base-file is the original file where both:\n * base-file and other-file were originated from.\n */\nexport async function threeWayMerge({\n scope,\n otherComponent,\n otherLabel,\n currentComponent,\n currentLabel,\n baseComponent,\n}: {\n scope: Scope;\n otherComponent: Version;\n otherLabel: string;\n currentComponent: Component;\n currentLabel: string;\n baseComponent: Version;\n}): Promise<MergeResultsThreeWay> {\n // baseFiles and currentFiles come from the model, therefore their paths include the\n // sharedOriginallyDir. fsFiles come from the Fs, therefore their paths don't include the\n // sharedOriginallyDir.\n // option 1) strip sharedOriginallyDir from baseFiles and currentFiles. the problem is that the\n // sharedDir can be different if the dependencies were changes for example, as a result, it won't\n // be possible to compare between the files as the paths are different.\n // in the previous it was implemented this way and caused a bug, which now has an e2e-test to\n // block it. see https://github.com/teambit/bit/pull/2070 PR.\n // option 2) add sharedOriginallyDir to the fsFiles. we must go with this option.\n // one thing we have to change is the end-of-line, it should be set as LF, same way we do before\n // saving the file as an object.\n const baseFiles: SourceFileModel[] = baseComponent.files;\n const otherFiles: SourceFileModel[] = otherComponent.files;\n const currentFiles: SourceFile[] = currentComponent.cloneFilesWithSharedDir();\n currentFiles.forEach((fsFile) => {\n fsFile.contents = eol.lf(fsFile.contents) as Buffer;\n });\n const results: MergeResultsThreeWay = {\n addFiles: [],\n removeFiles: [],\n remainDeletedFiles: [],\n deletedConflictFiles: [],\n modifiedFiles: [],\n unModifiedFiles: [],\n overrideFiles: [],\n updatedFiles: [],\n hasConflicts: false,\n };\n const getFileResult = async (fsFile: SourceFile, baseFile?: SourceFileModel, otherFile?: SourceFileModel) => {\n const filePath: PathLinux = pathNormalizeToLinux(fsFile.relative);\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const fsFileHash = sha1(fsFile.contents);\n if (!otherFile) {\n // if !otherFile && !baseFile, the file was created after the last tag, no need to do any\n // calculation, the file should be added\n if (!baseFile) {\n results.addFiles.push({ filePath, fsFile });\n return;\n }\n const baseFileHash = baseFile.file.hash;\n if (fsFileHash === baseFileHash) {\n results.removeFiles.push({ filePath });\n return;\n }\n results.deletedConflictFiles.push({ filePath });\n return;\n }\n const otherFileHash = otherFile.file.hash;\n if (fsFileHash === otherFileHash) {\n // if fs === other, no need to take any action (regardless the base)\n results.unModifiedFiles.push({ filePath, fsFile });\n return;\n }\n if (baseFile && fsFileHash === baseFile.file.hash) {\n // the file has no local modification.\n // the file currently in the fs, is not the same as the file we want to write (other).\n // but no need to check whether it has conflicts because we always want to write the other.\n const content = (await otherFile.file.load(scope.objects)) as Source;\n results.updatedFiles.push({ filePath, otherFile, content: content.contents });\n return;\n }\n // it was changed in both, there is a chance for conflict. (regardless the base)\n fsFile.label = currentLabel;\n // @ts-ignore it's a hack to pass the data, version is not a valid attribute.\n otherFile.label = otherLabel;\n results.modifiedFiles.push({ filePath, fsFile, baseFile, otherFile, output: null, conflict: null });\n };\n\n await Promise.all(\n currentFiles.map(async (fsFile) => {\n const relativePath = pathNormalizeToLinux(fsFile.relative);\n const baseFile = baseFiles.find((file) => file.relativePath === relativePath);\n const otherFile = otherFiles.find((file) => file.relativePath === relativePath);\n await getFileResult(fsFile, baseFile, otherFile);\n })\n );\n const fsFilesPaths = currentFiles.map((fsFile) => pathNormalizeToLinux(fsFile.relative));\n const baseFilesPaths = baseFiles.map((baseFile) => baseFile.relativePath);\n const isOtherSameAsBase = (otherFile: SourceFileModel) => {\n const baseFile = baseFiles.find((file) => file.relativePath === otherFile.relativePath);\n if (!baseFile) throw new Error('isOtherSameAsBase expect the base to be there');\n return baseFile.file.hash === otherFile.file.hash;\n };\n const deletedFromFs = otherFiles.filter(\n (otherFile) =>\n !fsFilesPaths.includes(otherFile.relativePath) &&\n baseFilesPaths.includes(otherFile.relativePath) &&\n isOtherSameAsBase(otherFile)\n );\n const deletedAndModified = otherFiles.filter(\n (otherFile) =>\n !fsFilesPaths.includes(otherFile.relativePath) &&\n baseFilesPaths.includes(otherFile.relativePath) &&\n !isOtherSameAsBase(otherFile)\n );\n const addedOnOther = otherFiles.filter(\n (otherFile) => !fsFilesPaths.includes(otherFile.relativePath) && !baseFilesPaths.includes(otherFile.relativePath)\n );\n deletedFromFs.forEach((file) => results.remainDeletedFiles.push({ filePath: file.relativePath }));\n deletedAndModified.forEach((file) => results.deletedConflictFiles.push({ filePath: file.relativePath }));\n\n await Promise.all(\n addedOnOther.map(async (file) => {\n const fsFile = await SourceFile.loadFromSourceFileModel(file, scope.objects);\n results.addFiles.push({ filePath: file.relativePath, fsFile });\n })\n );\n await Promise.all(\n deletedAndModified.map(async (file) => {\n const fsFile = await SourceFile.loadFromSourceFileModel(file, scope.objects);\n results.deletedConflictFiles.push({ filePath: file.relativePath, fsFile });\n })\n );\n if (isEmpty(results.modifiedFiles)) return results;\n\n const conflictResults = await getMergeResults(scope, results.modifiedFiles);\n conflictResults.forEach((conflictResult: MergeFileResult) => {\n const modifiedFile = results.modifiedFiles.find((file) => file.filePath === conflictResult.filePath);\n if (!modifiedFile) throw new BitError(`unable to find ${conflictResult.filePath} in modified files array`);\n modifiedFile.output = conflictResult.output;\n modifiedFile.conflict = conflictResult.conflict;\n modifiedFile.isBinaryConflict = conflictResult.isBinaryConflict;\n if (conflictResult.conflict || conflictResult.isBinaryConflict) results.hasConflicts = true;\n });\n\n return results;\n}\n\nasync function getMergeResults(\n scope: Scope,\n modifiedFiles: MergeResultsThreeWay['modifiedFiles']\n): Promise<MergeFileResult[]> {\n const tmp = new Tmp(scope);\n const conflictResultsP = modifiedFiles.map(async (modifiedFile) => {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const fsFilePathP = tmp.save(modifiedFile.fsFile.contents);\n const writeFile = async (file: SourceFileModel): Promise<PathOsBased> => {\n const content = await file.file.load(scope.objects);\n // @ts-ignore\n return tmp.save(content.contents.toString());\n };\n const baseFilePathP = modifiedFile.baseFile ? writeFile(modifiedFile.baseFile) : tmp.save('');\n const otherFilePathP = writeFile(modifiedFile.otherFile);\n const [fsFilePath, baseFilePath, otherFilePath] = await Promise.all([fsFilePathP, baseFilePathP, otherFilePathP]);\n const mergeFilesParams: MergeFileParams = {\n filePath: modifiedFile.filePath,\n currentFile: {\n label: modifiedFile.fsFile.label,\n path: fsFilePath,\n },\n baseFile: {\n path: baseFilePath,\n },\n otherFile: {\n // @ts-ignore\n label: modifiedFile.otherFile.label,\n path: otherFilePath,\n },\n };\n return mergeFiles(mergeFilesParams);\n });\n return Promise.all(conflictResultsP);\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAE,cAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,aAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,eAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,cAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,aAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,YAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,IAAA;EAAA,MAAAL,IAAA,GAAAM,uBAAA,CAAAL,OAAA;EAAAI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|
|
81
81
|
};
|
|
82
82
|
return data;
|
|
83
83
|
}
|
|
84
|
-
function
|
|
85
|
-
const data = require("@teambit/
|
|
86
|
-
|
|
84
|
+
function _toolboxPath() {
|
|
85
|
+
const data = require("@teambit/toolbox.path.path");
|
|
86
|
+
_toolboxPath = function () {
|
|
87
|
+
return data;
|
|
88
|
+
};
|
|
89
|
+
return data;
|
|
90
|
+
}
|
|
91
|
+
function _pkgModules() {
|
|
92
|
+
const data = require("@teambit/pkg.modules.component-package-name");
|
|
93
|
+
_pkgModules = function () {
|
|
87
94
|
return data;
|
|
88
95
|
};
|
|
89
96
|
return data;
|
|
@@ -137,13 +144,6 @@ function _configMerger() {
|
|
|
137
144
|
};
|
|
138
145
|
return data;
|
|
139
146
|
}
|
|
140
|
-
function _componentIdToPackageName() {
|
|
141
|
-
const data = _interopRequireDefault(require("@teambit/legacy/dist/utils/bit/component-id-to-package-name"));
|
|
142
|
-
_componentIdToPackageName = function () {
|
|
143
|
-
return data;
|
|
144
|
-
};
|
|
145
|
-
return data;
|
|
146
|
-
}
|
|
147
147
|
function _dependencyResolver() {
|
|
148
148
|
const data = require("@teambit/dependency-resolver");
|
|
149
149
|
_dependencyResolver = function () {
|
|
@@ -380,7 +380,7 @@ class MergingMain {
|
|
|
380
380
|
const newlyIntroducedIds = currentLane?.toComponentIds().filter(id => !currentLaneIdsBeforeMerge?.hasWithoutVersion(id));
|
|
381
381
|
const newlyIntroducedComponentIds = _componentId().ComponentIdList.fromArray(newlyIntroducedIds || []);
|
|
382
382
|
const components = (0, _lodash().compact)(componentsResults.map(c => c.legacyCompToWrite).filter(c => c && newlyIntroducedComponentIds.hasWithoutVersion(c.id)));
|
|
383
|
-
const packages = components.map(c => (0,
|
|
383
|
+
const packages = components.map(c => (0, _pkgModules().componentIdToPackageName)(c));
|
|
384
384
|
const isRemoved = this.depResolver.removeFromRootPolicy(packages);
|
|
385
385
|
if (isRemoved) await this.depResolver.persistConfig('merge (remove packages)');
|
|
386
386
|
}
|
|
@@ -494,7 +494,7 @@ class MergingMain {
|
|
|
494
494
|
const markAllFilesAsUnchanged = () => {
|
|
495
495
|
if (!currentComponent) throw new Error(`applyVersion expect to get currentComponent for ${id.toString()}`);
|
|
496
496
|
currentComponent.files.forEach(file => {
|
|
497
|
-
filesStatus[(0,
|
|
497
|
+
filesStatus[(0, _toolboxPath().pathNormalizeToLinux)(file.relative)] = _mergeVersion().FileStatus.unchanged;
|
|
498
498
|
});
|
|
499
499
|
};
|
|
500
500
|
if (mergeResults && mergeResults.hasConflicts && mergeStrategy === _mergeVersion().MergeOptions.ours) {
|