isomorphic-git 1.43.0 → 1.43.2

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,10 @@ 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>
461
+ </tr>
462
+ <tr>
463
+ <td align="center"><a href="https://github.com/ewraj"><img src="https://avatars.githubusercontent.com/u/212665522?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Raj Royal</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=ewraj" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=ewraj" title="Tests">⚠️</a></td>
460
464
  </tr>
461
465
  </table>
462
466
 
package/index.cjs CHANGED
@@ -1831,8 +1831,9 @@ const SECTION_REGEX = /^[A-Za-z0-9-.]+$/;
1831
1831
  // variable name is alphanumeric (ASCII) with -
1832
1832
  // variable name starts with an alphabetic character
1833
1833
  // variable name is case insensitive
1834
- const VARIABLE_LINE_REGEX = /^([A-Za-z][A-Za-z-]*)(?: *= *(.*))?$/;
1835
- const VARIABLE_NAME_REGEX = /^[A-Za-z][A-Za-z-]*$/;
1834
+ // whitespace (spaces or tabs) around the equal sign is ignored
1835
+ const VARIABLE_LINE_REGEX = /^([A-Za-z][A-Za-z0-9-]*)(?:\s*=\s*(.*))?$/;
1836
+ const VARIABLE_NAME_REGEX = /^[A-Za-z][A-Za-z0-9-]*$/;
1836
1837
 
1837
1838
  // Comments start with either # or ; and extend to the end of line
