sf-git-merge-driver 1.0.1 → 1.0.2-dev-83.16905851057-1

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/README.md CHANGED
@@ -38,9 +38,9 @@ GLOBAL FLAGS
38
38
  DESCRIPTION
39
39
  Installs a local git merge driver for the given org and branch.
40
40
 
41
- Installs a local git merge driver for the given org and branch, by updating the `.gitattributes` files in the project,
42
- creating a new merge driver configuration in the `.git/config` of the project, and installing the binary in the
43
- node_modules/.bin directory.
41
+ Installs a local git merge driver for the given org and branch, by updating the `.git/info/attributes` files in the
42
+ project, creating a new merge driver configuration in the `.git/config` of the project, and installing the binary in
43
+ the node_modules/.bin directory.
44
44
 
45
45
  EXAMPLES
46
46
  Install the driver for a given project:
@@ -48,7 +48,7 @@ EXAMPLES
48
48
  $ sf git merge driver install
49
49
  ```
50
50
 
51
- _See code: [src/commands/git/merge/driver/install.ts](https://github.com/scolladon/sf-git-merge-driver/blob/v1.0.1/src/commands/git/merge/driver/install.ts)_
51
+ _See code: [src/commands/git/merge/driver/install.ts](https://github.com/scolladon/sf-git-merge-driver/blob/v1.0.2-dev-83.16905851057-1/src/commands/git/merge/driver/install.ts)_
52
52
 
53
53
  ## `sf git merge driver run`
54
54
 
@@ -92,7 +92,7 @@ EXAMPLES
92
92
  - output-file is the path to the file where the merged content will be written
93
93
  ```
94
94
 
