@teambit/merging 1.0.677 → 1.0.679

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.
@@ -1,25 +0,0 @@
1
- export declare const mergeOptionsCli: {
2
- o: string;
3
- t: string;
4
- m: string;
5
- };
6
- export declare const MergeOptions: {
7
- ours: string;
8
- theirs: string;
9
- manual: string;
10
- };
11
- export type MergeStrategy = keyof typeof MergeOptions;
12
- export declare const FileStatus: {
13
- merged: string;
14
- manual: string;
15
- binaryConflict: string;
16
- updated: string;
17
- added: string;
18
- removed: string;
19
- overridden: string;
20
- unchanged: string;
21
- remainDeleted: string;
22
- deletedConflict: string;
23
- };
24
- export declare function getMergeStrategyInteractive(): Promise<MergeStrategy>;
25
- export declare function getMergeStrategy(ours: boolean, theirs: boolean, manual: boolean): MergeStrategy | null | undefined;
@@ -1,76 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.MergeOptions = exports.FileStatus = void 0;
7
- exports.getMergeStrategy = getMergeStrategy;
8
- exports.getMergeStrategyInteractive = getMergeStrategyInteractive;
9
- exports.mergeOptionsCli = void 0;
10
- function _chalk() {
11
- const data = _interopRequireDefault(require("chalk"));
12
- _chalk = function () {
13
- return data;
14
- };
15
- return data;
16
- }
17
- function _bitError() {
18
- const data = require("@teambit/bit-error");
19
- _bitError = function () {
20
- return data;
21
- };
22
- return data;
23
- }
24
- function _legacyCli() {
25
- const data = require("@teambit/legacy.cli.prompts");
26
- _legacyCli = function () {
27
- return data;
28
- };
29
- return data;
30
- }
31
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
32
- const mergeOptionsCli = exports.mergeOptionsCli = {
33
- o: 'ours',
34
- t: 'theirs',
35
- m: 'manual'
36
- };
37
- const MergeOptions = exports.MergeOptions = {
38
- ours: 'ours',
39
- theirs: 'theirs',
40
- manual: 'manual'
41
- };
42
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
43
-
44
- const FileStatus = exports.FileStatus = {
45
- merged: _chalk().default.green('auto-merged'),
46
- manual: _chalk().default.red('CONFLICT'),
47
- binaryConflict: _chalk().default.red('unchanged-BINARY-CONFLICT'),
48
- updated: _chalk().default.green('updated'),
49
- added: _chalk().default.green('added'),
50
- removed: _chalk().default.green('removed'),
51
- overridden: _chalk().default.yellow('overridden'),
52
- unchanged: _chalk().default.green('unchanged'),
53
- remainDeleted: _chalk().default.green('remain-deleted'),
54
- deletedConflict: _chalk().default.red('CONFLICT-deleted-and-modified')
55
- };
56
- async function getMergeStrategyInteractive() {
57
- try {
58
- const result = await (0, _legacyCli().resolveConflictPrompt)();
59
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
60
- return mergeOptionsCli[result.mergeStrategy];
61
- } catch {
62
- // probably user clicked ^C
63
- throw new (_bitError().BitError)('the action has been canceled');
64
- }
65
- }
66
- function getMergeStrategy(ours, theirs, manual) {
67
- if (ours && theirs || ours && manual || theirs && manual) {
68
- throw new (_bitError().BitError)('please choose only one of the following: ours, theirs or manual');
69
- }
70
- if (ours) return MergeOptions.ours;
71
- if (theirs) return MergeOptions.theirs;
72
- if (manual) return MergeOptions.manual;
73
- return null;
74
- }
75
-
76
- //# sourceMappingURL=merge-version.js.map
@@ -1 +0,0 @@
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","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 {\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;A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ACN;IACA,MAAM,KAAIC,oBAAQ,EAAC,8BAA8B,CAAC;EACpD;AACF;AAEO,SAASC,gBAAgBA,CAACtB,IAAa,EAAEC,MAAe,EAAEC,MAAe,EAAoC;EAClH,IAAKF,IAAI,IAAIC,MAAM,IAAMD,IAAI,IAAIE,MAAO,IAAKD,MAAM,IAAIC,MAAO,EAAE;IAC9D,MAAM,KAAImB,oBAAQ,EAAC,iEAAiE,CAAC;EACvF;EACA,IAAIrB,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,65 +0,0 @@
1
- import type { Version, SourceFileModel } from '@teambit/objects';
2
- import type { PathLinux } from '@teambit/toolbox.path.path';
3
- import type { ConsumerComponent as Component } from '@teambit/legacy.consumer-component';
4
- import { SourceFile } from '@teambit/component.sources';
5
- import type { Scope } from '@teambit/legacy.scope';
6
- export type MergeResultsThreeWay = {
7
- addFiles: Array<{
8
- filePath: PathLinux;
9
- fsFile: SourceFile;
10
- }>;
11
- removeFiles: Array<{
12
- filePath: PathLinux;
13
- }>;
14
- remainDeletedFiles: Array<{
15
- filePath: PathLinux;
16
- }>;
17
- deletedConflictFiles: Array<{
18
- filePath: PathLinux;
19
- fsFile?: SourceFile;
20
- }>;
21
- modifiedFiles: Array<{
22
- filePath: PathLinux;
23
- fsFile: SourceFile;
24
- baseFile?: SourceFileModel;
25
- otherFile: SourceFileModel;
26
- output: string | null | undefined;
27
- conflict: string | null | undefined;
28
- isBinaryConflict?: boolean;
29
- }>;
30
- unModifiedFiles: Array<{
31
- filePath: PathLinux;
32
- fsFile: SourceFile;
33
- }>;
34
- overrideFiles: Array<{
35
- filePath: PathLinux;
36
- fsFile: SourceFile;
37
- }>;
38
- updatedFiles: Array<{
39
- filePath: PathLinux;
40
- otherFile: SourceFileModel;
41
- content: Buffer;
42
- }>;
43
- hasConflicts: boolean;
44
- };
45
- /**
46
- * to do the actual merge we use git, specifically `merge-file` command, so we try to use the same
47
- * terminology as git. From the command help:
48
- * `git merge-file <current-file> <base-file> <other-file>
49
- * git merge-file incorporates all changes that lead from the <base-file> to <other-file> into
50
- * <current-file>. The result ordinarily goes into <current-file>.`
51
- *
52
- * see checkout-version.getBaseVersion() for a case when a component is modified and then the base-file is not the
53
- * common file before other-file and current-file.
54
- * otherwise, Git terminology pretty much reflects what we do here. current-file is the one that is currently written
55
- * to the filesystem. other-file is the one the user wants to checkout to. base-file is the original file where both:
56
- * base-file and other-file were originated from.
57
- */
58
- export declare function threeWayMerge({ scope, otherComponent, otherLabel, currentComponent, currentLabel, baseComponent, }: {
59
- scope: Scope;
60
- otherComponent: Version;
61
- otherLabel: string;
62
- currentComponent: Component;
63
- currentLabel: string;
64
- baseComponent: Version;
65
- }): Promise<MergeResultsThreeWay>;
@@ -1,254 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.threeWayMerge = threeWayMerge;
7
- function _bitError() {
8
- const data = require("@teambit/bit-error");
9
- _bitError = function () {
10
- return data;
11
- };
12
- return data;
13
- }
14
- function _toolboxCrypto() {
15
- const data = require("@teambit/toolbox.crypto.sha1");
16
- _toolboxCrypto = function () {
17
- return data;
18
- };
19
- return data;
20
- }
21
- function _toolboxPath() {
22
- const data = require("@teambit/toolbox.path.path");
23
- _toolboxPath = function () {
24
- return data;
25
- };
26
- return data;
27
- }
28
- function eol() {
29
- const data = _interopRequireWildcard(require("@teambit/toolbox.string.eol"));
30
- eol = function () {
31
- return data;
32
- };
33
- return data;
34
- }
35
- function _mergeFiles() {
36
- const data = require("../merge-files");
37
- _mergeFiles = function () {
38
- return data;
39
- };
40
- return data;
41
- }
42
- function _component() {
43
- const data = require("@teambit/component.sources");
44
- _component = function () {
45
- return data;
46
- };
47
- return data;
48
- }
49
- function _legacy() {
50
- const data = require("@teambit/legacy.scope");
51
- _legacy = function () {
52
- return data;
53
- };
54
- return data;
55
- }
56
- function _lodash() {
57
- const data = require("lodash");
58
- _lodash = function () {
59
- return data;
60
- };
61
- return data;
62
- }
63
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
64
- /**
65
- * to do the actual merge we use git, specifically `merge-file` command, so we try to use the same
66
- * terminology as git. From the command help:
67
- * `git merge-file <current-file> <base-file> <other-file>
68
- * git merge-file incorporates all changes that lead from the <base-file> to <other-file> into
69
- * <current-file>. The result ordinarily goes into <current-file>.`
70
- *
71
- * see checkout-version.getBaseVersion() for a case when a component is modified and then the base-file is not the
72
- * common file before other-file and current-file.
73
- * otherwise, Git terminology pretty much reflects what we do here. current-file is the one that is currently written
74
- * to the filesystem. other-file is the one the user wants to checkout to. base-file is the original file where both:
75
- * base-file and other-file were originated from.
76
- */
77
- async function threeWayMerge({
78
- scope,
79
- otherComponent,
80
- otherLabel,
81
- currentComponent,
82
- currentLabel,
83
- baseComponent
84
- }) {
85
- // baseFiles and currentFiles come from the model, therefore their paths include the
86
- // sharedOriginallyDir. fsFiles come from the Fs, therefore their paths don't include the
87
- // sharedOriginallyDir.
88
- // option 1) strip sharedOriginallyDir from baseFiles and currentFiles. the problem is that the
89
- // sharedDir can be different if the dependencies were changes for example, as a result, it won't
90
- // be possible to compare between the files as the paths are different.
91
- // in the previous it was implemented this way and caused a bug, which now has an e2e-test to
92
- // block it. see https://github.com/teambit/bit/pull/2070 PR.
93
- // option 2) add sharedOriginallyDir to the fsFiles. we must go with this option.
94
- // one thing we have to change is the end-of-line, it should be set as LF, same way we do before
95
- // saving the file as an object.
96
- const baseFiles = baseComponent.files;
97
- const otherFiles = otherComponent.files;
98
- const currentFiles = currentComponent.cloneFilesWithSharedDir();
99
- currentFiles.forEach(fsFile => {
100
- fsFile.contents = eol().lf(fsFile.contents);
101
- });
102
- const results = {
103
- addFiles: [],
104
- removeFiles: [],
105
- remainDeletedFiles: [],
106
- deletedConflictFiles: [],
107
- modifiedFiles: [],
108
- unModifiedFiles: [],
109
- overrideFiles: [],
110
- updatedFiles: [],
111
- hasConflicts: false
112
- };
113
- const getFileResult = async (fsFile, baseFile, otherFile) => {
114
- const filePath = (0, _toolboxPath().pathNormalizeToLinux)(fsFile.relative);
115
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
116
- const fsFileHash = (0, _toolboxCrypto().sha1)(fsFile.contents);
117
- if (!otherFile) {
118
- // if !otherFile && !baseFile, the file was created after the last tag, no need to do any
119
- // calculation, the file should be added
120
- if (!baseFile) {
121
- results.addFiles.push({
122
- filePath,
123
- fsFile
124
- });
125
- return;
126
- }
127
- const baseFileHash = baseFile.file.hash;
128
- if (fsFileHash === baseFileHash) {
129
- results.removeFiles.push({
130
- filePath
131
- });
132
- return;
133
- }
134
- results.deletedConflictFiles.push({
135
- filePath
136
- });
137
- return;
138
- }
139
- const otherFileHash = otherFile.file.hash;
140
- if (fsFileHash === otherFileHash) {
141
- // if fs === other, no need to take any action (regardless the base)
142
- results.unModifiedFiles.push({
143
- filePath,
144
- fsFile
145
- });
146
- return;
147
- }
148
- if (baseFile && fsFileHash === baseFile.file.hash) {
149
- // the file has no local modification.
150
- // the file currently in the fs, is not the same as the file we want to write (other).
151
- // but no need to check whether it has conflicts because we always want to write the other.
152
- const content = await otherFile.file.load(scope.objects);
153
- results.updatedFiles.push({
154
- filePath,
155
- otherFile,
156
- content: content.contents
157
- });
158
- return;
159
- }
160
- // it was changed in both, there is a chance for conflict. (regardless the base)
161
- fsFile.label = currentLabel;
162
- // @ts-ignore it's a hack to pass the data, version is not a valid attribute.
163
- otherFile.label = otherLabel;
164
- results.modifiedFiles.push({
165
- filePath,
166
- fsFile,
167
- baseFile,
168
- otherFile,
169
- output: null,
170
- conflict: null
171
- });
172
- };
173
- await Promise.all(currentFiles.map(async fsFile => {
174
- const relativePath = (0, _toolboxPath().pathNormalizeToLinux)(fsFile.relative);
175
- const baseFile = baseFiles.find(file => file.relativePath === relativePath);
176
- const otherFile = otherFiles.find(file => file.relativePath === relativePath);
177
- await getFileResult(fsFile, baseFile, otherFile);
178
- }));
179
- const fsFilesPaths = currentFiles.map(fsFile => (0, _toolboxPath().pathNormalizeToLinux)(fsFile.relative));
180
- const baseFilesPaths = baseFiles.map(baseFile => baseFile.relativePath);
181
- const isOtherSameAsBase = otherFile => {
182
- const baseFile = baseFiles.find(file => file.relativePath === otherFile.relativePath);
183
- if (!baseFile) throw new Error('isOtherSameAsBase expect the base to be there');
184
- return baseFile.file.hash === otherFile.file.hash;
185
- };
186
- const deletedFromFs = otherFiles.filter(otherFile => !fsFilesPaths.includes(otherFile.relativePath) && baseFilesPaths.includes(otherFile.relativePath) && isOtherSameAsBase(otherFile));
187
- const deletedAndModified = otherFiles.filter(otherFile => !fsFilesPaths.includes(otherFile.relativePath) && baseFilesPaths.includes(otherFile.relativePath) && !isOtherSameAsBase(otherFile));
188
- const addedOnOther = otherFiles.filter(otherFile => !fsFilesPaths.includes(otherFile.relativePath) && !baseFilesPaths.includes(otherFile.relativePath));
189
- deletedFromFs.forEach(file => results.remainDeletedFiles.push({
190
- filePath: file.relativePath
191
- }));
192
- deletedAndModified.forEach(file => results.deletedConflictFiles.push({
193
- filePath: file.relativePath
194
- }));
195
- await Promise.all(addedOnOther.map(async file => {
196
- const fsFile = await _component().SourceFile.loadFromSourceFileModel(file, scope.objects);
197
- results.addFiles.push({
198
- filePath: file.relativePath,
199
- fsFile
200
- });
201
- }));
202
- await Promise.all(deletedAndModified.map(async file => {
203
- const fsFile = await _component().SourceFile.loadFromSourceFileModel(file, scope.objects);
204
- results.deletedConflictFiles.push({
205
- filePath: file.relativePath,
206
- fsFile
207
- });
208
- }));
209
- if ((0, _lodash().isEmpty)(results.modifiedFiles)) return results;
210
- const conflictResults = await getMergeResults(scope, results.modifiedFiles);
211
- conflictResults.forEach(conflictResult => {
212
- const modifiedFile = results.modifiedFiles.find(file => file.filePath === conflictResult.filePath);
213
- if (!modifiedFile) throw new (_bitError().BitError)(`unable to find ${conflictResult.filePath} in modified files array`);
214
- modifiedFile.output = conflictResult.output;
215
- modifiedFile.conflict = conflictResult.conflict;
216
- modifiedFile.isBinaryConflict = conflictResult.isBinaryConflict;
217
- if (conflictResult.conflict || conflictResult.isBinaryConflict) results.hasConflicts = true;
218
- });
219
- return results;
220
- }
221
- async function getMergeResults(scope, modifiedFiles) {
222
- const tmp = new (_legacy().Tmp)(scope);
223
- const conflictResultsP = modifiedFiles.map(async modifiedFile => {
224
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
225
- const fsFilePathP = tmp.save(modifiedFile.fsFile.contents);
226
- const writeFile = async file => {
227
- const content = await file.file.load(scope.objects);
228
- // @ts-ignore
229
- return tmp.save(content.contents.toString());
230
- };
231
- const baseFilePathP = modifiedFile.baseFile ? writeFile(modifiedFile.baseFile) : tmp.save('');
232
- const otherFilePathP = writeFile(modifiedFile.otherFile);
233
- const [fsFilePath, baseFilePath, otherFilePath] = await Promise.all([fsFilePathP, baseFilePathP, otherFilePathP]);
234
- const mergeFilesParams = {
235
- filePath: modifiedFile.filePath,
236
- currentFile: {
237
- label: modifiedFile.fsFile.label,
238
- path: fsFilePath
239
- },
240
- baseFile: {
241
- path: baseFilePath
242
- },
243
- otherFile: {
244
- // @ts-ignore
245
- label: modifiedFile.otherFile.label,
246
- path: otherFilePath
247
- }
248
- };
249
- return (0, _mergeFiles().mergeFiles)(mergeFilesParams);
250
- });
251
- return Promise.all(conflictResultsP);
252
- }
253
-
254
- //# sourceMappingURL=three-way-merge.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_bitError","data","require","_toolboxCrypto","_toolboxPath","eol","_interopRequireWildcard","_mergeFiles","_component","_legacy","_lodash","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","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 type { Source, Version, SourceFileModel } from '@teambit/objects';\nimport { sha1 } from '@teambit/toolbox.crypto.sha1';\nimport type { PathLinux, PathOsBased } from '@teambit/toolbox.path.path';\nimport { pathNormalizeToLinux } from '@teambit/toolbox.path.path';\nimport * as eol from '@teambit/toolbox.string.eol';\nimport type { MergeFileParams, MergeFileResult } from '../merge-files';\nimport { mergeFiles } from '../merge-files';\nimport type { ConsumerComponent as Component } from '@teambit/legacy.consumer-component';\nimport { SourceFile } from '@teambit/component.sources';\nimport type { Scope } from '@teambit/legacy.scope';\nimport { Tmp } from '@teambit/legacy.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,CA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MAAM,CAAC6B,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,8 +0,0 @@
1
- export { threeWayMerge, MergeResultsThreeWay } from './three-way-merge';
2
- export {
3
- FileStatus,
4
- getMergeStrategyInteractive,
5
- getMergeStrategy,
6
- MergeOptions,
7
- MergeStrategy,
8
- } from './merge-version';
@@ -1,41 +0,0 @@
1
- import chalk from 'chalk';
2
- import { BitError } from '@teambit/bit-error';
3
- import { resolveConflictPrompt } from '@teambit/legacy.cli.prompts';
4
-
5
- export const mergeOptionsCli = { o: 'ours', t: 'theirs', m: 'manual' };
6
- export const MergeOptions = { ours: 'ours', theirs: 'theirs', manual: 'manual' };
7
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
8
- export type MergeStrategy = keyof typeof MergeOptions;
9
- export const FileStatus = {
10
- merged: chalk.green('auto-merged'),
11
- manual: chalk.red('CONFLICT'),
12
- binaryConflict: chalk.red('unchanged-BINARY-CONFLICT'),
13
- updated: chalk.green('updated'),
14
- added: chalk.green('added'),
15
- removed: chalk.green('removed'),
16
- overridden: chalk.yellow('overridden'),
17
- unchanged: chalk.green('unchanged'),
18
- remainDeleted: chalk.green('remain-deleted'),
19
- deletedConflict: chalk.red('CONFLICT-deleted-and-modified'),
20
- };
21
-
22
- export async function getMergeStrategyInteractive(): Promise<MergeStrategy> {
23
- try {
24
- const result = await resolveConflictPrompt();
25
- // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
26
- return mergeOptionsCli[result.mergeStrategy];
27
- } catch {
28
- // probably user clicked ^C
29
- throw new BitError('the action has been canceled');
30
- }
31
- }
32
-
33
- export function getMergeStrategy(ours: boolean, theirs: boolean, manual: boolean): MergeStrategy | null | undefined {
34
- if ((ours && theirs) || (ours && manual) || (theirs && manual)) {
35
- throw new BitError('please choose only one of the following: ours, theirs or manual');
36
- }
37
- if (ours) return MergeOptions.ours as any;
38
- if (theirs) return MergeOptions.theirs as any;
39
- if (manual) return MergeOptions.manual as any;
40
- return null;
41
- }