1838
1839
  const VARIABLE_VALUE_COMMENT_REGEX = /^(.*?)( *[#;].*)$/;
@@ -6128,6 +6129,67 @@ async function addToIndex({
6128
6129
  return fulfilledPromises
6129
6130
  }
6130
6131
 
6132
+ async function hasObjectLoose({ fs, gitdir, oid }) {
6133
+ const source = `objects/${oid.slice(0, 2)}/${oid.slice(2)}`;
6134
+ return fs.exists(`${gitdir}/${source}`)
6135
+ }
6136
+
6137
+ async function hasObjectPacked({
6138
+ fs,
6139
+ cache,
6140
+ gitdir,
6141
+ oid,
6142
+ getExternalRefDelta,
6143
+ }) {
6144
+ // Check to see if it's in a packfile.
6145
+ // Iterate through all the .idx files
6146
+ let list = await fs.readdir(join(gitdir, 'objects/pack'));
6147
+ list = list.filter(x => x.endsWith('.idx'));
6148
+ for (const filename of list) {
6149
+ const indexFile = `${gitdir}/objects/pack/${filename}`;
6150
+ const p = await readPackIndex({
6151
+ fs,
6152
+ cache,
6153
+ filename: indexFile,
6154
+ getExternalRefDelta,
6155
+ });
6156
+ if (p.error) throw new InternalError(p.error)
6157
+ // If the packfile DOES have the oid we're looking for...
6158
+ if (p.offsets.has(oid)) {
6159
+ return true
6160
+ }
6161
+ }
6162
+ // Failed to find it
6163
+ return false
6164
+ }
6165
+
6166
+ async function hasObject({
6167
+ fs,
6168
+ cache,
6169
+ gitdir,
6170
+ oid,
6171
+ format = 'content',
6172
+ }) {
6173
+ // Curry the current read method so that the packfile un-deltification
6174
+ // process can acquire external ref-deltas.
6175
+ const getExternalRefDelta = oid => _readObject({ fs, cache, gitdir, oid });
6176
+
6177
+ // Look for it in the loose object directory.
6178
+ let result = await hasObjectLoose({ fs, gitdir, oid });
6179
+ // Check to see if it's in a packfile.
6180
+ if (!result) {
6181
+ result = await hasObjectPacked({
6182
+ fs,
6183
+ cache,
6184
+ gitdir,
6185
+ oid,
6186
+ getExternalRefDelta,
6187
+ });
6188
+ }
6189
+ // Finally
6190
+ return result
6191
+ }
6192
+
6131
6193
  // @ts-check
6132
6194
 
6133
6195
  /**
@@ -6429,8 +6491,24 @@ async function _commit({
6429
6491
  } else {
6430
6492
  // ensure that the parents are oids, not refs
6431
6493
  parent = await Promise.all(
6432
- parent.map(p => {
6433
- return GitRefManager.resolve({ fs, gitdir, ref: p })
6494
+ parent.map(async p => {
6495
+ let oid = await GitRefManager.resolve({ fs, gitdir, ref: p });
6496
+ // If `p` is an annotated tag, use the commit it points to.
6497
+ // Parents are not required to exist locally.
6498
+ while (await hasObject({ fs, cache, gitdir, oid })) {
6499
+ const { type, object } = await _readObject({
6500
+ fs,
6501
+ cache,
6502
+ gitdir,
6503
+ oid,
6504
+ });
6505
+ if (type === 'commit') break
6506
+ if (type !== 'tag') {
6507
+ throw new ObjectTypeError(oid, type, 'commit')
6508
+ }
6509
+ oid = GitAnnotatedTag.from(object).parse().object;
6510
+ }
6511
+ return oid
6434
6512
  })
6435
6513
  );
6436
6514
  }
@@ -7166,8 +7244,10 @@ async function _branch({
7166
7244
  // Probably an empty repo
7167
7245
  }
7168
7246
 
7169
- // Create a new ref that points at the current commit
7247
+ // Create a new ref that points at the current commit,
7248
+ // peeling annotated tags to the commit they point to
7170
7249
  if (oid) {
7250
+ oid = (await resolveCommit({ fs, cache: {}, gitdir, oid })).oid;
7171
7251
  await GitRefManager.writeRef({ fs, gitdir, ref: fullref, value: oid });
7172
7252
  }
7173
7253
 
@@ -7360,6 +7440,18 @@ async function _checkout({
7360
7440
  });
7361
7441
  }
7362
7442
 
7443
+ // If `ref` is an annotated tag, use the commit it points to
7444
+ if (!noUpdateHead) {
7445
+ try {
7446
+ oid = (await resolveCommit({ fs, cache, gitdir, oid })).oid;
7447
+ } catch (err) {
7448
+ if (err instanceof NotFoundError) {
7449
+ throw new CommitNotFetchedError(ref, err.data.what)
7450
+ }
7451
+ throw err
7452
+ }
7453
+ }
7454
+
7363
7455
  // Update working dir
7364
7456
  if (!noCheckout) {
7365
7457
  let ops;
@@ -7378,6 +7470,7 @@ async function _checkout({
7378
7470
  });
7379
7471
  } catch (err) {
7380
7472
  // Throw a more helpful error message for this common mistake.
7473
+ // Only reachable with `noUpdateHead`, otherwise the commit was already read above.
7381
7474
  if (err instanceof NotFoundError && err.data.what === oid) {
7382
7475
  throw new CommitNotFetchedError(ref, oid)
7383
7476
  } else {
@@ -9933,67 +10026,6 @@ class GitShallowManager {
9933
10026
  }
9934
10027
  }
9935
10028
 
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
10029
  function addCredentialUsername({ config, onAuth }) {
9998
10030
  if (!onAuth) return onAuth
9999
10031
 
@@ -10023,8 +10055,8 @@ function filterCapabilities(server, client) {
10023
10055
 
10024
10056
  const pkg = {
10025
10057
  name: 'isomorphic-git',
10026
- version: '1.43.0',
10027
- agent: 'git/isomorphic-git@1.43.0',
10058
+ version: '1.43.2',
10059
+ agent: 'git/isomorphic-git@1.43.2',
10028
10060
  };
10029
10061
 
10030
10062
  class FIFO {
@@ -11669,10 +11701,12 @@ async function _merge({
11669
11701
  gitdir,
11670
11702
  ref: ours,
11671
11703
  });
11672
- const theirOid = await GitRefManager.resolve({
11704
+ // If `theirs` is an annotated tag, use the commit it points to
11705
+ const { oid: theirOid } = await resolveCommit({
11673
11706
  fs,
11707
+ cache,
11674
11708
  gitdir,
11675
- ref: theirs,
11709
+ oid: await GitRefManager.resolve({ fs, gitdir, ref: theirs }),
11676
11710
  });
11677
11711
  // find most recent common ancestor of ref a and ref b
11678
11712
  const baseOids = await _findMergeBase({
package/index.js CHANGED
@@ -1824,8 +1824,9 @@ const SECTION_REGEX = /^[A-Za-z0-9-.]+$/;
1824
1824
  // variable name is alphanumeric (ASCII) with -
1825
1825
  // variable name starts with an alphabetic character
1826
1826
  // variable name is case insensitive
1827
- const VARIABLE_LINE_REGEX = /^([A-Za-z][A-Za-z-]*)(?: *= *(.*))?$/;
1828
- const VARIABLE_NAME_REGEX = /^[A-Za-z][A-Za-z-]*$/;
1827
+ // whitespace (spaces or tabs) around the equal sign is ignored
1828
+ const VARIABLE_LINE_REGEX = /^([A-Za-z][A-Za-z0-9-]*)(?:\s*=\s*(.*))?$/;
1829
+ const VARIABLE_NAME_REGEX = /^[A-Za-z][A-Za-z0-9-]*$/;
1829
1830
 
1830
1831
  // Comments start with either # or ; and extend to the end of line
1831
1832
  const VARIABLE_VALUE_COMMENT_REGEX = /^(.*?)( *[#;].*)$/;
@@ -6115,6 +6116,67 @@ async function addToIndex({
6115
6116
  return fulfilledPromises
6116
6117
  }
6117
6118
 
6119
+ async function hasObjectLoose({ fs, gitdir, oid }) {
6120
+ const source = `objects/${oid.slice(0, 2)}/${oid.slice(2)}`;
6121
+ return fs.exists(`${gitdir}/${source}`)
6122
+ }
6123
+
6124
+ async function hasObjectPacked({
6125
+ fs,
6126
+ cache,
6127
+ gitdir,
6128
+ oid,
6129
+ getExternalRefDelta,
6130
+ }) {
6131
+ // Check to see if it's in a packfile.
6132
+ // Iterate through all the .idx files
6133
+ let list = await fs.readdir(join(gitdir, 'objects/pack'));
6134
+ list = list.filter(x => x.endsWith('.idx'));
6135
+ for (const filename of list) {
6136
+ const indexFile = `${gitdir}/objects/pack/${filename}`;
6137
+ const p = await readPackIndex({
6138
+ fs,
6139
+ cache,
6140
+ filename: indexFile,
6141
+ getExternalRefDelta,
6142
+ });
6143
+ if (p.error) throw new InternalError(p.error)
6144
+ // If the packfile DOES have the oid we're looking for...
6145
+ if (p.offsets.has(oid)) {
6146
+ return true
6147
+ }
6148
+ }
6149
+ // Failed to find it
6150
+ return false
6151
+ }
6152
+
6153
+ async function hasObject({
6154
+ fs,
6155
+ cache,
6156
+ gitdir,
6157
+ oid,
6158
+ format = 'content',
6159
+ }) {
6160
+ // Curry the current read method so that the packfile un-deltification
6161
+ // process can acquire external ref-deltas.
6162
+ const getExternalRefDelta = oid => _readObject({ fs, cache, gitdir, oid });
6163
+
6164
+ // Look for it in the loose object directory.
6165
+ let result = await hasObjectLoose({ fs, gitdir, oid });
6166
+ // Check to see if it's in a packfile.
6167
+ if (!result) {
6168
+ result = await hasObjectPacked({
6169
+ fs,
6170
+ cache,
6171
+ gitdir,
6172
+ oid,
6173
+ getExternalRefDelta,
6174
+ });
6175
+ }
6176
+ // Finally
6177
+ return result
6178
+ }
6179
+
6118
6180
  // @ts-check
6119
6181
 
6120
6182
  /**
@@ -6416,8 +6478,24 @@ async function _commit({
6416
6478
  } else {
6417
6479
  // ensure that the parents are oids, not refs
6418
6480
  parent = await Promise.all(
6419
- parent.map(p => {
6420
- return GitRefManager.resolve({ fs, gitdir, ref: p })
6481
+ parent.map(async p => {
6482
+ let oid = await GitRefManager.resolve({ fs, gitdir, ref: p });
6483
+ // If `p` is an annotated tag, use the commit it points to.
6484
+ // Parents are not required to exist locally.
6485
+ while (await hasObject({ fs, cache, gitdir, oid })) {
6486
+ const { type, object } = await _readObject({
6487
+ fs,
6488
+ cache,
6489
+ gitdir,
6490
+ oid,
6491
+ });
6492
+ if (type === 'commit') break
6493
+ if (type !== 'tag') {
6494
+ throw new ObjectTypeError(oid, type, 'commit')
6495
+ }
6496
+ oid = GitAnnotatedTag.from(object).parse().object;
6497
+ }
6498
+ return oid
6421
6499
  })
6422
6500
  );
6423
6501
  }
@@ -7153,8 +7231,10 @@ async function _branch({
7153
7231
  // Probably an empty repo
7154
7232
  }
7155
7233
 
7156
- // Create a new ref that points at the current commit
7234
+ // Create a new ref that points at the current commit,
7235
+ // peeling annotated tags to the commit they point to
7157
7236
  if (oid) {
7237
+ oid = (await resolveCommit({ fs, cache: {}, gitdir, oid })).oid;
7158
7238
  await GitRefManager.writeRef({ fs, gitdir, ref: fullref, value: oid });
7159
7239
  }
7160
7240
 
@@ -7347,6 +7427,18 @@ async function _checkout({
7347
7427
  });
7348
7428
  }
7349
7429
 
7430
+ // If `ref` is an annotated tag, use the commit it points to
7431
+ if (!noUpdateHead) {
7432
+ try {
7433
+ oid = (await resolveCommit({ fs, cache, gitdir, oid })).oid;
7434
+ } catch (err) {
7435
+ if (err instanceof NotFoundError) {
7436
+ throw new CommitNotFetchedError(ref, err.data.what)
7437
+ }
7438
+ throw err
7439
+ }
7440
+ }
7441
+
7350
7442
  // Update working dir
7351
7443
  if (!noCheckout) {
7352
7444
  let ops;
@@ -7365,6 +7457,7 @@ async function _checkout({
7365
7457
  });
7366
7458
  } catch (err) {
7367
7459
  // Throw a more helpful error message for this common mistake.
7460
+ // Only reachable with `noUpdateHead`, otherwise the commit was already read above.
7368
7461
  if (err instanceof NotFoundError && err.data.what === oid) {
7369
7462
  throw new CommitNotFetchedError(ref, oid)
7370
7463
  } else {
@@ -9920,67 +10013,6 @@ class GitShallowManager {
9920
10013
  }
9921
10014
  }
9922
10015
 
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
10016
  function addCredentialUsername({ config, onAuth }) {
9985
10017
  if (!onAuth) return onAuth
9986
10018
 
@@ -10010,8 +10042,8 @@ function filterCapabilities(server, client) {
10010
10042
 
10011
10043
  const pkg = {
10012
10044
  name: 'isomorphic-git',
10013
- version: '1.43.0',
10014
- agent: 'git/isomorphic-git@1.43.0',
10045
+ version: '1.43.2',
10046
+ agent: 'git/isomorphic-git@1.43.2',
10015
10047
  };
10016
10048
 
10017
10049
  class FIFO {
@@ -11656,10 +11688,12 @@ async function _merge({
11656
11688
  gitdir,
11657
11689
  ref: ours,
11658
11690
  });
11659
- const theirOid = await GitRefManager.resolve({
11691
+ // If `theirs` is an annotated tag, use the commit it points to
11692
+ const { oid: theirOid } = await resolveCommit({
11660
11693
  fs,
11694
+ cache,
11661
11695
  gitdir,
11662
- ref: theirs,
11696
+ oid: await GitRefManager.resolve({ fs, gitdir, ref: theirs }),
11663
11697
  });
11664
11698
  // find most recent common ancestor of ref a and ref b
11665
11699
  const baseOids = await _findMergeBase({