95
- _See code: [src/commands/git/merge/driver/run.ts](https://github.com/scolladon/sf-git-merge-driver/blob/v1.0.1/src/commands/git/merge/driver/run.ts)_
95
+ _See code: [src/commands/git/merge/driver/run.ts](https://github.com/scolladon/sf-git-merge-driver/blob/v1.0.2-dev-83.16905851057-1/src/commands/git/merge/driver/run.ts)_
96
96
 
97
97
  ## `sf git merge driver uninstall`
98
98
 
@@ -110,8 +110,8 @@ DESCRIPTION
110
110
  Uninstalls the local git merge driver for the given org and branch.
111
111
 
112
112
  Uninstalls the local git merge driver for the given org and branch, by removing the merge driver content in the
113
- `.gitattributes` files in the project, deleting the merge driver configuration from the `.git/config` of the project,
114
- and removing the installed binary from the node_modules/.bin directory.
113
+ `.git/info/attributes` files in the project, deleting the merge driver configuration from the `.git/config` of the
114
+ project, and removing the installed binary from the node_modules/.bin directory.
115
115
 
116
116
  EXAMPLES
117
117
  Uninstall the driver for a given project:
@@ -119,7 +119,7 @@ EXAMPLES
119
119
  $ sf git merge driver uninstall
120
120
  ```
121
121
 
122
- _See code: [src/commands/git/merge/driver/uninstall.ts](https://github.com/scolladon/sf-git-merge-driver/blob/v1.0.1/src/commands/git/merge/driver/uninstall.ts)_
122
+ _See code: [src/commands/git/merge/driver/uninstall.ts](https://github.com/scolladon/sf-git-merge-driver/blob/v1.0.2-dev-83.16905851057-1/src/commands/git/merge/driver/uninstall.ts)_
123
123
  <!-- commandsstop -->
124
124
 
125
125
  ## How It Works
@@ -132,11 +132,9 @@ The merge driver works by:
132
132
 
133
133
  ## Configuration
134
134
 
135
- The driver is configured to work with `.xml` files by default. The installation adds the following to your `.gitattributes` file:
135
+ The driver is configured to work with `.xml` files by default. The installation adds the following to the `.git/info/attributes` file (so it is discrete for the current repo):
136
136
 
137
137
  ```
138
-
139
-
140
138
  *.labels-meta.xml merge=salesforce-source
141
139
  *.label-meta.xml merge=salesforce-source
142
140
  *.profile-meta.xml merge=salesforce-source
@@ -5,6 +5,8 @@ import { MergeDriver } from '../../../../driver/MergeDriver.js';
5
5
  import { ConflictMarker } from '../../../../merger/conflictMarker.js';
6
6
  Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
7
7
  const messages = Messages.loadMessages('sf-git-merge-driver', 'run');
8
+ const ERROR_EXIT_CODE = 1;
9
+ const SUCCESS_EXIT_CODE = 0;
8
10
  export default class Run extends SfCommand {
9
11
  static summary = messages.getMessage('summary');
10
12
  static description = messages.getMessage('description');
@@ -66,13 +68,8 @@ export default class Run extends SfCommand {
66
68
  };
67
69
  ConflictMarker.setConflictConfig(conflicConfig);
68
70
  const mergeDriver = new MergeDriver();
69
- const hasConflict = await mergeDriver.mergeFiles(flags['ancestor-file'], flags['local-file'], flags['other-file'], flags['output-file']);
70
- if (hasConflict) {
71
- this.error(messages.getMessage('result.withconflict') + ' ' + flags['output-file'], { exit: 1 });
72
- }
73
- else {
74
- this.info(messages.getMessage('result.successful') + ' ' + flags['output-file']);
75
- }
71
+ const hasConflict = await mergeDriver.mergeFiles(flags['ancestor-file'], flags['local-file'], flags['other-file']);
72
+ process.exitCode = hasConflict ? ERROR_EXIT_CODE : SUCCESS_EXIT_CODE;
76
73
  }
77
74
  }
78
75
  //# sourceMappingURL=run.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../../../../../src/commands/git/merge/driver/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC5B,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,0CAA0C,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAA;AAGrE,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC5D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAA;AAEpE,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,SAAe;IACvC,MAAM,CAAmB,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;IACjE,MAAM,CAAmB,WAAW,GACzC,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAA;IAC7B,MAAM,CAAmB,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAA;IAEpE,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AAsB,CAAC;YACjD,mBAAmB,EAAE,KAAK,CAAC,uBAAuB,CAAC;YACnD,gBAAgB,EAAE,KAAK,CAAC,oBAAoB,CAAC;YAC7C,gBAAgB,EAAE,KAAK,CAAC,oBAAoB,CAAC;SAC9C,CAAA;QACD,cAAc,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAA;QAE/C,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAA;QACrC,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,UAAU,CAC9C,KAAK,CAAC,eAAe,CAAC,EACtB,KAAK,CAAC,YAAY,CAAC,EACnB,KAAK,CAAC,YAAY,CAAC,CACpB,CAAA;QACD,OAAO,CAAC,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,iBAAiB,CAAA;IACtE,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const GIT_INFO_ATTRIBUTES_PATH = "info/attributes";
@@ -0,0 +1,2 @@
1
+ export const GIT_INFO_ATTRIBUTES_PATH = 'info/attributes';
2
+ //# sourceMappingURL=gitConstant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitConstant.js","sourceRoot":"","sources":["../../src/constant/gitConstant.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CAAA"}
@@ -1,3 +1,3 @@
1
1
  export declare class MergeDriver {
2
- mergeFiles(ancestorFile: string, ourFile: string, theirFile: string, outputFile: string): Promise<boolean>;
2
+ mergeFiles(ancestorFile: string, ourFile: string, theirFile: string): Promise<boolean>;
3
3
  }
@@ -1,17 +1,19 @@
1
1
  import { readFile, writeFile } from 'node:fs/promises';
2
+ import { normalize } from 'node:path';
2
3
  import { XmlMerger } from '../merger/XmlMerger.js';
4
+ import { detectEol, normalizeEol } from '../utils/mergeUtils.js';
3
5
  export class MergeDriver {
4
- async mergeFiles(ancestorFile, ourFile, theirFile, outputFile) {
6
+ async mergeFiles(ancestorFile, ourFile, theirFile) {
5
7
  // Read all three versions
6
- const [ancestorContent, ourContent, theirContent] = await Promise.all([
7
- readFile(ancestorFile, 'utf8'),
8
- readFile(ourFile, 'utf8'),
9
- readFile(theirFile, 'utf8'),
10
- ]);
8
+ const [ancestorContent, ourContent, theirContent] = await Promise.all([ancestorFile, ourFile, theirFile]
9
+ .map(normalize)
10
+ .map(path => readFile(path, 'utf8')));
11
11
  const xmlMerger = new XmlMerger();
12
12
  const mergedContent = xmlMerger.mergeThreeWay(ancestorContent, ourContent, theirContent);
13
- // Write the merged content to the output file
14
- await writeFile(outputFile, mergedContent.output);
13
+ const targetEol = detectEol(ourContent);
14
+ const outputWithEol = normalizeEol(mergedContent.output, targetEol);
15
+ // Write the merged content to the our file
16
+ await writeFile(normalize(ourFile), outputWithEol);
15
17
  return mergedContent.hasConflict;
16
18
  }
17
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"MergeDriver.js","sourceRoot":"","sources":["../../src/driver/MergeDriver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAElD,MAAM,OAAO,WAAW;IACtB,KAAK,CAAC,UAAU,CACd,YAAoB,EACpB,OAAe,EACf,SAAiB,EACjB,UAAkB;QAElB,0BAA0B;QAC1B,MAAM,CAAC,eAAe,EAAE,UAAU,EAAE,YAAY,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YACpE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;YAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;YACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;SAC5B,CAAC,CAAA;QAEF,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAA;QAEjC,MAAM,aAAa,GAAG,SAAS,CAAC,aAAa,CAC3C,eAAe,EACf,UAAU,EACV,YAAY,CACb,CAAA;QAED,8C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} from 'node:fs/promises';
2
2
  import { simpleGit } from 'simple-git';
3
3
  import { DRIVER_NAME, RUN_PLUGIN_COMMAND } from '../constant/driverConstant.js';
4
4
  import { METADATA_TYPES_PATTERNS } from '../constant/metadataConstant.js';
5
+ import { getGitAttributesPath } from '../utils/gitUtils.js';
5
6
  export class InstallService {
6
7
  async installMergeDriver() {
7
8
  const git = simpleGit();
8
9
  await git.addConfig(`merge.${DRIVER_NAME}.name`, 'Salesforce source merge driver');
9
- await git.addConfig(`merge.${DRIVER_NAME}.driver`, `${RUN_PLUGIN_COMMAND} -O %O -A %A -B %B -P %P -L %L -X %X -Y %Y`);
10
+ await git.addConfig(`merge.${DRIVER_NAME}.driver`, `sh -c '${RUN_PLUGIN_COMMAND} -O "$1" -A "$2" -B "$3" -P "$4" -L "$5" -X "$6" -Y "$7"' -- %O %A %B %P %L %X %Y`);
10
11
  await git.addConfig(`merge.${DRIVER_NAME}.recursive`, 'true');
11
12
  // Configure merge driver for each metadata type pattern
12
13
  const patterns = METADATA_TYPES_PATTERNS.map(pattern => `*.${pattern}-meta.xml merge=${DRIVER_NAME}`).join('\n');
13
14
  const content = `${patterns}\n`;
14
- await appendFile('.gitattributes', content, { flag: 'a' });
15
+ const gitAttributesPath = await getGitAttributesPath();
16
+ await appendFile(gitAttributesPath, content, { flag: 'a' });
15
17
  }
16
18
  }
17
19
  //# sourceMappingURL=installService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"installService.js","sourceRoot":"","sources":["../../src/service/installService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAC/E,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAA;AAEzE,MAAM,OAAO,cAAc;IAClB,KAAK,CAAC,kBAAkB;QAC7B,MAAM,G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AM,GAAG,CAAC,SAAS,CAAC,SAAS,WAAW,YAAY,EAAE,MAAM,CAAC,CAAA;QAE7D,wDAAwD;QACxD,MAAM,QAAQ,GAAG,uBAAuB,CAAC,GAAG,CAC1C,OAAO,CAAC,EAAE,CAAC,KAAK,OAAO,mBAAmB,WAAW,EAAE,CACxD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QACZ,MAAM,OAAO,GAAG,GAAG,QAAQ,IAAI,CAAA;QAE/B,MAAM,iBAAiB,GAAG,MAAM,oBAAoB,EAAE,CAAA;QAEtD,MAAM,UAAU,CAAC,iBAAiB,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,CAAA;IAC7D,CAAC;CACF"}
@@ -1,23 +1,27 @@
1
1
  import { readFile, writeFile } from 'node:fs/promises';
2
2
  import { simpleGit } from 'simple-git';
3
3
  import { DRIVER_NAME } from '../constant/driverConstant.js';
4
+ import { getGitAttributesPath } from '../utils/gitUtils.js';
4
5
  // This match lines like: "*.profile-meta.xml merge=sf-git-merge-driver"
5
6
  const MERGE_DRIVER_CONFIG = new RegExp(`.*\s+merge\s*=\s*${DRIVER_NAME}$`);
6
7
  export class UninstallService {
7
8
  async uninstallMergeDriver() {
8
9
  const git = simpleGit();
9
10
  try {
11
+ // Throw when the merge driver is not installed
10
12
  await git.raw(['config', '--remove-section', `merge.${DRIVER_NAME}`]);
13
+ const gitAttributesPath = await getGitAttributesPath();
14
+ // Throw when the file does not exist
15
+ const gitAttributes = await readFile(gitAttributesPath, {
16
+ encoding: 'utf8',
17
+ });
18
+ const filteredAttributes = gitAttributes
19
+ .split('\n')
20
+ .filter(line => !MERGE_DRIVER_CONFIG.test(line));
21
+ await writeFile(gitAttributesPath, filteredAttributes.join('\n'));
11
22
  // biome-ignore lint/suspicious/noEmptyBlockStatements: fail silently
12
23
  }
13
24
  catch { }
14
- const gitAttributes = await readFile('.gitattributes', {
15
- encoding: 'utf8',
16
- });
17
- const filteredAttributes = gitAttributes
18
- .split('\n')
19
- .filter(line => !MERGE_DRIVER_CONFIG.test(line));
20
- await writeFile('.gitattributes', filteredAttributes.join('\n'));
21
25
  }
22
26
  }
23
27
  //# sourceMappingURL=uninstallService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"uninstallService.js","sourceRoot":"","sources":["../../src/service/uninstallService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAE3D,wEAAwE;AACxE,MAAM,mBAAmB,GAAG,IAAI,MAAM,CAAC,oBAAoB,WAAW,GAAG,CAAC,CAAA;AAE1E,MAAM,OAAO,gBAAgB;IACpB,KAAK,CAAC,oBAAoB;QAC/B,MAAM,GAAG,GAAG,SAAS,EAAE,CAAA;QACvB,IAAI,CAAC;YACH,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,kBAAkB,EAAE,SAAS,WAAW,EAAE,CAAC,CAAC,CAAA;YACrE,qEAAqE;QACvE,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QAEV,MAAM,aAAa,GAAG,MAAM,QAAQ,CAAC,gBAAgB,EAAE;YACrD,QAAQ,EAAE,MAAM;SACjB,CAAC,CAAA;QACF,MAAM,kBAAkB,GAAG,aAAa;aACrC,KAAK,CAAC,IAAI,CAAC;aACX,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;QAClD,MAAM,SAAS,CAAC,gBAAgB,EAAE,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;IAClE,CAAC;CACF"}
1
+ {"version":3,"file":"uninstallService.js","sourceRoot":"","sources":["../../src/service/uninstallService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAE3D,wEAAwE;AACxE,MAAM,mBAAmB,GAAG,IAAI,MAAM,CAAC,oBAAoB,WAAW,GAAG,CAAC,CAAA;AAE1E,MAAM,OAAO,gBAAgB;IACpB,KAAK,CAAC,oBAAoB;QAC/B,MAAM,GAAG,GAAG,SAAS,EAAE,CAAA;QACvB,IAAI,CAAC;YACH,+CAA+C;YAC/C,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,kBAAkB,EAAE,SAAS,WAAW,EAAE,CAAC,CAAC,CAAA;YAErE,MAAM,iBAAiB,GAAG,MAAM,oBAAoB,EAAE,CAAA;YACtD,qCAAqC;YACrC,MAAM,aAAa,GAAG,MAAM,QAAQ,CAAC,iBAAiB,EAAE;gBACtD,QAAQ,EAAE,MAAM;aACjB,CAAC,CAAA;YACF,MAAM,kBAAkB,GAAG,aAAa;iBACrC,KAAK,CAAC,IAAI,CAAC;iBACX,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAClD,MAAM,SAAS,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YACjE,qEAAqE;QACvE,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IACZ,CAAC;CACF"}
@@ -0,0 +1 @@
1
+ export declare function getGitAttributesPath(): Promise<string>;
@@ -0,0 +1,9 @@
1
+ import { join } from 'node:path';
2
+ import { simpleGit } from 'simple-git';
3
+ import { GIT_INFO_ATTRIBUTES_PATH } from '../constant/gitConstant.js';
4
+ export async function getGitAttributesPath() {
5
+ const git = simpleGit();
6
+ const gitDir = await git.revparse(['--git-dir']);
7
+ return join(gitDir.trim(), GIT_INFO_ATTRIBUTES_PATH);
8
+ }
9
+ //# sourceMappingURL=gitUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitUtils.js","sourceRoot":"","sources":["../../src/utils/gitUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAErE,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACxC,MAAM,GAAG,GAAG,SAAS,EAAE,CAAA;IACvB,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,CAAC,CAAA;IAChD,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,wBAAwB,CAAC,CAAA;AACtD,CAAC"}
@@ -2,3 +2,5 @@ import type { JsonArray, JsonObject, JsonValue } from '../types/jsonTypes.js';
2
2
  export declare const isObject: (ancestor: JsonValue | undefined | null, local: JsonValue | undefined | null, other: JsonValue | undefined | null) => boolean;
3
3
  export declare const ensureArray: (value: JsonValue) => JsonArray;
4
4
  export declare const getUniqueSortedProps: (...objects: (JsonObject | JsonArray)[]) => string[];
5
+ export declare const detectEol: (text: string) => string;
6
+ export declare const normalizeEol: (text: string, eol?: string) => string;
@@ -1,5 +1,42 @@
1
1
  import { castArray, isNil } from 'lodash-es';
2
+ import { EOL } from 'os';
3
+ const CR = '\r';
4
+ const LF = '\n';
5
+ const CRLF = `${CR}${LF}`;
6
+ const RE_CRLF = /\r\n/g;
7
+ const RE_LF_OR_CRLF = /\r\n|\n/g;
2
8
  export const isObject = (ancestor, local, other) => typeof [ancestor, other, local].find(ele => !isNil(ele)) === 'object';
3
9
  export const ensureArray = (value) => isNil(value) ? [] : castArray(value);
4
10
  export const getUniqueSortedProps = (...objects) => Array.from(new Set([...objects].map(Object.keys).flat())).sort();
11
+ export const detectEol = (text) => {
12
+ if (!text) {
13
+ return EOL;
14
+ }
15
+ let hasCRLF = false;
16
+ let hasLF = false;
17
+ for (let i = 0; i < text.length; ++i) {
18
+ if (text[i] === LF) {
19
+ if (i > 0 && text[i - 1] === CR) {
20
+ hasCRLF = true;
21
+ }
22
+ else {
23
+ hasLF = true;
24
+ }
25
+ if (hasCRLF && hasLF) {
26
+ return EOL;
27
+ }
28
+ }
29
+ }
30
+ return hasCRLF ? CRLF : hasLF ? LF : EOL;
31
+ };
32
+ export const normalizeEol = (text, eol = EOL) => {
33
+ if (!text) {
34
+ return text;
35
+ }
36
+ let regex = RE_CRLF;
37
+ if (eol === CRLF) {
38
+ regex = RE_LF_OR_CRLF;
39
+ }
40
+ return text.replace(regex, eol);
41
+ };
5
42
  //# sourceMappingURL=mergeUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mergeUtils.js","sourceRoot":"","sources":["../../src/utils/mergeUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,WAAW,CAAA;AAG5C,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,QAAsC,EACtC,KAAmC,EACnC,KAAmC,EAC1B,EAAE,CACX,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,QAAQ,CAAA;AAEvE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAgB,EAAa,EAAE,CACzD,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAE,SAAS,CAAC,KAAK,CAAe,CAAA;AAErD,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,GAAG,OAAmC,EAC5B,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,OAA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AAE,CAAC;QACV,OAAO,GAAG,CAAA;IACZ,CAAC;IAED,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,IAAI,KAAK,GAAG,KAAK,CAAA;IAEjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QACrC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;YACnB,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;gBAChC,OAAO,GAAG,IAAI,CAAA;YAChB,CAAC;iBAAM,CAAC;gBACN,KAAK,GAAG,IAAI,CAAA;YACd,CAAC;YAED,IAAI,OAAO,IAAI,KAAK,EAAE,CAAC;gBACrB,OAAO,GAAG,CAAA;YACZ,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA;AAC1C,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,MAAc,GAAG,EAAU,EAAE;IACtE,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,KAAK,GAAG,OAAO,CAAA;IACnB,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACjB,KAAK,GAAG,aAAa,CAAA;IACvB,CAAC;IAED,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;AACjC,CAAC,CAAA"}
@@ -4,7 +4,7 @@ Installs a local git merge driver for the given org and branch.
4
4
 
5
5
  # description
6
6
 
7
- Installs a local git merge driver for the given org and branch, by updating the `.gitattributes` files in the project, creating a new merge driver configuration in the `.git/config` of the project, and installing the binary in the node_modules/.bin directory.
7
+ Installs a local git merge driver for the given org and branch, by updating the `.git/info/attributes` files in the project, creating a new merge driver configuration in the `.git/config` of the project, and installing the binary in the node_modules/.bin directory.
8
8
 
9
9
  # examples
10
10
 
package/messages/run.md CHANGED
@@ -45,11 +45,3 @@ string used to tag local version in conflicts
45
45
 
46
46
  # flags.other-conflict-tag.summary
47
47
  string used to tag other version in conflicts
48
-
49
- # result.withconflict
50
-
51
- There are conflicts for file
52
-
53
- # result.successful
54
-
55
- Successfully merged file
@@ -4,7 +4,7 @@ Uninstalls the local git merge driver for the given org and branch.
4
4
 
5
5
  # description
6
6
 
7
- Uninstalls the local git merge driver for the given org and branch, by removing the merge driver content in the `.gitattributes` files in the project, deleting the merge driver configuration from the `.git/config` of the project, and removing the installed binary from the node_modules/.bin directory.
7
+ Uninstalls the local git merge driver for the given org and branch, by removing the merge driver content in the `.git/info/attributes` files in the project, deleting the merge driver configuration from the `.git/config` of the project, and removing the installed binary from the node_modules/.bin directory.
8
8
 
9
9
  # examples
10
10