isomorphic-git 1.34.2 → 1.35.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/index.js CHANGED
@@ -1,12 +1,10 @@
1
1
  import AsyncLock from 'async-lock';
2
2
  import Hash from 'sha.js/sha1.js';
3
- import { join } from 'path-browserify';
4
3
  import crc32 from 'crc-32';
5
4
  import pako from 'pako';
6
5
  import pify from 'pify';
7
6
  import ignore from 'ignore';
8
7
  import cleanGitRef from 'clean-git-ref';
9
- import validRef from 'is-git-ref-name-valid';
10
8
  import diff3Merge from 'diff3';
11
9
 
12
10
  /**
@@ -844,7 +842,7 @@ class GitIndex {
844
842
  gid: stats.gid,
845
843
  size: stats.size,
846
844
  path: filepath,
847
- oid: oid,
845
+ oid,
848
846
  flags: {
849
847
  assumeValid: false,
850
848
  extended: false,
@@ -1093,7 +1091,7 @@ type Node = {
1093
1091
 
1094
1092
  function flatFileListToDirectoryStructure(files) {
1095
1093
  const inodes = new Map();
1096
- const mkdir = function(name) {
1094
+ const mkdir = function (name) {
1097
1095
  if (!inodes.has(name)) {
1098
1096
  const dir = {
1099
1097
  type: 'tree',
@@ -1112,13 +1110,13 @@ function flatFileListToDirectoryStructure(files) {
1112
1110
  return inodes.get(name)
1113
1111
  };
1114
1112
 
1115
- const mkfile = function(name, metadata) {
1113
+ const mkfile = function (name, metadata) {
1116
1114
  if (!inodes.has(name)) {
1117
1115
  const file = {
1118
1116
  type: 'blob',
1119
1117
  fullpath: name,
1120
1118
  basename: basename(name),
1121
- metadata: metadata,
1119
+ metadata,
1122
1120
  // This recursively generates any missing parent folders.
1123
1121
  parent: mkdir(dirname(name)),
1124
1122
  children: [],
@@ -1156,7 +1154,7 @@ class GitWalkerIndex {
1156
1154
  constructor({ fs, gitdir, cache }) {
1157
1155
  this.treePromise = GitIndexManager.acquire(
1158
1156
  { fs, gitdir, cache },
1159
- async function(index) {
1157
+ async function (index) {
1160
1158
  return flatFileListToDirectoryStructure(index.entries)
1161
1159
  }
1162
1160
  );
@@ -1270,7 +1268,7 @@ const GitWalkSymbol = Symbol('GitWalkSymbol');
1270
1268
  function STAGE() {
1271
1269
  const o = Object.create(null);
1272
1270
  Object.defineProperty(o, GitWalkSymbol, {
1273
- value: function({ fs, gitdir, cache }) {
1271
+ value: function ({ fs, gitdir, cache }) {
1274
1272
  return new GitWalkerIndex({ fs, gitdir, cache })
1275
1273
  },
1276
1274
  });
@@ -1400,13 +1398,8 @@ class GitRefSpec {
1400
1398
  }
1401
1399
 
1402
1400
  static from(refspec) {
1403
- const [
1404
- forceMatch,
1405
- remotePath,
1406
- remoteGlobMatch,
1407
- localPath,
1408
- localGlobMatch,
1409
- ] = refspec.match(/^(\+?)(.*?)(\*?):(.*?)(\*?)$/).slice(1);
1401
+ const [forceMatch, remotePath, remoteGlobMatch, localPath, localGlobMatch] =
1402
+ refspec.match(/^(\+?)(.*?)(\*?):(.*?)(\*?)$/).slice(1);
1410
1403
  const force = forceMatch === '+';
1411
1404
  const remoteIsGlob = remoteGlobMatch === '*';
1412
1405
  const localIsGlob = localGlobMatch === '*';
@@ -1507,6 +1500,104 @@ function compareRefNames(a, b) {
1507
1500
  return tmp
1508
1501
  }
1509
1502
 
1503
+ /*!
1504
+ * This code for `path.join` is directly copied from @zenfs/core/path for bundle size improvements.
1505
+ * SPDX-License-Identifier: LGPL-3.0-or-later
1506
+ * Copyright (c) James Prevett and other ZenFS contributors.
1507
+ */
1508
+
1509
+ function normalizeString(path, aar) {
1510
+ let res = '';
1511
+ let lastSegmentLength = 0;
1512
+ let lastSlash = -1;
1513
+ let dots = 0;
1514
+ let char = '\x00';
1515
+ for (let i = 0; i <= path.length; ++i) {
1516
+ if (i < path.length) char = path[i];
1517
+ else if (char === '/') break
1518
+ else char = '/';
1519
+
1520
+ if (char === '/') {
1521
+ if (lastSlash === i - 1 || dots === 1) {
1522
+ // NOOP
1523
+ } else if (dots === 2) {
1524
+ if (
1525
+ res.length < 2 ||
1526
+ lastSegmentLength !== 2 ||
1527
+ res.at(-1) !== '.' ||
1528
+ res.at(-2) !== '.'
1529
+ ) {
1530
+ if (res.length > 2) {
1531
+ const lastSlashIndex = res.lastIndexOf('/');
1532
+ if (lastSlashIndex === -1) {
1533
+ res = '';
1534
+ lastSegmentLength = 0;
1535
+ } else {
1536
+ res = res.slice(0, lastSlashIndex);
1537
+ lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
1538
+ }
1539
+ lastSlash = i;
1540
+ dots = 0;
1541
+ continue
1542
+ } else if (res.length !== 0) {
1543
+ res = '';
1544
+ lastSegmentLength = 0;
1545
+ lastSlash = i;
1546
+ dots = 0;
1547
+ continue
1548
+ }
1549
+ }
1550
+ if (aar) {
1551
+ res += res.length > 0 ? '/..' : '..';
1552
+ lastSegmentLength = 2;
1553
+ }
1554
+ } else {
1555
+ if (res.length > 0) res += '/' + path.slice(lastSlash + 1, i);
1556
+ else res = path.slice(lastSlash + 1, i);
1557
+ lastSegmentLength = i - lastSlash - 1;
1558
+ }
1559
+ lastSlash = i;
1560
+ dots = 0;
1561
+ } else if (char === '.' && dots !== -1) {
1562
+ ++dots;
1563
+ } else {
1564
+ dots = -1;
1565
+ }
1566
+ }
1567
+ return res
1568
+ }
1569
+
1570
+ function normalize(path) {
1571
+ if (!path.length) return '.'
1572
+
1573
+ const isAbsolute = path[0] === '/';
1574
+ const trailingSeparator = path.at(-1) === '/';
1575
+
1576
+ path = normalizeString(path, !isAbsolute);
1577
+
1578
+ if (!path.length) {
1579
+ if (isAbsolute) return '/'
1580
+ return trailingSeparator ? './' : '.'
1581
+ }
1582
+ if (trailingSeparator) path += '/';
1583
+
1584
+ return isAbsolute ? `/${path}` : path
1585
+ }
1586
+
1587
+ function join(...args) {
1588
+ if (args.length === 0) return '.'
1589
+ let joined;
1590
+ for (let i = 0; i < args.length; ++i) {
1591
+ const arg = args[i];
1592
+ if (arg.length > 0) {
1593
+ if (joined === undefined) joined = arg;
1594
+ else joined += '/' + arg;
1595
+ }
1596
+ }
1597
+ if (joined === undefined) return '.'
1598
+ return normalize(joined)
1599
+ }
1600
+
1510
1601
  // This is straight from parse_unit_factor in config.c of canonical git
