isomorphic-git 1.15.0 → 1.16.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.
@@ -1,8 +1,8 @@
1
1
  [
2
2
  "HeadlessChrome 0.0.0 (Linux 0.0.0)",
3
- "Firefox 97.0.0 (Ubuntu 0.0.0)",
3
+ "Firefox 98.0.0 (Ubuntu 0.0.0)",
4
4
  "Chrome Mobile 96.0.4664 (Android 0.0.0)",
5
5
  "Chrome 79.0.3945 (Windows 10 0.0.0)",
6
- "Mobile Safari 13.0.0 (iOS 13.0.0)",
7
- "Safari 13.1.0 (Mac OS X 10.15.4)"
6
+ "Safari 13.1.0 (Mac OS X 10.15.4)",
7
+ "Mobile Safari 13.0.0 (iOS 13.0.0)"
8
8
  ]
package/index.cjs CHANGED
@@ -4447,6 +4447,7 @@ function assertParameter(name, value) {
4447
4447
  * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
4448
4448
  * @param {string|string[]} args.filepath - The path to the file to add to the index
4449
4449
  * @param {object} [args.cache] - a [cache](cache.md) object
4450
+ * @param {boolean} [args.force=false] - add to index even if matches gitignore. Think `git add --force`
4450
4451
  *
4451
4452
  * @returns {Promise<void>} Resolves successfully once the git index has been updated
4452
4453
  *
@@ -4462,6 +4463,7 @@ async function add({
4462
4463
  gitdir = join(dir, '.git'),
4463
4464
  filepath,
4464
4465
  cache = {},
4466
+ force = false,
4465
4467
  }) {
4466
4468
  try {
4467
4469
  assertParameter('fs', _fs);
@@ -4471,7 +4473,7 @@ async function add({
4471
4473
 
4472
4474
  const fs = new FileSystem(_fs);
4473
4475
  await GitIndexManager.acquire({ fs, gitdir, cache }, async index => {
4474
- return addToIndex({ dir, gitdir, fs, filepath, index })
4476
+ return addToIndex({ dir, gitdir, fs, filepath, index, force })
4475
4477
  });
4476
4478
  } catch (err) {
4477
4479
  err.caller = 'git.add';
@@ -4479,17 +4481,19 @@ async function add({
4479
4481
  }
4480
4482
  }
4481
4483
 
4482
- async function addToIndex({ dir, gitdir, fs, filepath, index }) {
4484
+ async function addToIndex({ dir, gitdir, fs, filepath, index, force }) {
4483
4485
  // TODO: Should ignore UNLESS it's already in the index.
4484
4486
  filepath = Array.isArray(filepath) ? filepath : [filepath];
4485
4487
  const promises = filepath.map(async currentFilepath => {
4486
- const ignored = await GitIgnoreManager.isIgnored({
4487
- fs,
4488
- dir,
4489
- gitdir,
4490
- filepath: currentFilepath,
4491
- });
4492
- if (ignored) return
4488
+ if (!force) {
4489
+ const ignored = await GitIgnoreManager.isIgnored({
4490
+ fs,
4491
+ dir,
4492
+ gitdir,
4493
+ filepath: currentFilepath,
4494
+ });
4495
+ if (ignored) return
4496
+ }
4493
4497
  const stats = await fs.lstat(join(dir, currentFilepath));
4494
4498
  if (!stats) throw new NotFoundError(currentFilepath)
4495
4499
 
@@ -4502,6 +4506,7 @@ async function addToIndex({ dir, gitdir, fs, filepath, index }) {
4502
4506
  fs,
4503
4507
  filepath: [join(currentFilepath, child)],
4504
4508
  index,
4509
+ force,
4505
4510
  })
4506
4511
  );
4507
4512
  await Promise.all(promises);
@@ -6918,8 +6923,8 @@ function filterCapabilities(server, client) {
6918
6923
 
6919
6924
  const pkg = {
6920
6925
  name: 'isomorphic-git',
6921
- version: '1.15.0',
6922
- agent: 'git/isomorphic-git@1.15.0',
6926
+ version: '1.16.0',
6927
+ agent: 'git/isomorphic-git@1.16.0',
6923
6928
  };
6924
6929
 
6925
6930
  class FIFO {
@@ -13342,6 +13347,7 @@ async function getHeadTree({ fs, cache, gitdir }) {
13342
13347
  * @param {string[]} [args.filepaths = ['.']] - Limit the query to the given files and directories
13343
13348
  * @param {function(string): boolean} [args.filter] - Filter the results to only those whose filepath matches a function.
13344
13349
  * @param {object} [args.cache] - a [cache](cache.md) object
13350
+ * @param {boolean} [args.ignored = false] - include ignored files in the result
13345
13351
  *
13346
13352
  * @returns {Promise<Array<StatusRow>>} Resolves with a status matrix, described below.
13347
13353
  * @see StatusRow
@@ -13354,6 +13360,7 @@ async function statusMatrix({
13354
13360
  filepaths = ['.'],
13355
13361
  filter,
13356
13362
  cache = {},
13363
+ ignored: shouldIgnore = false,
13357
13364
  }) {
13358
13365
  try {
13359
13366
  assertParameter('fs', _fs);
@@ -13370,14 +13377,15 @@ async function statusMatrix({
13370
13377
  map: async function(filepath, [head, workdir, stage]) {
13371
13378
  // Ignore ignored files, but only if they are not already tracked.
13372
13379
  if (!head && !stage && workdir) {
13373
- if (
13374
- await GitIgnoreManager.isIgnored({
13380
+ if (!shouldIgnore) {
13381
+ const isIgnored = await GitIgnoreManager.isIgnored({
13375
13382
  fs,
13376
13383
  dir,
13377
13384
  filepath,
13378
- })
13379
- ) {
13380
- return null
13385
+ });
13386
+ if (isIgnored) {
13387
+ return null
13388
+ }
13381
13389
  }
13382
13390
  }
13383
13391
  // match against base paths
@@ -13566,15 +13574,22 @@ async function updateIndex({
13566
13574
  fileStats = await fs.lstat(join(dir, filepath));
13567
13575
 
13568
13576
  if (fileStats) {
13577
+ if (fileStats.isDirectory()) {
13578
+ // Removing directories should not work
13579
+ throw new InvalidFilepathError('directory')
13580
+ }
13581
+
13569
13582
  // Do nothing if we don't force and the file still exists in the workdir
13570
13583
  return
13571
13584
  }
13572
13585
  }
13573
13586
 
13574
- // Remove the file from the index if it's forced or the file does not exist
13575
- index.delete({
13576
- filepath,
13577
- });
13587
+ // Directories are not allowed, so we make sure the provided filepath exists in the index
13588
+ if (index.has({ filepath })) {
13589
+ index.delete({
13590
+ filepath,
13591
+ });
13592
+ }
13578
13593
  }
13579
13594
  )
13580
13595
  }
package/index.d.ts CHANGED
@@ -754,6 +754,7 @@ export function WORKDIR(): Walker;
754
754
  * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
755
755
  * @param {string|string[]} args.filepath - The path to the file to add to the index
756
756
  * @param {object} [args.cache] - a [cache](cache.md) object
757
+ * @param {boolean} [args.force=false] - add to index even if matches gitignore. Think `git add --force`
757
758
  *
758
759
  * @returns {Promise<void>} Resolves successfully once the git index has been updated
759
760
  *
@@ -763,12 +764,13 @@ export function WORKDIR(): Walker;
763
764
  * console.log('done')
764
765
  *
765
766
  */
766
- export function add({ fs: _fs, dir, gitdir, filepath, cache, }: {
767
+ export function add({ fs: _fs, dir, gitdir, filepath, cache, force, }: {
767
768
  fs: CallbackFsClient | PromiseFsClient;
768
769
  dir: string;
769
770
  gitdir?: string;
770
771
  filepath: string | string[];
771
772
  cache?: any;
773
+ force?: boolean;
772
774
  }): Promise<void>;
773
775
  /**
774
776
  * Add or update an object note
@@ -3069,11 +3071,12 @@ export function status({ fs: _fs, dir, gitdir, filepath, cache, }: {
3069
3071
  * @param {string[]} [args.filepaths = ['.']] - Limit the query to the given files and directories
3070
3072
  * @param {function(string): boolean} [args.filter] - Filter the results to only those whose filepath matches a function.
3071
3073
  * @param {object} [args.cache] - a [cache](cache.md) object
3074
+ * @param {boolean} [args.ignored = false] - include ignored files in the result
3072
3075
  *
3073
3076
  * @returns {Promise<Array<StatusRow>>} Resolves with a status matrix, described below.
3074
3077
  * @see StatusRow
3075
3078
  */
3076
- export function statusMatrix({ fs: _fs, dir, gitdir, ref, filepaths, filter, cache, }: {
3079
+ export function statusMatrix({ fs: _fs, dir, gitdir, ref, filepaths, filter, cache, ignored: shouldIgnore, }: {
3077
3080
  fs: CallbackFsClient | PromiseFsClient;
3078
3081
  dir: string;
3079
3082
  gitdir?: string;
@@ -3081,6 +3084,7 @@ export function statusMatrix({ fs: _fs, dir, gitdir, ref, filepaths, filter, cac
3081
3084
  filepaths?: string[];
3082
3085
  filter?: (arg0: string) => boolean;
3083
3086
  cache?: any;
3087
+ ignored?: boolean;
3084
3088
  }): Promise<[string, 0 | 1, 0 | 1 | 2, 0 | 1 | 2 | 3][]>;
3085
3089
  /**
3086
3090
  * Create a lightweight tag
package/index.js CHANGED
@@ -4441,6 +4441,7 @@ function assertParameter(name, value) {
4441
4441
  * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
4442
4442
  * @param {string|string[]} args.filepath - The path to the file to add to the index
4443
4443
  * @param {object} [args.cache] - a [cache](cache.md) object
4444
+ * @param {boolean} [args.force=false] - add to index even if matches gitignore. Think `git add --force`
4444
4445
  *
4445
4446
  * @returns {Promise<void>} Resolves successfully once the git index has been updated
4446
4447
  *
@@ -4456,6 +4457,7 @@ async function add({
4456
4457
  gitdir = join(dir, '.git'),
4457
4458
  filepath,
4458
4459
  cache = {},
4460
+ force = false,
4459
4461
  }) {
4460
4462
  try {
4461
4463
  assertParameter('fs', _fs);
@@ -4465,7 +4467,7 @@ async function add({
4465
4467
 
4466
4468
  const fs = new FileSystem(_fs);
4467
4469
  await GitIndexManager.acquire({ fs, gitdir, cache }, async index => {
4468
- return addToIndex({ dir, gitdir, fs, filepath, index })
4470
+ return addToIndex({ dir, gitdir, fs, filepath, index, force })
4469
4471
  });
4470
4472
  } catch (err) {
4471
4473
  err.caller = 'git.add';
@@ -4473,17 +4475,19 @@ async function add({
4473
4475
  }
4474
4476
  }
4475
4477
 
4476
- async function addToIndex({ dir, gitdir, fs, filepath, index }) {
4478
+ async function addToIndex({ dir, gitdir, fs, filepath, index, force }) {
4477
4479
  // TODO: Should ignore UNLESS it's already in the index.
4478
4480
  filepath = Array.isArray(filepath) ? filepath : [filepath];
4479
4481
  const promises = filepath.map(async currentFilepath => {
4480
- const ignored = await GitIgnoreManager.isIgnored({
4481
- fs,
4482
- dir,
4483
- gitdir,
4484
- filepath: currentFilepath,
4485
- });
4486
- if (ignored) return
4482
+ if (!force) {
4483
+ const ignored = await GitIgnoreManager.isIgnored({
4484
+ fs,
4485
+ dir,
4486
+ gitdir,
4487
+ filepath: currentFilepath,
4488
+ });
4489
+ if (ignored) return
4490
+ }
4487
4491
  const stats = await fs.lstat(join(dir, currentFilepath));
4488
4492
  if (!stats) throw new NotFoundError(currentFilepath)
4489
4493
 
@@ -4496,6 +4500,7 @@ async function addToIndex({ dir, gitdir, fs, filepath, index }) {
4496
4500
  fs,
4497
4501
  filepath: [join(currentFilepath, child)],
4498
4502
  index,
4503
+ force,
4499
4504
  })
4500
4505
  );
4501
4506
  await Promise.all(promises);
@@ -6912,8 +6917,8 @@ function filterCapabilities(server, client) {
6912
6917
 
6913
6918
  const pkg = {
6914
6919
  name: 'isomorphic-git',
6915
- version: '1.15.0',
6916
- agent: 'git/isomorphic-git@1.15.0',
6920
+ version: '1.16.0',
6921
+ agent: 'git/isomorphic-git@1.16.0',
6917
6922
  };
6918
6923
 
6919
6924
  class FIFO {
@@ -13336,6 +13341,7 @@ async function getHeadTree({ fs, cache, gitdir }) {
13336
13341
  * @param {string[]} [args.filepaths = ['.']] - Limit the query to the given files and directories
13337
13342
  * @param {function(string): boolean} [args.filter] - Filter the results to only those whose filepath matches a function.
13338
13343
  * @param {object} [args.cache] - a [cache](cache.md) object
13344
+ * @param {boolean} [args.ignored = false] - include ignored files in the result
13339
13345
  *
13340
13346
  * @returns {Promise<Array<StatusRow>>} Resolves with a status matrix, described below.
13341
13347
  * @see StatusRow
@@ -13348,6 +13354,7 @@ async function statusMatrix({
13348
13354
  filepaths = ['.'],
13349
13355
  filter,
13350
13356
  cache = {},
13357
+ ignored: shouldIgnore = false,
13351
13358
  }) {
13352
13359
  try {
13353
13360
  assertParameter('fs', _fs);
@@ -13364,14 +13371,15 @@ async function statusMatrix({
13364
13371
  map: async function(filepath, [head, workdir, stage]) {
13365
13372
  // Ignore ignored files, but only if they are not already tracked.
13366
13373
  if (!head && !stage && workdir) {
13367
- if (
13368
- await GitIgnoreManager.isIgnored({
13374
+ if (!shouldIgnore) {
13375
+ const isIgnored = await GitIgnoreManager.isIgnored({
13369
13376
  fs,
13370
13377
  dir,
13371
13378
  filepath,
13372
- })
13373
- ) {
13374
- return null
13379
+ });
13380
+ if (isIgnored) {
13381
+ return null
13382
+ }
13375
13383
  }
13376
13384
  }
13377
13385
  // match against base paths
@@ -13560,15 +13568,22 @@ async function updateIndex({
13560
13568
  fileStats = await fs.lstat(join(dir, filepath));
13561
13569
 
13562
13570
  if (fileStats) {
13571
+ if (fileStats.isDirectory()) {
13572
+ // Removing directories should not work
13573
+ throw new InvalidFilepathError('directory')
13574
+ }
13575
+
13563
13576
  // Do nothing if we don't force and the file still exists in the workdir
13564
13577
  return
13565
13578
  }
13566
13579
  }
13567
13580
 
13568
- // Remove the file from the index if it's forced or the file does not exist
13569
- index.delete({
13570
- filepath,
13571
- });
13581
+ // Directories are not allowed, so we make sure the provided filepath exists in the index
13582
+ if (index.has({ filepath })) {
13583
+ index.delete({
13584
+ filepath,
13585
+ });
13586
+ }
13572
13587
  }
13573
13588
  )
13574
13589
  }
@@ -754,6 +754,7 @@ export function WORKDIR(): Walker;
754
754
  * @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
755
755
  * @param {string|string[]} args.filepath - The path to the file to add to the index
756
756
  * @param {object} [args.cache] - a [cache](cache.md) object
757
+ * @param {boolean} [args.force=false] - add to index even if matches gitignore. Think `git add --force`
757
758
  *
758
759
  * @returns {Promise<void>} Resolves successfully once the git index has been updated
759
760
  *
@@ -763,12 +764,13 @@ export function WORKDIR(): Walker;
763
764
  * console.log('done')
764
765
  *
765
766
  */
766
- export function add({ fs: _fs, dir, gitdir, filepath, cache, }: {
767
+ export function add({ fs: _fs, dir, gitdir, filepath, cache, force, }: {
767
768
  fs: CallbackFsClient | PromiseFsClient;
768
769
  dir: string;
769
770
  gitdir?: string;
770
771
  filepath: string | string[];
771
772
  cache?: any;
773
+ force?: boolean;
772
774
  }): Promise<void>;
773
775
  /**
774
776
  * Add or update an object note
@@ -3069,11 +3071,12 @@ export function status({ fs: _fs, dir, gitdir, filepath, cache, }: {
3069
3071
  * @param {string[]} [args.filepaths = ['.']] - Limit the query to the given files and directories
3070
3072
  * @param {function(string): boolean} [args.filter] - Filter the results to only those whose filepath matches a function.
3071
3073
  * @param {object} [args.cache] - a [cache](cache.md) object
3074
+ * @param {boolean} [args.ignored = false] - include ignored files in the result
3072
3075
  *
3073
3076
  * @returns {Promise<Array<StatusRow>>} Resolves with a status matrix, described below.
3074
3077
  * @see StatusRow
3075
3078
  */
3076
- export function statusMatrix({ fs: _fs, dir, gitdir, ref, filepaths, filter, cache, }: {
3079
+ export function statusMatrix({ fs: _fs, dir, gitdir, ref, filepaths, filter, cache, ignored: shouldIgnore, }: {
3077
3080
  fs: CallbackFsClient | PromiseFsClient;
3078
3081
  dir: string;
3079
3082
  gitdir?: string;
@@ -3081,6 +3084,7 @@ export function statusMatrix({ fs: _fs, dir, gitdir, ref, filepaths, filter, cac
3081
3084
  filepaths?: string[];
3082
3085
  filter?: (arg0: string) => boolean;
3083
3086
  cache?: any;
3087
+ ignored?: boolean;
3084
3088
  }): Promise<[string, 0 | 1, 0 | 1 | 2, 0 | 1 | 2 | 3][]>;
3085
3089
  /**
3086
3090
  * Create a lightweight tag