isomorphic-git 1.43.0 → 1.43.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
@@ -457,6 +457,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
457
457
  <td align="center"><a href="https://github.com/arisgk"><img src="https://avatars.githubusercontent.com/u/4354335?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Aris Goudouras</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=arisgk" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=arisgk" title="Documentation">📖</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=arisgk" title="Tests">⚠️</a> <a href="https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Aarisgk" title="Bug reports">🐛</a></td>
458
458
  <td align="center"><a href="https://github.com/TonyWu2333"><img src="https://avatars.githubusercontent.com/u/75903587?v=4?s=60" width="60px;" alt=""/><br /><sub><b>TonyWu</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=TonyWu2333" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=TonyWu2333" title="Tests">⚠️</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=TonyWu2333" title="Documentation">📖</a></td>
459
459
  <td align="center"><a href="https://github.com/MadalinTurluianu"><img src="https://avatars.githubusercontent.com/u/81984912?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Madalin Turluianu</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=MadalinTurluianu" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=MadalinTurluianu" title="Tests">⚠️</a></td>
460
+ <td align="center"><a href="https://nandan.fyi"><img src="https://avatars.githubusercontent.com/u/74198723?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Nandan Varma</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=nandan-varma" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=nandan-varma" title="Tests">⚠️</a></td>
460
461
  </tr>
461
462
  </table>
462
463
 
