isomorphic-git 1.30.0 → 1.30.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.
@@ -1,8 +1,10 @@
1
1
  [
2
2
  "Chrome Headless 79.0.3945.0 (Linux x86_64)",
3
3
  "Firefox 136.0 (Ubuntu 0.0.0)",
4
- "Chrome 128.0.0.0 (Android 10)",
4
+ "X Chrome 128.0.0.0 (Android 10)",
5
5
  "Edge 79.0.309.65 (Windows 10)",
6
+ "Mobile Safari 14.0 (iOS 14.0.1)",
6
7
  "Safari 14.1 (Mac OS 10.15.7)",
7
- "Mobile Safari 14.0 (iOS 14.0.1)"
8
+ "Chrome Headless 79.0.3945.0 (Linux x86_64)",
9
+ "Chrome 128.0.0.0 (Android 10)"
8
10
  ]
package/index.cjs CHANGED
@@ -979,8 +979,11 @@ function createCache() {
979
979
  }
980
980
 
981
981
  async function updateCachedIndexFile(fs, filepath, cache) {
982
- const stat = await fs.lstat(filepath);
983
- const rawIndexFile = await fs.read(filepath);
982
+ const [stat, rawIndexFile] = await Promise.all([
983
+ fs.lstat(filepath),
984
+ fs.read(filepath),
985
+ ]);
986
+
984
987
  const index = await GitIndex.from(rawIndexFile);
985
988
  // cache the GitIndex object so we don't need to re-read it every time.
986
989
  cache.map.set(filepath, index);
@@ -992,8 +995,9 @@ async function updateCachedIndexFile(fs, filepath, cache) {
992
995
  async function isIndexStale(fs, filepath, cache) {
993
996
  const savedStats = cache.stats.get(filepath);
994
997
  if (savedStats === undefined) return true
995
- const currStats = await fs.lstat(filepath);
996
998
  if (savedStats === null) return false
999
+
1000
+ const currStats = await fs.lstat(filepath);
997
1001
  if (currStats === null) return false
998
1002
  return compareStats(savedStats, currStats)
999
1003
  }
@@ -1009,7 +1013,9 @@ class GitIndexManager {
1009
1013
  * @param {function(GitIndex): any} closure
1010
1014
  */
1011
1015
  static async acquire({ fs, gitdir, cache, allowUnmerged = true }, closure) {
1012
- if (!cache[IndexCache]) cache[IndexCache] = createCache();
1016
+ if (!cache[IndexCache]) {
1017
+ cache[IndexCache] = createCache();
1018
+ }
1013
1019
 
1014
1020
  const filepath = `${gitdir}/index`;
1015
1021
  if (lock === null) lock = new AsyncLock({ maxPending: Infinity });
@@ -1020,10 +1026,11 @@ class GitIndexManager {
1020
1026
  // to make sure other processes aren't writing to it
1021
1027
  // simultaneously, which could result in a corrupted index.
1022
1028
  // const fileLock = await Lock(filepath)
1023
- if (await isIndexStale(fs, filepath, cache[IndexCache])) {
1024
- await updateCachedIndexFile(fs, filepath, cache[IndexCache]);
1029
+ const theIndexCache = cache[IndexCache];
1030
+ if (await isIndexStale(fs, filepath, theIndexCache)) {
1031
+ await updateCachedIndexFile(fs, filepath, theIndexCache);
1025
1032
  }
1026
- const index = cache[IndexCache].map.get(filepath);
1033
+ const index = theIndexCache.map.get(filepath);
1027
1034
  unmergedPaths = index.unmergedPaths;
1028
1035
 
1029
1036
  if (unmergedPaths.length && !allowUnmerged)
@@ -1036,7 +1043,7 @@ class GitIndexManager {
1036
1043
  const buffer = await index.toObject();
1037
1044
  await fs.write(filepath, buffer);
1038
1045
  // Update cached stat value
1039
- cache[IndexCache].stats.set(filepath, await fs.lstat(filepath));
1046
+ theIndexCache.stats.set(filepath, await fs.lstat(filepath));
1040
1047
  index._dirty = false;
1041
1048
  }
1042
1049
  });
@@ -4261,7 +4268,7 @@ class GitWalkerFs {
4261
4268
  oid = undefined;
4262
4269
  } else {
4263
4270
  oid = await shasum(
4264
- GitObject.wrap({ type: 'blob', object: await entry.content() })
4271
+ GitObject.wrap({ type: 'blob', object: content })
4265
4272
  );
4266
4273
  // Update the stats in the index so we will get a "cache hit" next time
4267
4274
  // 1) if we can (because the oid and mode are the same)
@@ -4452,15 +4459,20 @@ async function _walk({
4452
4459
  const range = arrayRange(0, walkers.length);
4453
4460
  const unionWalkerFromReaddir = async entries => {
4454
4461
  range.map(i => {
4455
- entries[i] = entries[i] && new walkers[i].ConstructEntry(entries[i]);
4462
+ const entry = entries[i];
4463
+ entries[i] = entry && new walkers[i].ConstructEntry(entry);
4456
4464
  });
4457
4465
  const subdirs = await Promise.all(
4458
- range.map(i => (entries[i] ? walkers[i].readdir(entries[i]) : []))
4466
+ range.map(i => {
4467
+ const entry = entries[i];
4468
+ return entry ? walkers[i].readdir(entry) : []
4469
+ })
4459
4470
  );
4460
4471
  // Now process child directories
4461
- const iterators = subdirs
4462
- .map(array => (array === null ? [] : array))
4463
- .map(array => array[Symbol.iterator]());
4472
+ const iterators = subdirs.map(array => {
4473
+ return (array === null ? [] : array)[Symbol.iterator]()
4474
+ });
4475
+
4464
4476
  return {
4465
4477
  entries,
4466
4478
  children: unionOfIterators(iterators),
@@ -7632,8 +7644,8 @@ function filterCapabilities(server, client) {
7632
7644
 
7633
7645
  const pkg = {
7634
7646
  name: 'isomorphic-git',
7635
- version: '1.30.0',
7636
- agent: 'git/isomorphic-git@1.30.0',
7647
+ version: '1.30.1',
7648
+ agent: 'git/isomorphic-git@1.30.1',
7637
7649
  };
7638
7650
 
7639
7651
  class FIFO {
@@ -15288,11 +15300,9 @@ async function updateIndex({
15288
15300
  return await GitIndexManager.acquire(
15289
15301
  { fs, gitdir, cache },
15290
15302
  async function(index) {
15291
- let fileStats;
15292
-
15293
15303
  if (!force) {
15294
15304
  // Check if the file is still present in the working directory
15295
- fileStats = await fs.lstat(pathBrowserify.join(dir, filepath));
15305
+ const fileStats = await fs.lstat(pathBrowserify.join(dir, filepath));
15296
15306
 
15297
15307
  if (fileStats) {
15298
15308
  if (fileStats.isDirectory()) {
@@ -15342,18 +15352,7 @@ async function updateIndex({
15342
15352
  )
15343
15353
  }
15344
15354
 
15345
- // By default we use 0 for the stats of the index file
15346
- let stats = {
15347
- ctime: new Date(0),
15348
- mtime: new Date(0),
15349
- dev: 0,
15350
- ino: 0,
15351
- mode,
15352
- uid: 0,
15353
- gid: 0,
15354
- size: 0,
15355
- };
15356
-
15355
+ let stats;
15357
15356
  if (!oid) {
15358
15357
  stats = fileStats;
15359
15358
 
@@ -15369,6 +15368,18 @@ async function updateIndex({
15369
15368
  format: 'content',
15370
15369
  object,
15371
15370
  });
15371
+ } else {
15372
+ // By default we use 0 for the stats of the index file
15373
+ stats = {
15374
+ ctime: new Date(0),
15375
+ mtime: new Date(0),
15376
+ dev: 0,
15377
+ ino: 0,
15378
+ mode,
15379
+ uid: 0,
15380
+ gid: 0,
15381
+ size: 0,
15382
+ };
15372
15383
  }
15373
15384
 
15374
15385
  index.insert({
package/index.js CHANGED
@@ -973,8 +973,11 @@ function createCache() {
973
973
  }
974
974
 
975
975
  async function updateCachedIndexFile(fs, filepath, cache) {
976
- const stat = await fs.lstat(filepath);
977
- const rawIndexFile = await fs.read(filepath);
976
+ const [stat, rawIndexFile] = await Promise.all([
977
+ fs.lstat(filepath),
978
+ fs.read(filepath),
979
+ ]);
980
+
978
981
  const index = await GitIndex.from(rawIndexFile);
979
982
  // cache the GitIndex object so we don't need to re-read it every time.
980
983
  cache.map.set(filepath, index);
@@ -986,8 +989,9 @@ async function updateCachedIndexFile(fs, filepath, cache) {
986
989
  async function isIndexStale(fs, filepath, cache) {
987
990
  const savedStats = cache.stats.get(filepath);
988
991
  if (savedStats === undefined) return true
989
- const currStats = await fs.lstat(filepath);
990
992
  if (savedStats === null) return false
993
+
994
+ const currStats = await fs.lstat(filepath);
991
995
  if (currStats === null) return false
992
996
  return compareStats(savedStats, currStats)
993
997
  }
@@ -1003,7 +1007,9 @@ class GitIndexManager {
1003
1007
  * @param {function(GitIndex): any} closure
1004
1008
  */
1005
1009
  static async acquire({ fs, gitdir, cache, allowUnmerged = true }, closure) {
1006
- if (!cache[IndexCache]) cache[IndexCache] = createCache();
1010
+ if (!cache[IndexCache]) {
1011
+ cache[IndexCache] = createCache();
1012
+ }
1007
1013
 
1008
1014
  const filepath = `${gitdir}/index`;
1009
1015
  if (lock === null) lock = new AsyncLock({ maxPending: Infinity });
@@ -1014,10 +1020,11 @@ class GitIndexManager {
1014
1020
  // to make sure other processes aren't writing to it
1015
1021
  // simultaneously, which could result in a corrupted index.
1016
1022
  // const fileLock = await Lock(filepath)
1017
- if (await isIndexStale(fs, filepath, cache[IndexCache])) {
1018
- await updateCachedIndexFile(fs, filepath, cache[IndexCache]);
1023
+ const theIndexCache = cache[IndexCache];
1024
+ if (await isIndexStale(fs, filepath, theIndexCache)) {
1025
+ await updateCachedIndexFile(fs, filepath, theIndexCache);
1019
1026
  }
1020
- const index = cache[IndexCache].map.get(filepath);
1027
+ const index = theIndexCache.map.get(filepath);
1021
1028
  unmergedPaths = index.unmergedPaths;
1022
1029
 
1023
1030
  if (unmergedPaths.length && !allowUnmerged)
@@ -1030,7 +1037,7 @@ class GitIndexManager {
1030
1037
  const buffer = await index.toObject();
1031
1038
  await fs.write(filepath, buffer);
1032
1039
  // Update cached stat value
1033
- cache[IndexCache].stats.set(filepath, await fs.lstat(filepath));
1040
+ theIndexCache.stats.set(filepath, await fs.lstat(filepath));
1034
1041
  index._dirty = false;
1035
1042
  }
1036
1043
  });
@@ -4255,7 +4262,7 @@ class GitWalkerFs {
4255
4262
  oid = undefined;
4256
4263
  } else {
4257
4264
  oid = await shasum(
4258
- GitObject.wrap({ type: 'blob', object: await entry.content() })
4265
+ GitObject.wrap({ type: 'blob', object: content })
4259
4266
  );
4260
4267
  // Update the stats in the index so we will get a "cache hit" next time
4261
4268
  // 1) if we can (because the oid and mode are the same)
@@ -4446,15 +4453,20 @@ async function _walk({
4446
4453
  const range = arrayRange(0, walkers.length);
4447
4454
  const unionWalkerFromReaddir = async entries => {
4448
4455
  range.map(i => {
4449
- entries[i] = entries[i] && new walkers[i].ConstructEntry(entries[i]);
4456
+ const entry = entries[i];
4457
+ entries[i] = entry && new walkers[i].ConstructEntry(entry);
4450
4458
  });
4451
4459
  const subdirs = await Promise.all(
4452
- range.map(i => (entries[i] ? walkers[i].readdir(entries[i]) : []))
4460
+ range.map(i => {
4461
+ const entry = entries[i];
4462
+ return entry ? walkers[i].readdir(entry) : []
4463
+ })
4453
4464
  );
4454
4465
  // Now process child directories
4455
- const iterators = subdirs
4456
- .map(array => (array === null ? [] : array))
4457
- .map(array => array[Symbol.iterator]());
4466
+ const iterators = subdirs.map(array => {
4467
+ return (array === null ? [] : array)[Symbol.iterator]()
4468
+ });
4469
+
4458
4470
  return {
4459
4471
  entries,
4460
4472
  children: unionOfIterators(iterators),
@@ -7626,8 +7638,8 @@ function filterCapabilities(server, client) {
7626
7638
 
7627
7639
  const pkg = {
7628
7640
  name: 'isomorphic-git',
7629
- version: '1.30.0',
7630
- agent: 'git/isomorphic-git@1.30.0',
7641
+ version: '1.30.1',
7642
+ agent: 'git/isomorphic-git@1.30.1',
7631
7643
  };
7632
7644
 
7633
7645
  class FIFO {
@@ -15282,11 +15294,9 @@ async function updateIndex({
15282
15294
  return await GitIndexManager.acquire(
15283
15295
  { fs, gitdir, cache },
15284
15296
  async function(index) {
15285
- let fileStats;
15286
-
15287
15297
  if (!force) {
15288
15298
  // Check if the file is still present in the working directory
15289
- fileStats = await fs.lstat(join(dir, filepath));
15299
+ const fileStats = await fs.lstat(join(dir, filepath));
15290
15300
 
15291
15301
  if (fileStats) {
15292
15302
  if (fileStats.isDirectory()) {
@@ -15336,18 +15346,7 @@ async function updateIndex({
15336
15346
  )
15337
15347
  }
15338
15348
 
15339
- // By default we use 0 for the stats of the index file
15340
- let stats = {
15341
- ctime: new Date(0),
15342
- mtime: new Date(0),
15343
- dev: 0,
15344
- ino: 0,
15345
- mode,
15346
- uid: 0,
15347
- gid: 0,
15348
- size: 0,
15349
- };
15350
-
15349
+ let stats;
15351
15350
  if (!oid) {
15352
15351
  stats = fileStats;
15353
15352
 
@@ -15363,6 +15362,18 @@ async function updateIndex({
15363
15362
  format: 'content',
15364
15363
  object,
15365
15364
  });
15365
+ } else {
15366
+ // By default we use 0 for the stats of the index file
15367
+ stats = {
15368
+ ctime: new Date(0),
15369
+ mtime: new Date(0),
15370
+ dev: 0,
15371
+ ino: 0,
15372
+ mode,
15373
+ uid: 0,
15374
+ gid: 0,
15375
+ size: 0,
15376
+ };
15366
15377
  }
15367
15378
 
15368
15379
  index.insert({