isomorphic-git 1.24.4 → 1.25.0

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
@@ -363,6 +363,9 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
363
363
  <td align="center"><a href="https://github.com/barry963"><img src="https://avatars.githubusercontent.com/u/5289896?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Barry</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=barry963" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=barry963" title="Documentation">📖</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=barry963" title="Tests">⚠️</a></td>
364
364
  <td align="center"><a href="https://stackoverflow.com/users/1493081/alireza-mirian"><img src="https://avatars.githubusercontent.com/u/3150694?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Alireza Mirian</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=alirezamirian" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=alirezamirian" title="Documentation">📖</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=alirezamirian" title="Tests">⚠️</a> <a href="https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Aalirezamirian" title="Bug reports">🐛</a></td>
365
365
  </tr>
366
+ <tr>
367
+ <td align="center"><a href="https://github.com/DanilKazanov"><img src="https://avatars.githubusercontent.com/u/139755256?v=4?s=60" width="60px;" alt=""/><br /><sub><b>DanilKazanov</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=DanilKazanov" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=DanilKazanov" title="Documentation">📖</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=DanilKazanov" title="Tests">⚠️</a></td>
368
+ </tr>
366
369
  </table>
367
370
 
368
371
  <!-- markdownlint-restore -->
@@ -1,12 +1,12 @@
1
1
  [
2
- "Chrome Headless 79.0.3945.0 (Linux x86_64)",
3
- "Firefox 115.0 (Ubuntu 0.0.0)",
4
- "X Chrome 114.0.0.0 (Android 10)",
5
- "Safari 13.1 (Mac OS 10.15.4)",
6
- "Mobile Safari 13.0 (iOS 13.0)",
2
+ "X Chrome Headless 79.0.3945.0 (Linux x86_64)",
3
+ "Firefox 119.0 (Ubuntu 0.0.0)",
4
+ "Chrome 117.0.0.0 (Android 10)",
7
5
  "Edge 79.0.309.65 (Windows 10)",
6
+ "X Safari 13.1 (Mac OS 10.15.4)",
7
+ "X Mobile Safari 13.0 (iOS 13.0)",
8
8
  "Chrome Headless 79.0.3945.0 (Linux x86_64)",
9
- "X Chrome 114.0.0.0 (Android 10)",
10
- "Chrome Headless 79.0.3945.0 (Linux x86_64)",
11
- "Chrome 114.0.0.0 (Android 10)"
9
+ "Chrome 117.0.0.0 (Android 10)",
10
+ "Safari 13.1 (Mac OS 10.15.4)",
11
+ "Mobile Safari 13.0 (iOS 13.0)"
12
12
  ]