package/index.cjs CHANGED
@@ -6128,6 +6128,67 @@ async function addToIndex({
6128
6128
  return fulfilledPromises
6129
6129
  }
6130
6130
 
6131
+ async function hasObjectLoose({ fs, gitdir, oid }) {
6132
+ const source = `objects/${oid.slice(0, 2)}/${oid.slice(2)}`;
6133
+ return fs.exists(`${gitdir}/${source}`)
6134
+ }
6135
+
6136
+ async function hasObjectPacked({
6137
+ fs,
6138
+ cache,
6139
+ gitdir,
6140
+ oid,
6141
+ getExternalRefDelta,
6142
+ }) {
6143
+ // Check to see if it's in a packfile.
6144
+ // Iterate through all the .idx files
6145
+ let list = await fs.readdir(join(gitdir, 'objects/pack'));
6146
+ list = list.filter(x => x.endsWith('.idx'));
6147
+ for (const filename of list) {
6148
+ const indexFile = `${gitdir}/objects/pack/${filename}`;
6149
+ const p = await readPackIndex({
6150
+ fs,
6151
+ cache,
6152
+ filename: indexFile,
6153
+ getExternalRefDelta,
6154
+ });
6155
+ if (p.error) throw new InternalError(p.error)
6156
+ // If the packfile DOES have the oid we're looking for...
6157
+ if (p.offsets.has(oid)) {
6158
+ return true
6159
+ }
6160
+ }
6161
+ // Failed to find it
6162
+ return false
6163
+ }
6164
+
6165
+ async function hasObject({
6166
+ fs,
6167
+ cache,
6168
+ gitdir,
6169
+ oid,
6170
+ format = 'content',
6171
+ }) {
6172
+ // Curry the current read method so that the packfile un-deltification
6173
+ // process can acquire external ref-deltas.
6174
+ const getExternalRefDelta = oid => _readObject({ fs, cache, gitdir, oid });
6175
+
6176
+ // Look for it in the loose object directory.
6177
+ let result = await hasObjectLoose({ fs, gitdir, oid });
6178
+ // Check to see if it's in a packfile.
6179
+ if (!result) {
6180
+ result = await hasObjectPacked({
6181
+ fs,
6182
+ cache,
6183
+ gitdir,
6184
+ oid,
6185
+ getExternalRefDelta,
6186
+ });
6187
+ }
6188
+ // Finally
6189
+ return result
6190
+ }
6191
+
6131
6192
  // @ts-check
6132
6193
 
6133
6194
  /**
@@ -6429,8 +6490,24 @@ async function _commit({
6429
6490
  } else {
6430
6491
  // ensure that the parents are oids, not refs
6431
6492
  parent = await Promise.all(
6432
- parent.map(p => {
6433
- return GitRefManager.resolve({ fs, gitdir, ref: p })
6493
+ parent.map(async p => {
6494
+ let oid = await GitRefManager.resolve({ fs, gitdir, ref: p });
6495
+ // If `p` is an annotated tag, use the commit it points to.
6496
+ // Parents are not required to exist locally.
6497
+ while (await hasObject({ fs, cache, gitdir, oid })) {
6498
+ const { type, object } = await _readObject({
6499
+ fs,
6500
+ cache,
6501
+ gitdir,
6502
+ oid,
6503
+ });
6504
+ if (type === 'commit') break
6505
+ if (type !== 'tag') {
6506
+ throw new ObjectTypeError(oid, type, 'commit')
6507
+ }
6508
+ oid = GitAnnotatedTag.from(object).parse().object;
6509
+ }
6510
+ return oid
6434
6511
  })
6435
6512
  );
6436
6513
  }
@@ -7166,8 +7243,10 @@ async function _branch({
7166
7243
  // Probably an empty repo
7167
7244
  }
7168
7245
 
7169
- // Create a new ref that points at the current commit
7246
+ // Create a new ref that points at the current commit,
7247
+ // peeling annotated tags to the commit they point to
7170
7248
  if (oid) {
7249
+ oid = (await resolveCommit({ fs, cache: {}, gitdir, oid })).oid;
7171
7250
  await GitRefManager.writeRef({ fs, gitdir, ref: fullref, value: oid });
7172
7251
  }
7173
7252
 
@@ -7360,6 +7439,18 @@ async function _checkout({
7360
7439
  });
7361
7440
  }
7362
7441
 
7442
+ // If `ref` is an annotated tag, use the commit it points to
7443
+ if (!noUpdateHead) {
7444
+ try {
7445
+ oid = (await resolveCommit({ fs, cache, gitdir, oid })).oid;
7446
+ } catch (err) {
7447
+ if (err instanceof NotFoundError) {
7448
+ throw new CommitNotFetchedError(ref, err.data.what)
7449
+ }
7450
+ throw err
7451
+ }
7452
+ }
7453
+
7363
7454
  // Update working dir
7364
7455
  if (!noCheckout) {
7365
7456
  let ops;
@@ -7378,6 +7469,7 @@ async function _checkout({
7378
7469
  });
7379
7470
  } catch (err) {
7380
7471
  // Throw a more helpful error message for this common mistake.
7472
+ // Only reachable with `noUpdateHead`, otherwise the commit was already read above.
7381
7473
  if (err instanceof NotFoundError && err.data.what === oid) {
7382
7474
  throw new CommitNotFetchedError(ref, oid)
7383
7475
  } else {
@@ -9933,67 +10025,6 @@ class GitShallowManager {
9933
10025
  }
9934
10026
  }
9935
10027
 
9936
- async function hasObjectLoose({ fs, gitdir, oid }) {
9937
- const source = `objects/${oid.slice(0, 2)}/${oid.slice(2)}`;
9938
- return fs.exists(`${gitdir}/${source}`)
9939
- }
9940
-
9941
- async function hasObjectPacked({
9942
- fs,
9943
- cache,
9944
- gitdir,
9945
- oid,
9946
- getExternalRefDelta,
9947
- }) {
9948
- // Check to see if it's in a packfile.
9949
- // Iterate through all the .idx files
9950
- let list = await fs.readdir(join(gitdir, 'objects/pack'));
9951
- list = list.filter(x => x.endsWith('.idx'));
9952
- for (const filename of list) {
9953
- const indexFile = `${gitdir}/objects/pack/${filename}`;
9954
- const p = await readPackIndex({
9955
- fs,
9956
- cache,
9957
- filename: indexFile,
9958
- getExternalRefDelta,
9959
- });
9960
- if (p.error) throw new InternalError(p.error)
9961
- // If the packfile DOES have the oid we're looking for...
9962
- if (p.offsets.has(oid)) {
9963
- return true
9964
- }
9965
- }
9966
- // Failed to find it
9967
- return false
9968
- }
9969
-
9970
- async function hasObject({
9971
- fs,
9972
- cache,
9973
- gitdir,
9974
- oid,
9975
- format = 'content',
9976
- }) {
9977
- // Curry the current read method so that the packfile un-deltification
9978
- // process can acquire external ref-deltas.
9979
- const getExternalRefDelta = oid => _readObject({ fs, cache, gitdir, oid });
9980
-
9981
- // Look for it in the loose object directory.
9982
- let result = await hasObjectLoose({ fs, gitdir, oid });
9983
- // Check to see if it's in a packfile.
9984
- if (!result) {
9985
- result = await hasObjectPacked({
9986
- fs,
9987
- cache,
9988
- gitdir,
9989
- oid,
9990
- getExternalRefDelta,
9991
- });
9992
- }
9993
- // Finally
9994
- return result
9995
- }
9996
-
9997
10028
  function addCredentialUsername({ config, onAuth }) {
9998
10029
  if (!onAuth) return onAuth
9999
10030
 
@@ -10023,8 +10054,8 @@ function filterCapabilities(server, client) {
10023
10054
 
10024
10055
  const pkg = {
10025
10056
  name: 'isomorphic-git',
10026
- version: '1.43.0',
10027
- agent: 'git/isomorphic-git@1.43.0',
10057
+ version: '1.43.1',
10058
+ agent: 'git/isomorphic-git@1.43.1',
10028
10059
  };
10029
10060
 
10030
10061
  class FIFO {
@@ -11669,10 +11700,12 @@ async function _merge({
11669
11700
  gitdir,
11670
11701
  ref: ours,
11671
11702
  });
11672
- const theirOid = await GitRefManager.resolve({
11703
+ // If `theirs` is an annotated tag, use the commit it points to
11704
+ const { oid: theirOid } = await resolveCommit({
11673
11705
  fs,
11706
+ cache,
11674
11707
  gitdir,
11675
- ref: theirs,
11708
+ oid: await GitRefManager.resolve({ fs, gitdir, ref: theirs }),
11676
11709
  });
11677
11710
  // find most recent common ancestor of ref a and ref b
11678
11711
  const baseOids = await _findMergeBase({
package/index.js CHANGED
@@ -6115,6 +6115,67 @@ async function addToIndex({
6115
6115
  return fulfilledPromises
6116
6116
  }
6117
6117
 
6118
+ async function hasObjectLoose({ fs, gitdir, oid }) {
6119
+ const source = `objects/${oid.slice(0, 2)}/${oid.slice(2)}`;
6120
+ return fs.exists(`${gitdir}/${source}`)
6121
+ }
6122
+
6123
+ async function hasObjectPacked({
6124
+ fs,
6125
+ cache,
6126
+ gitdir,
6127
+ oid,
6128
+ getExternalRefDelta,
6129
+ }) {
6130
+ // Check to see if it's in a packfile.
6131
+ // Iterate through all the .idx files
6132
+ let list = await fs.readdir(join(gitdir, 'objects/pack'));
6133
+ list = list.filter(x => x.endsWith('.idx'));
6134
+ for (const filename of list) {
6135
+ const indexFile = `${gitdir}/objects/pack/${filename}`;
6136
+ const p = await readPackIndex({
6137
+ fs,
6138
+ cache,
6139
+ filename: indexFile,
6140
+ getExternalRefDelta,
6141
+ });
6142
+ if (p.error) throw new InternalError(p.error)
6143
+ // If the packfile DOES have the oid we're looking for...
6144
+ if (p.offsets.has(oid)) {
6145
+ return true
6146
+ }
6147
+ }
6148
+ // Failed to find it
6149
+ return false
6150
+ }
6151
+
6152
+ async function hasObject({
6153
+ fs,
6154
+ cache,
6155
+ gitdir,
6156
+ oid,
6157
+ format = 'content',
6158
+ }) {
6159
+ // Curry the current read method so that the packfile un-deltification
6160
+ // process can acquire external ref-deltas.
6161
+ const getExternalRefDelta = oid => _readObject({ fs, cache, gitdir, oid });
6162
+
6163
+ // Look for it in the loose object directory.
6164
+ let result = await hasObjectLoose({ fs, gitdir, oid });
6165
+ // Check to see if it's in a packfile.
6166
+ if (!result) {
6167
+ result = await hasObjectPacked({
6168
+ fs,
6169
+ cache,
6170
+ gitdir,
6171
+ oid,
6172
+ getExternalRefDelta,
6173
+ });
6174
+ }
6175
+ // Finally
6176
+ return result
6177
+ }
6178
+
6118
6179
  // @ts-check
6119
6180
 
6120
6181
  /**
@@ -6416,8 +6477,24 @@ async function _commit({
6416
6477
  } else {
6417
6478
  // ensure that the parents are oids, not refs
6418
6479
  parent = await Promise.all(
6419
- parent.map(p => {
6420
- return GitRefManager.resolve({ fs, gitdir, ref: p })
6480
+ parent.map(async p => {
6481
+ let oid = await GitRefManager.resolve({ fs, gitdir, ref: p });
6482
+ // If `p` is an annotated tag, use the commit it points to.
6483
+ // Parents are not required to exist locally.
6484
+ while (await hasObject({ fs, cache, gitdir, oid })) {
6485
+ const { type, object } = await _readObject({
6486
+ fs,
6487
+ cache,
6488
+ gitdir,
6489
+ oid,
6490
+ });
6491
+ if (type === 'commit') break
6492
+ if (type !== 'tag') {
6493
+ throw new ObjectTypeError(oid, type, 'commit')
6494
+ }
6495
+ oid = GitAnnotatedTag.from(object).parse().object;
6496
+ }
6497
+ return oid
6421
6498
  })
6422
6499
  );
6423
6500
  }
@@ -7153,8 +7230,10 @@ async function _branch({
7153
7230
  // Probably an empty repo
7154
7231
  }
7155
7232
 
7156
- // Create a new ref that points at the current commit
7233
+ // Create a new ref that points at the current commit,
7234
+ // peeling annotated tags to the commit they point to
7157
7235
  if (oid) {
7236
+ oid = (await resolveCommit({ fs, cache: {}, gitdir, oid })).oid;
7158
7237
  await GitRefManager.writeRef({ fs, gitdir, ref: fullref, value: oid });
7159
7238
  }
7160
7239
 
@@ -7347,6 +7426,18 @@ async function _checkout({
7347
7426
  });
7348
7427
  }
7349
7428
 
7429
+ // If `ref` is an annotated tag, use the commit it points to
7430
+ if (!noUpdateHead) {
7431
+ try {
7432
+ oid = (await resolveCommit({ fs, cache, gitdir, oid })).oid;
7433
+ } catch (err) {
7434
+ if (err instanceof NotFoundError) {
7435
+ throw new CommitNotFetchedError(ref, err.data.what)
7436
+ }
7437
+ throw err
7438
+ }
7439
+ }
7440
+
7350
7441
  // Update working dir
7351
7442
  if (!noCheckout) {
7352
7443
  let ops;
@@ -7365,6 +7456,7 @@ async function _checkout({
7365
7456
  });
7366
7457
  } catch (err) {
7367
7458
  // Throw a more helpful error message for this common mistake.
7459
+ // Only reachable with `noUpdateHead`, otherwise the commit was already read above.
7368
7460
  if (err instanceof NotFoundError && err.data.what === oid) {
7369
7461
  throw new CommitNotFetchedError(ref, oid)
7370
7462
  } else {
@@ -9920,67 +10012,6 @@ class GitShallowManager {
9920
10012
  }
9921
10013
  }
9922
10014
 
9923
- async function hasObjectLoose({ fs, gitdir, oid }) {
9924
- const source = `objects/${oid.slice(0, 2)}/${oid.slice(2)}`;
9925
- return fs.exists(`${gitdir}/${source}`)
9926
- }
9927
-
9928
- async function hasObjectPacked({
9929
- fs,
9930
- cache,
9931
- gitdir,
9932
- oid,
9933
- getExternalRefDelta,
9934
- }) {
9935
- // Check to see if it's in a packfile.
9936
- // Iterate through all the .idx files
9937
- let list = await fs.readdir(join(gitdir, 'objects/pack'));
9938
- list = list.filter(x => x.endsWith('.idx'));
9939
- for (const filename of list) {
9940
- const indexFile = `${gitdir}/objects/pack/${filename}`;
9941
- const p = await readPackIndex({
9942
- fs,
9943
- cache,
9944
- filename: indexFile,
9945
- getExternalRefDelta,
9946
- });
9947
- if (p.error) throw new InternalError(p.error)
9948
- // If the packfile DOES have the oid we're looking for...
9949
- if (p.offsets.has(oid)) {
9950
- return true
9951
- }
9952
- }
9953
- // Failed to find it
9954
- return false
9955
- }
9956
-
9957
- async function hasObject({
9958
- fs,
9959
- cache,
9960
- gitdir,
9961
- oid,
9962
- format = 'content',
9963
- }) {
9964
- // Curry the current read method so that the packfile un-deltification
9965
- // process can acquire external ref-deltas.
9966
- const getExternalRefDelta = oid => _readObject({ fs, cache, gitdir, oid });
9967
-
9968
- // Look for it in the loose object directory.
9969
- let result = await hasObjectLoose({ fs, gitdir, oid });
9970
- // Check to see if it's in a packfile.
9971
- if (!result) {
9972
- result = await hasObjectPacked({
9973
- fs,
9974
- cache,
9975
- gitdir,
9976
- oid,
9977
- getExternalRefDelta,
9978
- });
9979
- }
9980
- // Finally
9981
- return result
9982
- }
9983
-
9984
10015
  function addCredentialUsername({ config, onAuth }) {
9985
10016
  if (!onAuth) return onAuth
9986
10017
 
@@ -10010,8 +10041,8 @@ function filterCapabilities(server, client) {
10010
10041
 
10011
10042
  const pkg = {
10012
10043
  name: 'isomorphic-git',
10013
- version: '1.43.0',
10014
- agent: 'git/isomorphic-git@1.43.0',
10044
+ version: '1.43.1',
10045
+ agent: 'git/isomorphic-git@1.43.1',
10015
10046
  };
10016
10047
 
10017
10048
  class FIFO {
@@ -11656,10 +11687,12 @@ async function _merge({
11656
11687
  gitdir,
11657
11688
  ref: ours,
11658
11689
  });
11659
- const theirOid = await GitRefManager.resolve({
11690
+ // If `theirs` is an annotated tag, use the commit it points to
11691
+ const { oid: theirOid } = await resolveCommit({
11660
11692
  fs,
11693
+ cache,
11661
11694
  gitdir,
11662
- ref: theirs,
11695
+ oid: await GitRefManager.resolve({ fs, gitdir, ref: theirs }),
11663
11696
  });
11664
11697
  // find most recent common ancestor of ref a and ref b
11665
11698
  const baseOids = await _findMergeBase({