1511
1602
  const num = val => {
1512
1603
  if (typeof val === 'number') {
@@ -3852,8 +3943,8 @@ function parseAuthor(author) {
3852
3943
  /^(.*) <(.*)> (.*) (.*)$/
3853
3944
  );
3854
3945
  return {
3855
- name: name,
3856
- email: email,
3946
+ name,
3947
+ email,
3857
3948
  timestamp: Number(timestamp),
3858
3949
  timezoneOffset: parseTimezoneOffset(offset),
3859
3950
  }
@@ -4312,7 +4403,7 @@ class GitWalkerRepo {
4312
4403
  function TREE({ ref = 'HEAD' } = {}) {
4313
4404
  const o = Object.create(null);
4314
4405
  Object.defineProperty(o, GitWalkSymbol, {
4315
- value: function({ fs, gitdir, cache }) {
4406
+ value: function ({ fs, gitdir, cache }) {
4316
4407
  return new GitWalkerRepo({ fs, gitdir, ref, cache })
4317
4408
  },
4318
4409
  });
@@ -4436,46 +4527,47 @@ class GitWalkerFs {
4436
4527
  const { fs, gitdir, cache } = this;
4437
4528
  let oid;
4438
4529
  // See if we can use the SHA1 hash in the index.
4439
- await GitIndexManager.acquire({ fs, gitdir, cache }, async function(
4440
- index
4441
- ) {
4442
- const stage = index.entriesMap.get(entry._fullpath);
4443
- const stats = await entry.stat();
4444
- const config = await self._getGitConfig(fs, gitdir);
4445
- const filemode = await config.get('core.filemode');
4446
- const trustino =
4447
- typeof process !== 'undefined'
4448
- ? !(process.platform === 'win32')
4449
- : true;
4450
- if (!stage || compareStats(stats, stage, filemode, trustino)) {
4451
- const content = await entry.content();
4452
- if (content === undefined) {
4453
- oid = undefined;
4454
- } else {
4455
- oid = await shasum(
4456
- GitObject.wrap({ type: 'blob', object: content })
4457
- );
4458
- // Update the stats in the index so we will get a "cache hit" next time
4459
- // 1) if we can (because the oid and mode are the same)
4460
- // 2) and only if we need to (because other stats differ)
4461
- if (
4462
- stage &&
4463
- oid === stage.oid &&
4464
- (!filemode || stats.mode === stage.mode) &&
4465
- compareStats(stats, stage, filemode, trustino)
4466
- ) {
4467
- index.insert({
4468
- filepath: entry._fullpath,
4469
- stats,
4470
- oid: oid,
4471
- });
4530
+ await GitIndexManager.acquire(
4531
+ { fs, gitdir, cache },
4532
+ async function (index) {
4533
+ const stage = index.entriesMap.get(entry._fullpath);
4534
+ const stats = await entry.stat();
4535
+ const config = await self._getGitConfig(fs, gitdir);
4536
+ const filemode = await config.get('core.filemode');
4537
+ const trustino =
4538
+ typeof process !== 'undefined'
4539
+ ? !(process.platform === 'win32')
4540
+ : true;
4541
+ if (!stage || compareStats(stats, stage, filemode, trustino)) {
4542
+ const content = await entry.content();
4543
+ if (content === undefined) {
4544
+ oid = undefined;
4545
+ } else {
4546
+ oid = await shasum(
4547
+ GitObject.wrap({ type: 'blob', object: content })
4548
+ );
4549
+ // Update the stats in the index so we will get a "cache hit" next time
4550
+ // 1) if we can (because the oid and mode are the same)
4551
+ // 2) and only if we need to (because other stats differ)
4552
+ if (
4553
+ stage &&
4554
+ oid === stage.oid &&
4555
+ (!filemode || stats.mode === stage.mode) &&
4556
+ compareStats(stats, stage, filemode, trustino)
4557
+ ) {
4558
+ index.insert({
4559
+ filepath: entry._fullpath,
4560
+ stats,
4561
+ oid,
4562
+ });
4563
+ }
4472
4564
  }
4565
+ } else {
4566
+ // Use the index SHA1 rather than compute it
4567
+ oid = stage.oid;
4473
4568
  }
4474
- } else {
4475
- // Use the index SHA1 rather than compute it
4476
- oid = stage.oid;
4477
4569
  }
4478
- });
4570
+ );
4479
4571
  entry._oid = oid;
4480
4572
  }
4481
4573
  return entry._oid
@@ -4498,7 +4590,7 @@ class GitWalkerFs {
4498
4590
  function WORKDIR() {
4499
4591
  const o = Object.create(null);
4500
4592
  Object.defineProperty(o, GitWalkSymbol, {
4501
- value: function({ fs, dir, gitdir, cache }) {
4593
+ value: function ({ fs, dir, gitdir, cache }) {
4502
4594
  return new GitWalkerFs({ fs, dir, gitdir, cache })
4503
4595
  },
4504
4596
  });
@@ -4643,7 +4735,7 @@ async function _walk({
4643
4735
  const root = new Array(walkers.length).fill('.');
4644
4736
  const range = arrayRange(0, walkers.length);
4645
4737
  const unionWalkerFromReaddir = async entries => {
4646
- range.map(i => {
4738
+ range.forEach(i => {
4647
4739
  const entry = entries[i];
4648
4740
  entries[i] = entry && new walkers[i].ConstructEntry(entry);
4649
4741
  });
@@ -4855,7 +4947,6 @@ class FileSystem {
4855
4947
  async write(filepath, contents, options = {}) {
4856
4948
  try {
4857
4949
  await this._writeFile(filepath, contents, options);
4858
- return
4859
4950
  } catch (err) {
4860
4951
  // Hmm. Let's try mkdirp and try again.
4861
4952
  await this.mkdir(dirname(filepath));
@@ -4873,7 +4964,6 @@ class FileSystem {
4873
4964
  async mkdir(filepath, _selfCall = false) {
4874
4965
  try {
4875
4966
  await this._mkdir(filepath);
4876
- return
4877
4967
  } catch (err) {
4878
4968
  // If err is null then operation succeeded!
4879
4969
  if (err === null) return
@@ -5092,9 +5182,12 @@ async function abortMerge({
5092
5182
  const trees = [TREE({ ref: commit }), WORKDIR(), STAGE()];
5093
5183
  let unmergedPaths = [];
5094
5184
 
5095
- await GitIndexManager.acquire({ fs, gitdir, cache }, async function(index) {
5096
- unmergedPaths = index.unmergedPaths;
5097
- });
5185
+ await GitIndexManager.acquire(
5186
+ { fs, gitdir, cache },
5187
+ async function (index) {
5188
+ unmergedPaths = index.unmergedPaths;
5189
+ }
5190
+ );
5098
5191
 
5099
5192
  const results = await _walk({
5100
5193
  fs,
@@ -5102,7 +5195,7 @@ async function abortMerge({
5102
5195
  dir,
5103
5196
  gitdir,
5104
5197
  trees,
5105
- map: async function(path, [head, workdir, index]) {
5198
+ map: async function (path, [head, workdir, index]) {
5106
5199
  const staged = !(await modified(workdir, index));
5107
5200
  const unmerged = unmergedPaths.includes(path);
5108
5201
  const unmodified = !(await modified(index, head));
@@ -5124,31 +5217,36 @@ async function abortMerge({
5124
5217
  },
5125
5218
  });
5126
5219
 
5127
- await GitIndexManager.acquire({ fs, gitdir, cache }, async function(index) {
5128
- // Reset paths in index and worktree, this can't be done in _walk because the
5129
- // STAGE walker acquires its own index lock.
5130
-
5131
- for (const entry of results) {
5132
- if (entry === false) continue
5133
-
5134
- // entry is not false, so from here we can assume index = workdir
5135
- if (!entry) {
5136
- await fs.rmdir(`${dir}/${entry.path}`, { recursive: true });
5137
- index.delete({ filepath: entry.path });
5138
- continue
5139
- }
5220
+ await GitIndexManager.acquire(
5221
+ { fs, gitdir, cache },
5222
+ async function (index) {
5223
+ // Reset paths in index and worktree, this can't be done in _walk because the
5224
+ // STAGE walker acquires its own index lock.
5225
+
5226
+ for (const entry of results) {
5227
+ if (entry === false) continue
5228
+
5229
+ // entry is not false, so from here we can assume index = workdir
5230
+ if (!entry) {
5231
+ await fs.rmdir(`${dir}/${entry.path}`, { recursive: true });
5232
+ index.delete({ filepath: entry.path });
5233
+ continue
5234
+ }
5140
5235
 
5141
- if (entry.type === 'blob') {
5142
- const content = new TextDecoder().decode(entry.content);
5143
- await fs.write(`${dir}/${entry.path}`, content, { mode: entry.mode });
5144
- index.insert({
5145
- filepath: entry.path,
5146
- oid: entry.oid,
5147
- stage: 0,
5148
- });
5236
+ if (entry.type === 'blob') {
5237
+ const content = new TextDecoder().decode(entry.content);
5238
+ await fs.write(`${dir}/${entry.path}`, content, {
5239
+ mode: entry.mode,
5240
+ });
5241
+ index.insert({
5242
+ filepath: entry.path,
5243
+ oid: entry.oid,
5244
+ stage: 0,
5245
+ });
5246
+ }
5149
5247
  }
5150
5248
  }
5151
- });
5249
+ );
5152
5250
  } catch (err) {
5153
5251
  err.caller = 'git.abortMerge';
5154
5252
  throw err
@@ -5710,7 +5808,7 @@ async function _commit({
5710
5808
 
5711
5809
  return GitIndexManager.acquire(
5712
5810
  { fs, gitdir, cache, allowUnmerged: false },
5713
- async function(index) {
5811
+ async function (index) {
5714
5812
  const inodes = flatFileListToDirectoryStructure(index.entries);
5715
5813
  const inode = inodes.get('.');
5716
5814
  if (!tree) {
@@ -6124,6 +6222,22 @@ async function addNote({
6124
6222
  }
6125
6223
  }
6126
6224
 
6225
+ /*
6226
+ Adapted from is-git-ref-name-valid
6227
+ SPDX-License-Identifier: MIT
6228
+ Copyright © Vincent Weevers
6229
+ */
6230
+
6231
+ // eslint-disable-next-line no-control-regex
6232
+ const bad = /(^|[/.])([/.]|$)|^@$|@{|[\x00-\x20\x7f~^:?*[\\]|\.lock(\/|$)/;
6233
+
6234
+ function isValidRef(name, onelevel) {
6235
+ if (typeof name !== 'string')
6236
+ throw new TypeError('Reference name must be a string')
6237
+
6238
+ return !bad.test(name) && (!!onelevel || name.includes('/'))
6239
+ }
6240
+
6127
6241
  // @ts-check
6128
6242
 
6129
6243
  /**
@@ -6138,7 +6252,7 @@ async function addNote({
6138
6252
  *
6139
6253
  */
6140
6254
  async function _addRemote({ fs, gitdir, remote, url, force }) {
6141
- if (!validRef(remote, true)) {
6255
+ if (!isValidRef(remote, true)) {
6142
6256
  throw new InvalidRefNameError(remote, cleanGitRef.clean(remote))
6143
6257
  }
6144
6258
  const config = await GitConfigManager.get({ fs, gitdir });
@@ -6410,7 +6524,7 @@ async function _branch({
6410
6524
  checkout = false,
6411
6525
  force = false,
6412
6526
  }) {
6413
- if (!validRef(ref, true)) {
6527
+ if (!isValidRef(ref, true)) {
6414
6528
  throw new InvalidRefNameError(ref, cleanGitRef.clean(ref))
6415
6529
  }
6416
6530
 
@@ -6650,63 +6764,69 @@ async function _checkout({
6650
6764
 
6651
6765
  let count = 0;
6652
6766
  const total = ops.length;
6653
- await GitIndexManager.acquire({ fs, gitdir, cache }, async function(index) {
6654
- await Promise.all(
6655
- ops
6656
- .filter(
6657
- ([method]) => method === 'delete' || method === 'delete-index'
6658
- )
6659
- .map(async function([method, fullpath]) {
6660
- const filepath = `${dir}/${fullpath}`;
6661
- if (method === 'delete') {
6662
- await fs.rm(filepath);
6663
- }
6664
- index.delete({ filepath: fullpath });
6665
- if (onProgress) {
6666
- await onProgress({
6667
- phase: 'Updating workdir',
6668
- loaded: ++count,
6669
- total,
6670
- });
6671
- }
6672
- })
6673
- );
6674
- });
6767
+ await GitIndexManager.acquire(
6768
+ { fs, gitdir, cache },
6769
+ async function (index) {
6770
+ await Promise.all(
6771
+ ops
6772
+ .filter(
6773
+ ([method]) => method === 'delete' || method === 'delete-index'
6774
+ )
6775
+ .map(async function ([method, fullpath]) {
6776
+ const filepath = `${dir}/${fullpath}`;
6777
+ if (method === 'delete') {
6778
+ await fs.rm(filepath);
6779
+ }
6780
+ index.delete({ filepath: fullpath });
6781
+ if (onProgress) {
6782
+ await onProgress({
6783
+ phase: 'Updating workdir',
6784
+ loaded: ++count,
6785
+ total,
6786
+ });
6787
+ }
6788
+ })
6789
+ );
6790
+ }
6791
+ );
6675
6792
 
6676
6793
  // Note: this is cannot be done naively in parallel
6677
- await GitIndexManager.acquire({ fs, gitdir, cache }, async function(index) {
6678
- for (const [method, fullpath] of ops) {
6679
- if (method === 'rmdir' || method === 'rmdir-index') {
6680
- const filepath = `${dir}/${fullpath}`;
6681
- try {
6682
- if (method === 'rmdir') {
6683
- await fs.rmdir(filepath);
6684
- }
6685
- index.delete({ filepath: fullpath });
6686
- if (onProgress) {
6687
- await onProgress({
6688
- phase: 'Updating workdir',
6689
- loaded: ++count,
6690
- total,
6691
- });
6692
- }
6693
- } catch (e) {
6694
- if (e.code === 'ENOTEMPTY') {
6695
- console.log(
6696
- `Did not delete ${fullpath} because directory is not empty`
6697
- );
6698
- } else {
6699
- throw e
6794
+ await GitIndexManager.acquire(
6795
+ { fs, gitdir, cache },
6796
+ async function (index) {
6797
+ for (const [method, fullpath] of ops) {
6798
+ if (method === 'rmdir' || method === 'rmdir-index') {
6799
+ const filepath = `${dir}/${fullpath}`;
6800
+ try {
6801
+ if (method === 'rmdir') {
6802
+ await fs.rmdir(filepath);
6803
+ }
6804
+ index.delete({ filepath: fullpath });
6805
+ if (onProgress) {
6806
+ await onProgress({
6807
+ phase: 'Updating workdir',
6808
+ loaded: ++count,
6809
+ total,
6810
+ });
6811
+ }
6812
+ } catch (e) {
6813
+ if (e.code === 'ENOTEMPTY') {
6814
+ console.log(
6815
+ `Did not delete ${fullpath} because directory is not empty`
6816
+ );
6817
+ } else {
6818
+ throw e
6819
+ }
6700
6820
  }
6701
6821
  }
6702
6822
  }
6703
6823
  }
6704
- });
6824
+ );
6705
6825
 
6706
6826
  await Promise.all(
6707
6827
  ops
6708
6828
  .filter(([method]) => method === 'mkdir' || method === 'mkdir-index')
6709
- .map(async function([_, fullpath]) {
6829
+ .map(async function ([_, fullpath]) {
6710
6830
  const filepath = `${dir}/${fullpath}`;
6711
6831
  await fs.mkdir(filepath);
6712
6832
  if (onProgress) {
@@ -6731,14 +6851,16 @@ async function _checkout({
6731
6851
 
6732
6852
  const updateWorkingDirResults = await batchAllSettled(
6733
6853
  'Update Working Dir',
6734
- eligibleOps.map(([method, fullpath, oid, mode, chmod]) => () =>
6735
- updateWorkingDir({ fs, cache, gitdir, dir }, [
6736
- method,
6737
- fullpath,
6738
- oid,
6739
- mode,
6740
- chmod,
6741
- ])
6854
+ eligibleOps.map(
6855
+ ([method, fullpath, oid, mode, chmod]) =>
6856
+ () =>
6857
+ updateWorkingDir({ fs, cache, gitdir, dir }, [
6858
+ method,
6859
+ fullpath,
6860
+ oid,
6861
+ mode,
6862
+ chmod,
6863
+ ])
6742
6864
  ),
6743
6865
  onProgress,
6744
6866
  batchSize
@@ -6746,11 +6868,13 @@ async function _checkout({
6746
6868
 
6747
6869
  await GitIndexManager.acquire(
6748
6870
  { fs, gitdir, cache, allowUnmerged: true },
6749
- async function(index) {
6871
+ async function (index) {
6750
6872
  await batchAllSettled(
6751
6873
  'Update Index',
6752
- updateWorkingDirResults.map(([fullpath, oid, stats]) => () =>
6753
- updateIndex({ index, fullpath, oid, stats })
6874
+ updateWorkingDirResults.map(
6875
+ ([fullpath, oid, stats]) =>
6876
+ () =>
6877
+ updateIndex({ index, fullpath, oid, stats })
6754
6878
  ),
6755
6879
  onProgress,
6756
6880
  batchSize
@@ -6760,7 +6884,7 @@ async function _checkout({
6760
6884
  } else {
6761
6885
  await GitIndexManager.acquire(
6762
6886
  { fs, gitdir, cache, allowUnmerged: true },
6763
- async function(index) {
6887
+ async function (index) {
6764
6888
  await Promise.all(
6765
6889
  ops
6766
6890
  .filter(
@@ -6770,7 +6894,7 @@ async function _checkout({
6770
6894
  method === 'update' ||
6771
6895
  method === 'mkdir-index'
6772
6896
  )
6773
- .map(async function([method, fullpath, oid, mode, chmod]) {
6897
+ .map(async function ([method, fullpath, oid, mode, chmod]) {
6774
6898
  const filepath = `${dir}/${fullpath}`;
6775
6899
  try {
6776
6900
  if (method !== 'create-index' && method !== 'mkdir-index') {
@@ -6879,7 +7003,7 @@ async function analyze({
6879
7003
  dir,
6880
7004
  gitdir,
6881
7005
  trees: [TREE({ ref }), WORKDIR(), STAGE()],
6882
- map: async function(fullpath, [commit, workdir, stage]) {
7006
+ map: async function (fullpath, [commit, workdir, stage]) {
6883
7007
  if (fullpath === '.') return
6884
7008
  // match against base paths
6885
7009
  if (filepaths && !filepaths.some(base => worthWalking(fullpath, base))) {
@@ -7137,7 +7261,7 @@ async function analyze({
7137
7261
  }
7138
7262
  },
7139
7263
  // Modify the default flat mapping
7140
- reduce: async function(parent, children) {
7264
+ reduce: async function (parent, children) {
7141
7265
  children = flat(children);
7142
7266
  if (!parent) {
7143
7267
  return children
@@ -7331,7 +7455,7 @@ async function checkout({
7331
7455
  }
7332
7456
 
7333
7457
  // @see https://git-scm.com/docs/git-rev-parse.html#_specifying_revisions
7334
- const abbreviateRx = new RegExp('^refs/(heads/|tags/|remotes/)?(.*)');
7458
+ const abbreviateRx = /^refs\/(heads\/|tags\/|remotes\/)?(.*)/;
7335
7459
 
7336
7460
  function abbreviateRef(ref) {
7337
7461
  const match = abbreviateRx.exec(ref);
@@ -7940,7 +8064,7 @@ class GitShallowManager {
7940
8064
  if (lock$2 === null) lock$2 = new AsyncLock();
7941
8065
  const filepath = join(gitdir, 'shallow');
7942
8066
  const oids = new Set();
7943
- await lock$2.acquire(filepath, async function() {
8067
+ await lock$2.acquire(filepath, async function () {
7944
8068
  const text = await fs.read(filepath, { encoding: 'utf8' });
7945
8069
  if (text === null) return oids // no file
7946
8070
  if (text.trim() === '') return oids // empty file
@@ -7967,14 +8091,14 @@ class GitShallowManager {
7967
8091
  const filepath = join(gitdir, 'shallow');
7968
8092
  if (oids.size > 0) {
7969
8093
  const text = [...oids].join('\n') + '\n';
7970
- await lock$2.acquire(filepath, async function() {
8094
+ await lock$2.acquire(filepath, async function () {
7971
8095
  await fs.write(filepath, text, {
7972
8096
  encoding: 'utf8',
7973
8097
  });
7974
8098
  });
7975
8099
  } else {
7976
8100
  // No shallows
7977
- await lock$2.acquire(filepath, async function() {
8101
+ await lock$2.acquire(filepath, async function () {
7978
8102
  await fs.rm(filepath);
7979
8103
  });
7980
8104
  }
@@ -8061,8 +8185,8 @@ function filterCapabilities(server, client) {
8061
8185
 
8062
8186
  const pkg = {
8063
8187
  name: 'isomorphic-git',
8064
- version: '1.34.2',
8065
- agent: 'git/isomorphic-git@1.34.2',
8188
+ version: '1.35.0',
8189
+ agent: 'git/isomorphic-git@1.35.0',
8066
8190
  };
8067
8191
 
8068
8192
  class FIFO {
@@ -8181,7 +8305,7 @@ class GitSideBand {
8181
8305
  const packfile = new FIFO();
8182
8306
  const progress = new FIFO();
8183
8307
  // TODO: Use a proper through stream?
8184
- const nextBit = async function() {
8308
+ const nextBit = async function () {
8185
8309
  const line = await read();
8186
8310
  // Skip over flush packets
8187
8311
  if (line === null) return nextBit()
@@ -9667,7 +9791,7 @@ async function mergeTree({
9667
9791
  dir,
9668
9792
  gitdir,
9669
9793
  trees: [ourTree, baseTree, theirTree],
9670
- map: async function(filepath, [ours, base, theirs]) {
9794
+ map: async function (filepath, [ours, base, theirs]) {
9671
9795
  const path = basename(filepath);
9672
9796
  // What we did, what they did
9673
9797
  const ourChange = await modified(ours, base);
@@ -9904,7 +10028,7 @@ async function mergeTree({
9904
10028
  dir,
9905
10029
  gitdir,
9906
10030
  trees: [TREE({ ref: results.oid })],
9907
- map: async function(filepath, [entry]) {
10031
+ map: async function (filepath, [entry]) {
9908
10032
  const path = `${dir}/${filepath}`;
9909
10033
  if ((await entry.type()) === 'blob') {
9910
10034
  const mode = await entry.mode();
@@ -11439,11 +11563,12 @@ async function _listFiles({ fs, gitdir, ref, cache }) {
11439
11563
  });
11440
11564
  return filenames
11441
11565
  } else {
11442
- return GitIndexManager.acquire({ fs, gitdir, cache }, async function(
11443
- index
11444
- ) {
11445
- return index.entries.map(x => x.path)
11446
- })
11566
+ return GitIndexManager.acquire(
11567
+ { fs, gitdir, cache },
11568
+ async function (index) {
11569
+ return index.entries.map(x => x.path)
11570
+ }
11571
+ )
11447
11572
  }
11448
11573
  }
11449
11574
 
@@ -11973,7 +12098,7 @@ async function _resolveFileId({
11973
12098
  filepaths = [],
11974
12099
  parentPath = '',
11975
12100
  }) {
11976
- const walks = tree.entries().map(function(entry) {
12101
+ const walks = tree.entries().map(function (entry) {
11977
12102
  let result;
11978
12103
  if (entry.oid === fileId) {
11979
12104
  result = join(parentPath, entry.path);
@@ -11984,7 +12109,7 @@ async function _resolveFileId({
11984
12109
  cache,
11985
12110
  gitdir,
11986
12111
  oid: entry.oid,
11987
- }).then(function({ object }) {
12112
+ }).then(function ({ object }) {
11988
12113
  return _resolveFileId({
11989
12114
  fs,
11990
12115
  cache,
@@ -13008,7 +13133,7 @@ async function _push({
13008
13133
  const hookCancel = await onPrePush({
13009
13134
  remote,
13010
13135
  url,
13011
- localRef: { ref: _delete ? '(delete)' : fullRef, oid: oid },
13136
+ localRef: { ref: _delete ? '(delete)' : fullRef, oid },
13012
13137
  remoteRef: { ref: fullRemoteRef, oid: oldoid },
13013
13138
  });
13014
13139
  if (!hookCancel) throw new UserCanceledError()
@@ -13956,7 +14081,7 @@ async function remove({
13956
14081
 
13957
14082
  await GitIndexManager.acquire(
13958
14083
  { fs: new FileSystem(_fs), gitdir, cache },
13959
- async function(index) {
14084
+ async function (index) {
13960
14085
  index.delete({ filepath });
13961
14086
  }
13962
14087
  );
@@ -14145,11 +14270,11 @@ async function _renameBranch({
14145
14270
  ref,
14146
14271
  checkout = false,
14147
14272
  }) {
14148
- if (!validRef(ref, true)) {
14273
+ if (!isValidRef(ref, true)) {
14149
14274
  throw new InvalidRefNameError(ref, cleanGitRef.clean(ref))
14150
14275
  }
14151
14276
 
14152
- if (!validRef(oldref, true)) {
14277
+ if (!isValidRef(oldref, true)) {
14153
14278
  throw new InvalidRefNameError(oldref, cleanGitRef.clean(oldref))
14154
14279
  }
14155
14280
 
@@ -14333,12 +14458,15 @@ async function resetIndex({
14333
14458
  stats = await fs.lstat(join(dir, filepath));
14334
14459
  }
14335
14460
  }
14336
- await GitIndexManager.acquire({ fs, gitdir, cache }, async function(index) {
14337
- index.delete({ filepath });
14338
- if (oid) {
14339
- index.insert({ filepath, stats, oid });
14461
+ await GitIndexManager.acquire(
14462
+ { fs, gitdir, cache },
14463
+ async function (index) {
14464
+ index.delete({ filepath });
14465
+ if (oid) {
14466
+ index.insert({ filepath, stats, oid });
14467
+ }
14340
14468
  }
14341
- });
14469
+ );
14342
14470
  } catch (err) {
14343
14471
  err.caller = 'git.reset';
14344
14472
  throw err
@@ -15204,9 +15332,8 @@ async function _stashDrop({ fs, dir, gitdir, refIdx = 0 }) {
15204
15332
  reflogEntries.reverse().join('\n') + '\n',
15205
15333
  'utf8'
15206
15334
  );
15207
- const lastStashCommit = reflogEntries[reflogEntries.length - 1].split(
15208
- ' '
15209
- )[1];
15335
+ const lastStashCommit =
15336
+ reflogEntries[reflogEntries.length - 1].split(' ')[1];
15210
15337
  await stashMgr.writeStashRef(lastStashCommit);
15211
15338
  } else {
15212
15339
  // remove the stash reflog file if no entry left
@@ -15421,7 +15548,7 @@ async function status({
15421
15548
  });
15422
15549
  const indexEntry = await GitIndexManager.acquire(
15423
15550
  { fs, gitdir, cache },
15424
- async function(index) {
15551
+ async function (index) {
15425
15552
  for (const entry of index) {
15426
15553
  if (entry.path === filepath) return entry
15427
15554
  }
@@ -15451,11 +15578,12 @@ async function status({
15451
15578
  // (like the Karma webserver) because BrowserFS HTTP Backend uses HTTP HEAD requests to do fs.stat
15452
15579
  if (stats.size !== -1) {
15453
15580
  // We don't await this so we can return faster for one-off cases.
15454
- GitIndexManager.acquire({ fs, gitdir, cache }, async function(
15455
- index
15456
- ) {
15457
- index.insert({ filepath, stats, oid: workdirOid });
15458
- });
15581
+ GitIndexManager.acquire(
15582
+ { fs, gitdir, cache },
15583
+ async function (index) {
15584
+ index.insert({ filepath, stats, oid: workdirOid });
15585
+ }
15586
+ );
15459
15587
  }
15460
15588
  }
15461
15589
  return workdirOid
@@ -15719,7 +15847,7 @@ async function statusMatrix({
15719
15847
  dir,
15720
15848
  gitdir,
15721
15849
  trees: [TREE({ ref }), WORKDIR(), STAGE()],
15722
- map: async function(filepath, [head, workdir, stage]) {
15850
+ map: async function (filepath, [head, workdir, stage]) {
15723
15851
  // Ignore ignored files, but only if they are not already tracked.
15724
15852
  if (!head && !stage && workdir) {
15725
15853
  if (!shouldIgnore) {
@@ -15911,7 +16039,7 @@ async function updateIndex$1({
15911
16039
  if (remove) {
15912
16040
  return await GitIndexManager.acquire(
15913
16041
  { fs, gitdir, cache },
15914
- async function(index) {
16042
+ async function (index) {
15915
16043
  if (!force) {
15916
16044
  // Check if the file is still present in the working directory
15917
16045
  const fileStats = await fs.lstat(join(dir, filepath));
@@ -15954,54 +16082,55 @@ async function updateIndex$1({
15954
16082
  }
15955
16083
  }
15956
16084
 
15957
- return await GitIndexManager.acquire({ fs, gitdir, cache }, async function(
15958
- index
15959
- ) {
15960
- if (!add && !index.has({ filepath })) {
15961
- // If the index does not contain the filepath yet and `add` is not set, we should throw
15962
- throw new NotFoundError(
15963
- `file at "${filepath}" in index and "add" not set`
15964
- )
15965
- }
16085
+ return await GitIndexManager.acquire(
16086
+ { fs, gitdir, cache },
16087
+ async function (index) {
16088
+ if (!add && !index.has({ filepath })) {
16089
+ // If the index does not contain the filepath yet and `add` is not set, we should throw
16090
+ throw new NotFoundError(
16091
+ `file at "${filepath}" in index and "add" not set`
16092
+ )
16093
+ }
15966
16094
 
15967
- let stats;
15968
- if (!oid) {
15969
- stats = fileStats;
16095
+ let stats;
16096
+ if (!oid) {
16097
+ stats = fileStats;
15970
16098
 
15971
- // Write the file to the object database
15972
- const object = stats.isSymbolicLink()
15973
- ? await fs.readlink(join(dir, filepath))
15974
- : await fs.read(join(dir, filepath));
16099
+ // Write the file to the object database
16100
+ const object = stats.isSymbolicLink()
16101
+ ? await fs.readlink(join(dir, filepath))
16102
+ : await fs.read(join(dir, filepath));
15975
16103
 
15976
- oid = await _writeObject({
15977
- fs,
15978
- gitdir,
15979
- type: 'blob',
15980
- format: 'content',
15981
- object,
15982
- });
15983
- } else {
15984
- // By default we use 0 for the stats of the index file
15985
- stats = {
15986
- ctime: new Date(0),
15987
- mtime: new Date(0),
15988
- dev: 0,
15989
- ino: 0,
15990
- mode,
15991
- uid: 0,
15992
- gid: 0,
15993
- size: 0,
15994
- };
15995
- }
16104
+ oid = await _writeObject({
16105
+ fs,
16106
+ gitdir,
16107
+ type: 'blob',
16108
+ format: 'content',
16109
+ object,
16110
+ });
16111
+ } else {
16112
+ // By default we use 0 for the stats of the index file
16113
+ stats = {
16114
+ ctime: new Date(0),
16115
+ mtime: new Date(0),
16116
+ dev: 0,
16117
+ ino: 0,
16118
+ mode,
16119
+ uid: 0,
16120
+ gid: 0,
16121
+ size: 0,
16122
+ };
16123
+ }
15996
16124
 
15997
- index.insert({
15998
- filepath,
15999
- oid: oid,
16000
- stats,
16001
- });
16125
+ index.insert({
16126
+ filepath,
16127
+ oid,
16128
+ stats,
16129
+ });
16002
16130
 
16003
- return oid
16004
- })
16131
+ return oid
16132
+ }
16133
+ )
16005
16134
  } catch (err) {
16006
16135
  err.caller = 'git.updateIndex';
16007
16136
  throw err
@@ -16555,7 +16684,7 @@ async function writeRef({
16555
16684
 
16556
16685
  const fs = new FileSystem(_fs);
16557
16686
 
16558
- if (!validRef(ref, true)) {
16687
+ if (!isValidRef(ref, true)) {
16559
16688
  throw new InvalidRefNameError(ref, cleanGitRef.clean(ref))
16560
16689
  }
16561
16690