package/index.cjs CHANGED
@@ -3312,13 +3312,16 @@ MergeNotSupportedError.code = 'MergeNotSupportedError';
3312
3312
  class MergeConflictError extends BaseError {
3313
3313
  /**
3314
3314
  * @param {Array<string>} filepaths
3315
+ * @param {Array<string>} bothModified
3316
+ * @param {Array<string>} deleteByUs
3317
+ * @param {Array<string>} deleteByTheirs
3315
3318
  */
3316
- constructor(filepaths) {
3319
+ constructor(filepaths, bothModified, deleteByUs, deleteByTheirs) {
3317
3320
  super(
3318
3321
  `Automatic merge failed with one or more merge conflicts in the following files: ${filepaths.toString()}. Fix conflicts then commit the result.`
3319
3322
  );
3320
3323
  this.code = this.name = MergeConflictError.code;
3321
- this.data = { filepaths };
3324
+ this.data = { filepaths, bothModified, deleteByUs, deleteByTheirs };
3322
3325
  }
3323
3326
  }
3324
3327
  /** @type {'MergeConflictError'} */
@@ -7313,8 +7316,8 @@ function filterCapabilities(server, client) {
7313
7316
 
7314
7317
  const pkg = {
7315
7318
  name: 'isomorphic-git',
7316
- version: '1.24.4',
7317
- agent: 'git/isomorphic-git@1.24.4',
7319
+ version: '1.25.0',
7320
+ agent: 'git/isomorphic-git@1.25.0',
7318
7321
  };
7319
7322
 
7320
7323
  class FIFO {
@@ -8637,15 +8640,20 @@ async function _expandOid({ fs, cache, gitdir, oid: short }) {
8637
8640
  // process can acquire external ref-deltas.
8638
8641
  const getExternalRefDelta = oid => _readObject({ fs, cache, gitdir, oid });
8639
8642
 
8640
- const results1 = await expandOidLoose({ fs, gitdir, oid: short });
8641
- const results2 = await expandOidPacked({
8643
+ const results = await expandOidLoose({ fs, gitdir, oid: short });
8644
+ const packedOids = await expandOidPacked({
8642
8645
  fs,
8643
8646
  cache,
8644
8647
  gitdir,
8645
8648
  oid: short,
8646
8649
  getExternalRefDelta,
8647
8650
  });
8648
- const results = results1.concat(results2);
8651
+ // Objects can exist in a pack file as well as loose, make sure we only get a list of unique oids.
8652
+ for (const packedOid of packedOids) {
8653
+ if (results.indexOf(packedOid) === -1) {
8654
+ results.push(packedOid);
8655
+ }
8656
+ }
8649
8657
 
8650
8658
  if (results.length === 1) {
8651
8659
  return results[0]
@@ -8873,6 +8881,9 @@ async function mergeTree({
8873
8881
  const theirTree = TREE({ ref: theirOid });
8874
8882
 
8875
8883
  const unmergedFiles = [];
8884
+ const bothModified = [];
8885
+ const deleteByUs = [];
8886
+ const deleteByTheirs = [];
8876
8887
 
8877
8888
  const results = await _walk({
8878
8889
  fs,
@@ -8938,6 +8949,7 @@ async function mergeTree({
8938
8949
  }).then(async r => {
8939
8950
  if (!r.cleanMerge) {
8940
8951
  unmergedFiles.push(filepath);
8952
+ bothModified.push(filepath);
8941
8953
  if (!abortOnConflict) {
8942
8954
  const baseOid = await base.oid();
8943
8955
  const ourOid = await ours.oid();
@@ -8955,8 +8967,70 @@ async function mergeTree({
8955
8967
  return r.mergeResult
8956
8968
  })
8957
8969
  }
8970
+
8971
+ // deleted by us
8972
+ if (
8973
+ base &&
8974
+ !ours &&
8975
+ theirs &&
8976
+ (await base.type()) === 'blob' &&
8977
+ (await theirs.type()) === 'blob'
8978
+ ) {
8979
+ unmergedFiles.push(filepath);
8980
+ deleteByUs.push(filepath);
8981
+ if (!abortOnConflict) {
8982
+ const baseOid = await base.oid();
8983
+ const theirOid = await theirs.oid();
8984
+
8985
+ index.delete({ filepath });
8986
+
8987
+ index.insert({ filepath, oid: baseOid, stage: 1 });
8988
+ index.insert({ filepath, oid: theirOid, stage: 3 });
8989
+ }
8990
+
8991
+ return {
8992
+ mode: await theirs.mode(),
8993
+ oid: await theirs.oid(),
8994
+ type: 'blob',
8995
+ path,
8996
+ }
8997
+ }
8998
+
8999
+ // deleted by theirs
9000
+ if (
9001
+ base &&
9002
+ ours &&
9003
+ !theirs &&
9004
+ (await base.type()) === 'blob' &&
9005
+ (await ours.type()) === 'blob'
9006
+ ) {
9007
+ unmergedFiles.push(filepath);
9008
+ deleteByTheirs.push(filepath);
9009
+ if (!abortOnConflict) {
9010
+ const baseOid = await base.oid();
9011
+ const ourOid = await ours.oid();
9012
+
9013
+ index.delete({ filepath });
9014
+
9015
+ index.insert({ filepath, oid: baseOid, stage: 1 });
9016
+ index.insert({ filepath, oid: ourOid, stage: 2 });
9017
+ }
9018
+
9019
+ return {
9020
+ mode: await ours.mode(),
9021
+ oid: await ours.oid(),
9022
+ type: 'blob',
9023
+ path,
9024
+ }
9025
+ }
9026
+
9027
+ // deleted by both
9028
+ if (base && !ours && !theirs && (await base.type()) === 'blob') {
9029
+ return undefined
9030
+ }
9031
+
8958
9032
  // all other types of conflicts fail
8959
- // TODO: Merge conflicts involving deletions/additions
9033
+ // TODO: Merge conflicts involving additions
8960
9034
  throw new MergeNotSupportedError()
8961
9035
  }
8962
9036
  }
@@ -9012,7 +9086,12 @@ async function mergeTree({
9012
9086
  },
9013
9087
  });
9014
9088
  }
9015
- return new MergeConflictError(unmergedFiles)
9089
+ return new MergeConflictError(
9090
+ unmergedFiles,
9091
+ bothModified,
9092
+ deleteByUs,
9093
+ deleteByTheirs
9094
+ )
9016
9095
  }
9017
9096
 
9018
9097
  return results.oid
package/index.d.ts CHANGED
@@ -3981,12 +3981,18 @@ declare namespace MergeNotSupportedError {
3981
3981
  declare class MergeConflictError extends BaseError {
3982
3982
  /**
3983
3983
  * @param {Array<string>} filepaths
3984
+ * @param {Array<string>} bothModified
3985
+ * @param {Array<string>} deleteByUs
3986
+ * @param {Array<string>} deleteByTheirs
3984
3987
  */
3985
- constructor(filepaths: string[]);
3988
+ constructor(filepaths: string[], bothModified: string[], deleteByUs: string[], deleteByTheirs: string[]);
3986
3989
  code: "MergeConflictError";
3987
3990
  name: "MergeConflictError";
3988
3991
  data: {
3989
3992
  filepaths: string[];
3993
+ bothModified: string[];
3994
+ deleteByUs: string[];
3995
+ deleteByTheirs: string[];
3990
3996
  };
3991
3997
  }
3992
3998
  declare namespace MergeConflictError {
package/index.js CHANGED
@@ -3306,13 +3306,16 @@ MergeNotSupportedError.code = 'MergeNotSupportedError';
3306
3306
  class MergeConflictError extends BaseError {
3307
3307
  /**
3308
3308
  * @param {Array<string>} filepaths
3309
+ * @param {Array<string>} bothModified
3310
+ * @param {Array<string>} deleteByUs
3311
+ * @param {Array<string>} deleteByTheirs
3309
3312
  */
3310
- constructor(filepaths) {
3313
+ constructor(filepaths, bothModified, deleteByUs, deleteByTheirs) {
3311
3314
  super(
3312
3315
  `Automatic merge failed with one or more merge conflicts in the following files: ${filepaths.toString()}. Fix conflicts then commit the result.`
3313
3316
  );
3314
3317
  this.code = this.name = MergeConflictError.code;
3315
- this.data = { filepaths };
3318
+ this.data = { filepaths, bothModified, deleteByUs, deleteByTheirs };
3316
3319
  }
3317
3320
  }
3318
3321
  /** @type {'MergeConflictError'} */
@@ -7307,8 +7310,8 @@ function filterCapabilities(server, client) {
7307
7310
 
7308
7311
  const pkg = {
7309
7312
  name: 'isomorphic-git',
7310
- version: '1.24.4',
7311
- agent: 'git/isomorphic-git@1.24.4',
7313
+ version: '1.25.0',
7314
+ agent: 'git/isomorphic-git@1.25.0',
7312
7315
  };
7313
7316
 
7314
7317
  class FIFO {
@@ -8631,15 +8634,20 @@ async function _expandOid({ fs, cache, gitdir, oid: short }) {
8631
8634
  // process can acquire external ref-deltas.
8632
8635
  const getExternalRefDelta = oid => _readObject({ fs, cache, gitdir, oid });
8633
8636
 
8634
- const results1 = await expandOidLoose({ fs, gitdir, oid: short });
8635
- const results2 = await expandOidPacked({
8637
+ const results = await expandOidLoose({ fs, gitdir, oid: short });
8638
+ const packedOids = await expandOidPacked({
8636
8639
  fs,
8637
8640
  cache,
8638
8641
  gitdir,
8639
8642
  oid: short,
8640
8643
  getExternalRefDelta,
8641
8644
  });
8642
- const results = results1.concat(results2);
8645
+ // Objects can exist in a pack file as well as loose, make sure we only get a list of unique oids.
8646
+ for (const packedOid of packedOids) {
8647
+ if (results.indexOf(packedOid) === -1) {
8648
+ results.push(packedOid);
8649
+ }
8650
+ }
8643
8651
 
8644
8652
  if (results.length === 1) {
8645
8653
  return results[0]
@@ -8867,6 +8875,9 @@ async function mergeTree({
8867
8875
  const theirTree = TREE({ ref: theirOid });
8868
8876
 
8869
8877
  const unmergedFiles = [];
8878
+ const bothModified = [];
8879
+ const deleteByUs = [];
8880
+ const deleteByTheirs = [];
8870
8881
 
8871
8882
  const results = await _walk({
8872
8883
  fs,
@@ -8932,6 +8943,7 @@ async function mergeTree({
8932
8943
  }).then(async r => {
8933
8944
  if (!r.cleanMerge) {
8934
8945
  unmergedFiles.push(filepath);
8946
+ bothModified.push(filepath);
8935
8947
  if (!abortOnConflict) {
8936
8948
  const baseOid = await base.oid();
8937
8949
  const ourOid = await ours.oid();
@@ -8949,8 +8961,70 @@ async function mergeTree({
8949
8961
  return r.mergeResult
8950
8962
  })
8951
8963
  }
8964
+
8965
+ // deleted by us
8966
+ if (
8967
+ base &&
8968
+ !ours &&
8969
+ theirs &&
8970
+ (await base.type()) === 'blob' &&
8971
+ (await theirs.type()) === 'blob'
8972
+ ) {
8973
+ unmergedFiles.push(filepath);
8974
+ deleteByUs.push(filepath);
8975
+ if (!abortOnConflict) {
8976
+ const baseOid = await base.oid();
8977
+ const theirOid = await theirs.oid();
8978
+
8979
+ index.delete({ filepath });
8980
+
8981
+ index.insert({ filepath, oid: baseOid, stage: 1 });
8982
+ index.insert({ filepath, oid: theirOid, stage: 3 });
8983
+ }
8984
+
8985
+ return {
8986
+ mode: await theirs.mode(),
8987
+ oid: await theirs.oid(),
8988
+ type: 'blob',
8989
+ path,
8990
+ }
8991
+ }
8992
+
8993
+ // deleted by theirs
8994
+ if (
8995
+ base &&
8996
+ ours &&
8997
+ !theirs &&
8998
+ (await base.type()) === 'blob' &&
8999
+ (await ours.type()) === 'blob'
9000
+ ) {
9001
+ unmergedFiles.push(filepath);
9002
+ deleteByTheirs.push(filepath);
9003
+ if (!abortOnConflict) {
9004
+ const baseOid = await base.oid();
9005
+ const ourOid = await ours.oid();
9006
+
9007
+ index.delete({ filepath });
9008
+
9009
+ index.insert({ filepath, oid: baseOid, stage: 1 });
9010
+ index.insert({ filepath, oid: ourOid, stage: 2 });
9011
+ }
9012
+
9013
+ return {
9014
+ mode: await ours.mode(),
9015
+ oid: await ours.oid(),
9016
+ type: 'blob',
9017
+ path,
9018
+ }
9019
+ }
9020
+
9021
+ // deleted by both
9022
+ if (base && !ours && !theirs && (await base.type()) === 'blob') {
9023
+ return undefined
9024
+ }
9025
+
8952
9026
  // all other types of conflicts fail
8953
- // TODO: Merge conflicts involving deletions/additions
9027
+ // TODO: Merge conflicts involving additions
8954
9028
  throw new MergeNotSupportedError()
8955
9029
  }
8956
9030
  }
@@ -9006,7 +9080,12 @@ async function mergeTree({
9006
9080
  },
9007
9081
  });
9008
9082
  }
9009
- return new MergeConflictError(unmergedFiles)
9083
+ return new MergeConflictError(
9084
+ unmergedFiles,
9085
+ bothModified,
9086
+ deleteByUs,
9087
+ deleteByTheirs
9088
+ )
9010
9089
  }
9011
9090
 
9012
9091
  return results.oid
@@ -3981,12 +3981,18 @@ declare namespace MergeNotSupportedError {
3981
3981
  declare class MergeConflictError extends BaseError {
3982
3982
  /**
3983
3983
  * @param {Array<string>} filepaths
3984
+ * @param {Array<string>} bothModified
3985
+ * @param {Array<string>} deleteByUs
3986
+ * @param {Array<string>} deleteByTheirs
3984
3987
  */
3985
- constructor(filepaths: string[]);
3988
+ constructor(filepaths: string[], bothModified: string[], deleteByUs: string[], deleteByTheirs: string[]);
3986
3989
  code: "MergeConflictError";
3987
3990
  name: "MergeConflictError";
3988
3991
  data: {
3989
3992
  filepaths: string[];
3993
+ bothModified: string[];
3994
+ deleteByUs: string[];
3995
+ deleteByTheirs: string[];
3990
3996
  };
3991
3997
  }
3992
3998
  declare namespace MergeConflictError {