isomorphic-git 1.29.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.
package/README.md CHANGED
@@ -17,7 +17,7 @@ By providing functionality as individual functions, code bundlers can produce sm
17
17
  The project includes type definitions so you can enjoy static type-checking and intelligent code completion in editors like VS Code and [CodeSandbox](https://codesandbox.io).
18
18
 
19
19
  ## Project status
20
- The original author of the project ([Billie Hilton](https://github.com/wmhilton)) left the project, but the project is still maintained by two volunteers:
20
+ The original author of the project ([Billie Hilton](https://github.com/billiegoose)) left the project, but the project is still maintained by two volunteers:
21
21
 
22
22
  * [@jcubic](https://github.com/jcubic) (most active)
23
23
  * [@mojavelinux](https://github.com/mojavelinux)
@@ -114,14 +114,14 @@ Unfortunately, due to the same-origin policy by default `isomorphic-git` can onl
114
114
  For this purpose [@isomorphic-git/cors-proxy](https://github.com/isomorphic-git/cors-proxy) exists which you can clone or [`npm install`](https://www.npmjs.com/package/@isomorphic-git/cors-proxy).
115
115
  For testing or small projects, you can also use [https://cors.isomorphic-git.org](https://cors.isomorphic-git.org) - a free proxy sponsored by [Clever Cloud](https://www.clever-cloud.com/?utm_source=ref&utm_medium=link&utm_campaign=isomorphic-git).
116
116
 
117
- I'm hoping to get CORS headers added to all the major Git hosting platforms eventually, and will list my progress here:
117
+ We hope to get CORS headers added to all the major Git hosting platforms eventually, and will list the progress made here:
118
118
 
119
119
  | Service | Supports CORS requests |
120
120
  | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
121
121
  | Gogs (self-hosted) | [✔](https://isomorphic-git.github.io/blog/2018/04/07/gogs-adds-cors-headers-for-isomorphic-git.html) |
122
122
  | Gitea (self-hosted) | [✔](https://github.com/go-gitea/gitea/pull/5719) |
123
123
  | Azure DevOps | [✔](https://github.com/isomorphic-git/isomorphic-git/issues/678#issuecomment-452402740) (Usage Note: requires authentication) |
124
- | Gitlab | ❌ My [PR](https://gitlab.com/gitlab-org/gitlab-workhorse/merge_requests/219) was rejected, but the [issue](https://gitlab.com/gitlab-org/gitlab/issues/20590) is still open! |
124
+ | Gitlab | ❌ Our [PR](https://gitlab.com/gitlab-org/gitlab-workhorse/merge_requests/219) was rejected, but the [issue](https://gitlab.com/gitlab-org/gitlab/issues/20590) is still open! |
125
125
  | Bitbucket | ❌ |
126
126
  | Github | ❌ |
127
127
 
@@ -140,7 +140,7 @@ The CLI is more of a lark for quickly testing `isomorphic-git` and isn't really
140
140
 
141
141
  ## Supported Git commands
142
142
 
143
- This project follows semantic versioning, so I may continue to make changes to the API but they will always be backwards compatible
143
+ This project follows semantic versioning, so we may continue to make changes to the API but they will always be backwards compatible
144
144
  unless there is a major version bump.
145
145
 
146
146
  ### commands
@@ -267,7 +267,7 @@ Check out the [`CONTRIBUTING`](./CONTRIBUTING.md) document for more instructions
267
267
 
268
268
  Isomorphic-git would not have been possible without the pioneering work by
269
269
  @creationix and @chrisdickinson. Git is a tricky binary mess, and without
270
- their examples (and their modules!) I would not have been able to come even
270
+ their examples (and their modules!) we would not have been able to come even
271
271
  close to finishing this. They are geniuses ahead of their time.
272
272
 
273
273
  Cross-browser device testing is provided by:
@@ -374,7 +374,7 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
374
374
  <td align="center"><a href="http://www.codeproject.com/script/Articles/MemberArticles.aspx?amid=62372"><img src="https://avatars.githubusercontent.com/u/865809?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Modesty Zhang</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=modesty" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=modesty" title="Documentation">📖</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=modesty" title="Tests">⚠️</a></td>
375
375
  <td align="center"><a href="https://github.com/amrc-benmorrow"><img src="https://avatars.githubusercontent.com/u/120477944?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Ben Morrow</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=amrc-benmorrow" title="Code">💻</a></td>
376
376
  </tr>
377
- <tr>
377
+ <tr>
378
378
  <td align="center"><a href="https://github.com/jayree"><img src="https://avatars.githubusercontent.com/u/14836154?v=4?s=60" width="60px;" alt=""/><br /><sub><b>jayree</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=jayree" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=jayree" title="Tests">⚠️</a></td>
379
379
  <td align="center"><a href="https://github.com/lsegurado"><img src="https://avatars.githubusercontent.com/u/27731047?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Lucas Martin Segurado</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=lsegurado" title="Documentation">📖</a> <a href="https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Alsegurado" title="Bug reports">🐛</a></td>
380
380
  <td align="center"><a href="https://github.com/limond"><img src="https://avatars.githubusercontent.com/u/1025682?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Leon Kaucher</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=limond" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=limond" title="Tests">⚠️</a></td>
@@ -383,6 +383,9 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
383
383
  <td align="center"><a href="https://github.com/Vinzent03"><img src="https://avatars.githubusercontent.com/u/63981639?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Vinzent</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=Vinzent03" title="Code">💻</a></td>
384
384
  <td align="center"><a href="https://github.com/LokiMidgard"><img src="https://avatars.githubusercontent.com/u/389101?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Patrick Kranz</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=LokiMidgard" title="Code">💻</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=LokiMidgard" title="Documentation">📖</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=LokiMidgard" title="Tests">⚠️</a></td>
385
385
  </tr>
386
+ <tr>
387
+ <td align="center"><a href="https://github.com/lukecotter"><img src="https://avatars.githubusercontent.com/u/4013877?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Luke Cotter</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=lukecotter" title="Code">💻</a></td>
388
+ </tr>
386
389
  </table>
387
390
 
388
391
  <!-- markdownlint-restore -->
@@ -1,11 +1,10 @@
1
1
  [
2
2
  "Chrome Headless 79.0.3945.0 (Linux x86_64)",
3
- "X Firefox 132.0 (Ubuntu 0.0.0)",
3
+ "Firefox 136.0 (Ubuntu 0.0.0)",
4
4
  "X Chrome 128.0.0.0 (Android 10)",
5
5
  "Edge 79.0.309.65 (Windows 10)",
6
- "Mobile Safari 13.0 (iOS 13.0)",
7
- "Safari 13.1 (Mac OS 10.15.4)",
6
+ "Mobile Safari 14.0 (iOS 14.0.1)",
7
+ "Safari 14.1 (Mac OS 10.15.7)",
8
8
  "Chrome Headless 79.0.3945.0 (Linux x86_64)",
9
- "Firefox 132.0 (Ubuntu 0.0.0)",
10
9
  "Chrome 128.0.0.0 (Android 10)"
11
10
  ]
@@ -13,13 +13,13 @@ export type GitHttpRequest = {
13
13
  /**
14
14
  * - The HTTP method to use
15
15
  */
16
- method?: string;
16
+ method?: string | undefined;
17
17
  /**
18
18
  * - Headers to include in the HTTP request
19
19
  */
20
20
  headers?: {
21
21
  [x: string]: string;
22
- };
22
+ } | undefined;
23
23
  /**
24
24
  * - An HTTP or HTTPS agent that manages connections for the HTTP client (Node.js only)
25
25
  */
@@ -27,15 +27,15 @@ export type GitHttpRequest = {
27
27
  /**
28
28
  * - An async iterator of Uint8Arrays that make up the body of POST requests
29
29
  */
30
- body?: any;
30
+ body?: AsyncIterableIterator<Uint8Array>;
31
31
  /**
32
32
  * - Reserved for future use (emitting `GitProgressEvent`s)
33
33
  */
34
- onProgress?: ProgressCallback;
34
+ onProgress?: ProgressCallback | undefined;
35
35
  /**
36
36
  * - Reserved for future use (canceling a request)
37
37
  */
38
- signal?: any;
38
+ signal?: object;
39
39
  };
40
40
  export type GitHttpResponse = {
41
41
  /**
@@ -45,17 +45,17 @@ export type GitHttpResponse = {
45
45
  /**
46
46
  * - The HTTP method that was used
47
47
  */
48
- method?: string;
48
+ method?: string | undefined;
49
49
  /**
50
50
  * - HTTP response headers
51
51
  */
52
52
  headers?: {
53
53
  [x: string]: string;
54
- };
54
+ } | undefined;
55
55
  /**
56
56
  * - An async iterator of Uint8Arrays that make up the body of the response
57
57
  */
58
- body?: any;
58
+ body?: AsyncIterableIterator<Uint8Array>;
59
59
  /**
60
60
  * - The HTTP status code
61
61
  */
@@ -13,13 +13,13 @@ export type GitHttpRequest = {
13
13
  /**
14
14
  * - The HTTP method to use
15
15
  */
16
- method?: string;
16
+ method?: string | undefined;
17
17
  /**
18
18
  * - Headers to include in the HTTP request
19
19
  */
20
20
  headers?: {
21
21
  [x: string]: string;
22
- };
22
+ } | undefined;
23
23
  /**
24
24
  * - An HTTP or HTTPS agent that manages connections for the HTTP client (Node.js only)
25
25
  */
@@ -27,15 +27,15 @@ export type GitHttpRequest = {
27
27
  /**
28
28
  * - An async iterator of Uint8Arrays that make up the body of POST requests
29
29
  */
30
- body?: any;
30
+ body?: AsyncIterableIterator<Uint8Array>;
31
31
  /**
32
32
  * - Reserved for future use (emitting `GitProgressEvent`s)
33
33
  */
34
- onProgress?: ProgressCallback;
34
+ onProgress?: ProgressCallback | undefined;
35
35
  /**
36
36
  * - Reserved for future use (canceling a request)
37
37
  */
38
- signal?: any;
38
+ signal?: object;
39
39
  };
40
40
  export type GitHttpResponse = {
41
41
  /**
@@ -45,17 +45,17 @@ export type GitHttpResponse = {
45
45
  /**
46
46
  * - The HTTP method that was used
47
47
  */
48
- method?: string;
48
+ method?: string | undefined;
49
49
  /**
50
50
  * - HTTP response headers
51
51
  */
52
52
  headers?: {
53
53
  [x: string]: string;
54
- };
54
+ } | undefined;
55
55
  /**
56
56
  * - An async iterator of Uint8Arrays that make up the body of the response
57
57
  */
58
- body?: any;
58
+ body?: AsyncIterableIterator<Uint8Array>;
59
59
  /**
60
60
  * - The HTTP status code
61
61
  */
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
  });
@@ -1489,6 +1496,10 @@ function compareRefNames(a, b) {
1489
1496
 
1490
1497
  // This is straight from parse_unit_factor in config.c of canonical git
1491
1498
  const num = val => {
1499
+ if (typeof val === 'number') {
1500
+ return val
1501
+ }
1502
+
1492
1503
  val = val.toLowerCase();
1493
1504
  let n = parseInt(val);
1494
1505
  if (val.endsWith('k')) n *= 1024;
@@ -1499,6 +1510,10 @@ const num = val => {
1499
1510
 
1500
1511
  // This is straight from git_parse_maybe_bool_text in config.c of canonical git
1501
1512
  const bool = val => {
1513
+ if (typeof val === 'boolean') {
1514
+ return val
1515
+ }
1516
+
1502
1517
  val = val.trim().toLowerCase();
1503
1518
  if (val === 'true' || val === 'yes' || val === 'on') return true
1504
1519
  if (val === 'false' || val === 'no' || val === 'off') return false
@@ -1614,6 +1629,7 @@ const normalizePath = path => {
1614
1629
  name,
1615
1630
  path: getPath(section, subsection, name),
1616
1631
  sectionPath: getPath(section, subsection, null),
1632
+ isSection: !!section,
1617
1633
  }
1618
1634
  };
1619
1635
 
@@ -1674,7 +1690,7 @@ class GitConfig {
1674
1690
 
1675
1691
  async getSubsections(section) {
1676
1692
  return this.parsedConfig
1677
- .filter(config => config.section === section && config.isSection)
1693
+ .filter(config => config.isSection && config.section === section)
1678
1694
  .map(config => config.subsection)
1679
1695
  }
1680
1696
 
@@ -1696,7 +1712,9 @@ class GitConfig {
1696
1712
  name,
1697
1713
  path: normalizedPath,
1698
1714
  sectionPath,
1715
+ isSection,
1699
1716
  } = normalizePath(path);
1717
+
1700
1718
  const configIndex = findLastIndex(
1701
1719
  this.parsedConfig,
1702
1720
  config => config.path === normalizedPath
@@ -1738,6 +1756,7 @@ class GitConfig {
1738
1756
  } else {
1739
1757
  // Add a new section
1740
1758
  const newSection = {
1759
+ isSection,
1741
1760
  section,
1742
1761
  subsection,
1743
1762
  modified: true,
@@ -4124,6 +4143,8 @@ class GitWalkerFs {
4124
4143
  this.cache = cache;
4125
4144
  this.dir = dir;
4126
4145
  this.gitdir = gitdir;
4146
+
4147
+ this.config = null;
4127
4148
  const walker = this;
4128
4149
  this.ConstructEntry = class WorkdirEntry {
4129
4150
  constructor(fullpath) {
@@ -4210,7 +4231,7 @@ class GitWalkerFs {
4210
4231
  if ((await entry.type()) === 'tree') {
4211
4232
  entry._content = undefined;
4212
4233
  } else {
4213
- const config = await GitConfigManager.get({ fs, gitdir });
4234
+ const config = await this._getGitConfig(fs, gitdir);
4214
4235
  const autocrlf = await config.get('core.autocrlf');
4215
4236
  const content = await fs.read(`${dir}/${entry._fullpath}`, { autocrlf });
4216
4237
  // workaround for a BrowserFS edge case
@@ -4226,6 +4247,7 @@ class GitWalkerFs {
4226
4247
 
4227
4248
  async oid(entry) {
4228
4249
  if (entry._oid === false) {
4250
+ const self = this;
4229
4251
  const { fs, gitdir, cache } = this;
4230
4252
  let oid;
4231
4253
  // See if we can use the SHA1 hash in the index.
@@ -4234,7 +4256,7 @@ class GitWalkerFs {
4234
4256
  ) {
4235
4257
  const stage = index.entriesMap.get(entry._fullpath);
4236
4258
  const stats = await entry.stat();
4237
- const config = await GitConfigManager.get({ fs, gitdir });
4259
+ const config = await self._getGitConfig(fs, gitdir);
4238
4260
  const filemode = await config.get('core.filemode');
4239
4261
  const trustino =
4240
4262
  typeof process !== 'undefined'
@@ -4246,7 +4268,7 @@ class GitWalkerFs {
4246
4268
  oid = undefined;
4247
4269
  } else {
4248
4270
  oid = await shasum(
4249
- GitObject.wrap({ type: 'blob', object: await entry.content() })
4271
+ GitObject.wrap({ type: 'blob', object: content })
4250
4272
  );
4251
4273
  // Update the stats in the index so we will get a "cache hit" next time
4252
4274
  // 1) if we can (because the oid and mode are the same)
@@ -4273,6 +4295,14 @@ class GitWalkerFs {
4273
4295
  }
4274
4296
  return entry._oid
4275
4297
  }
4298
+
4299
+ async _getGitConfig(fs, gitdir) {
4300
+ if (this.config) {
4301
+ return this.config
4302
+ }
4303
+ this.config = await GitConfigManager.get({ fs, gitdir });
4304
+ return this.config
4305
+ }
4276
4306
  }
4277
4307
 
4278
4308
  // @ts-check
@@ -4429,15 +4459,20 @@ async function _walk({
4429
4459
  const range = arrayRange(0, walkers.length);
4430
4460
  const unionWalkerFromReaddir = async entries => {
4431
4461
  range.map(i => {
4432
- entries[i] = entries[i] && new walkers[i].ConstructEntry(entries[i]);
4462
+ const entry = entries[i];
4463
+ entries[i] = entry && new walkers[i].ConstructEntry(entry);
4433
4464
  });
4434
4465
  const subdirs = await Promise.all(
4435
- 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
+ })
4436
4470
  );
4437
4471
  // Now process child directories
4438
- const iterators = subdirs
4439
- .map(array => (array === null ? [] : array))
4440
- .map(array => array[Symbol.iterator]());
4472
+ const iterators = subdirs.map(array => {
4473
+ return (array === null ? [] : array)[Symbol.iterator]()
4474
+ });
4475
+
4441
4476
  return {
4442
4477
  entries,
4443
4478
  children: unionOfIterators(iterators),
@@ -5066,6 +5101,8 @@ async function add({
5066
5101
 
5067
5102
  const fs = new FileSystem(_fs);
5068
5103
  await GitIndexManager.acquire({ fs, gitdir, cache }, async index => {
5104
+ const config = await GitConfigManager.get({ fs, gitdir });
5105
+ const autocrlf = await config.get('core.autocrlf');
5069
5106
  return addToIndex({
5070
5107
  dir,
5071
5108
  gitdir,
@@ -5074,6 +5111,7 @@ async function add({
5074
5111
  index,
5075
5112
  force,
5076
5113
  parallel,
5114
+ autocrlf,
5077
5115
  })
5078
5116
  });
5079
5117
  } catch (err) {
@@ -5090,6 +5128,7 @@ async function addToIndex({
5090
5128
  index,
5091
5129
  force,
5092
5130
  parallel,
5131
+ autocrlf,
5093
5132
  }) {
5094
5133
  // TODO: Should ignore UNLESS it's already in the index.
5095
5134
  filepath = Array.isArray(filepath) ? filepath : [filepath];
@@ -5118,6 +5157,7 @@ async function addToIndex({
5118
5157
  index,
5119
5158
  force,
5120
5159
  parallel,
5160
+ autocrlf,
5121
5161
  })
5122
5162
  );
5123
5163
  await Promise.all(promises);
@@ -5131,12 +5171,11 @@ async function addToIndex({
5131
5171
  index,
5132
5172
  force,
5133
5173
  parallel,
5174
+ autocrlf,
5134
5175
  });
5135
5176
  }
5136
5177
  }
5137
5178
  } else {
5138
- const config = await GitConfigManager.get({ fs, gitdir });
5139
- const autocrlf = await config.get('core.autocrlf');
5140
5179
  const object = stats.isSymbolicLink()
5141
5180
  ? await fs.readlink(pathBrowserify.join(dir, currentFilepath)).then(posixifyPathBuffer)
5142
5181
  : await fs.read(pathBrowserify.join(dir, currentFilepath), { autocrlf });
@@ -7605,8 +7644,8 @@ function filterCapabilities(server, client) {
7605
7644
 
7606
7645
  const pkg = {
7607
7646
  name: 'isomorphic-git',
7608
- version: '1.29.0',
7609
- agent: 'git/isomorphic-git@1.29.0',
7647
+ version: '1.30.1',
7648
+ agent: 'git/isomorphic-git@1.30.1',
7610
7649
  };
7611
7650
 
7612
7651
  class FIFO {
@@ -15261,11 +15300,9 @@ async function updateIndex({
15261
15300
  return await GitIndexManager.acquire(
15262
15301
  { fs, gitdir, cache },
15263
15302
  async function(index) {
15264
- let fileStats;
15265
-
15266
15303
  if (!force) {
15267
15304
  // Check if the file is still present in the working directory
15268
- fileStats = await fs.lstat(pathBrowserify.join(dir, filepath));
15305
+ const fileStats = await fs.lstat(pathBrowserify.join(dir, filepath));
15269
15306
 
15270
15307
  if (fileStats) {
15271
15308
  if (fileStats.isDirectory()) {
@@ -15315,18 +15352,7 @@ async function updateIndex({
15315
15352
  )
15316
15353
  }
15317
15354
 
15318
- // By default we use 0 for the stats of the index file
15319
- let stats = {
15320
- ctime: new Date(0),
15321
- mtime: new Date(0),
15322
- dev: 0,
15323
- ino: 0,
15324
- mode,
15325
- uid: 0,
15326
- gid: 0,
15327
- size: 0,
15328
- };
15329
-
15355
+ let stats;
15330
15356
  if (!oid) {
15331
15357
  stats = fileStats;
15332
15358
 
@@ -15342,6 +15368,18 @@ async function updateIndex({
15342
15368
  format: 'content',
15343
15369
  object,
15344
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
+ };
15345
15383
  }
15346
15384
 
15347
15385
  index.insert({