isomorphic-git 1.9.2 β 1.10.3
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 +6 -3
- package/browser-tests.json +3 -4
- package/index.cjs +65 -5
- package/index.d.ts +22 -0
- package/index.js +65 -6
- package/index.umd.min.d.ts +22 -0
- package/index.umd.min.js +2 -2
- package/index.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/size_report.html +1 -1
package/README.md
CHANGED
|
@@ -168,6 +168,7 @@ unless there is a major version bump.
|
|
|
168
168
|
- [indexPack](https://isomorphic-git.github.io/docs/indexPack.html)
|
|
169
169
|
- [init](https://isomorphic-git.github.io/docs/init.html)
|
|
170
170
|
- [isDescendent](https://isomorphic-git.github.io/docs/isDescendent.html)
|
|
171
|
+
- [isIgnored](https://isomorphic-git.github.io/docs/isIgnored.html)
|
|
171
172
|
- [listBranches](https://isomorphic-git.github.io/docs/listBranches.html)
|
|
172
173
|
- [listFiles](https://isomorphic-git.github.io/docs/listFiles.html)
|
|
173
174
|
- [listNotes](https://isomorphic-git.github.io/docs/listNotes.html)
|
|
@@ -321,21 +322,23 @@ Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds
|
|
|
321
322
|
<td align="center"><a href="http://eaf4.com"><img src="https://avatars0.githubusercontent.com/u/319282?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Edward Faulkner</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=ef4" title="Code">π»</a></td>
|
|
322
323
|
<td align="center"><a href="https://github.com/KSXGitHub"><img src="https://avatars2.githubusercontent.com/u/11488886?v=4?s=60" width="60px;" alt=""/><br /><sub><b>KhαΊ£i</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3AKSXGitHub" title="Bug reports">π</a></td>
|
|
323
324
|
<td align="center"><a href="https://crutchcorn.dev/"><img src="https://avatars0.githubusercontent.com/u/9100169?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Corbin Crutchley</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=crutchcorn" title="Code">π»</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=crutchcorn" title="Documentation">π</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=crutchcorn" title="Tests">β οΈ</a></td>
|
|
324
|
-
<td align="center"><a href="https://
|
|
325
|
+
<td align="center"><a href="https://github.com/snowyu"><img src="https://avatars1.githubusercontent.com/u/327887?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Riceball LEE</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=snowyu" title="Code">π»</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=snowyu" title="Documentation">π</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=snowyu" title="Tests">β οΈ</a></td>
|
|
325
326
|
</tr>
|
|
326
327
|
<tr>
|
|
328
|
+
<td align="center"><a href="https://onetwo.ren/"><img src="https://avatars1.githubusercontent.com/u/3746270?v=4?s=60" width="60px;" alt=""/><br /><sub><b>lin onetwo</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=linonetwo" title="Code">π»</a></td>
|
|
327
329
|
<td align="center"><a href="https://github.com/linfaxin"><img src="https://avatars2.githubusercontent.com/u/3705017?v=4?s=60" width="60px;" alt=""/><br /><sub><b>ζζ³ι«</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Alinfaxin" title="Bug reports">π</a></td>
|
|
328
|
-
<td align="center"><a href="https://github.com/snowyu"><img src="https://avatars1.githubusercontent.com/u/327887?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Riceball LEE</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=snowyu" title="Code">π»</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=snowyu" title="Documentation">π</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=snowyu" title="Tests">β οΈ</a></td>
|
|
329
330
|
<td align="center"><a href="https://github.com/willstott101"><img src="https://avatars2.githubusercontent.com/u/335152?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Will Stott</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=willstott101" title="Code">π»</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=willstott101" title="Tests">β οΈ</a></td>
|
|
330
331
|
<td align="center"><a href="http://mtnspring.org/"><img src="https://avatars2.githubusercontent.com/u/223277?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Seth Nickell</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Asnickell" title="Bug reports">π</a></td>
|
|
331
332
|
<td align="center"><a href="https://www.alextitarenko.me/"><img src="https://avatars0.githubusercontent.com/u/3290313?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Alex Titarenko</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=alex-titarenko" title="Code">π»</a></td>
|
|
332
333
|
<td align="center"><a href="https://github.com/mmkal"><img src="https://avatars2.githubusercontent.com/u/15040698?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Misha Kaletsky</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=mmkal" title="Code">π»</a></td>
|
|
333
334
|
<td align="center"><a href="https://github.com/rczulch"><img src="https://avatars1.githubusercontent.com/u/54646976?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Richard C. Zulch</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=rczulch" title="Code">π»</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=rczulch" title="Documentation">π</a></td>
|
|
334
|
-
<td align="center"><a href="https://scrapbox.io/mkizka/README"><img src="https://avatars.githubusercontent.com/u/30231179?v=4?s=60" width="60px;" alt=""/><br /><sub><b>mkizka</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=mkizka" title="Code">π»</a></td>
|
|
335
335
|
</tr>
|
|
336
336
|
<tr>
|
|
337
|
+
<td align="center"><a href="https://scrapbox.io/mkizka/README"><img src="https://avatars.githubusercontent.com/u/30231179?v=4?s=60" width="60px;" alt=""/><br /><sub><b>mkizka</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=mkizka" title="Code">π»</a></td>
|
|
337
338
|
<td align="center"><a href="https://ryotak.me/"><img src="https://avatars.githubusercontent.com/u/49341894?v=4?s=60" width="60px;" alt=""/><br /><sub><b>RyotaK</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3ARy0taK" title="Bug reports">π</a></td>
|
|
338
339
|
<td align="center"><a href="https://github.com/strangedev"><img src="https://avatars.githubusercontent.com/u/3045979?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Noah Hummel</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=strangedev" title="Code">π»</a> <a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=strangedev" title="Tests">β οΈ</a></td>
|
|
340
|
+
<td align="center"><a href="https://github.com/mtlewis"><img src="https://avatars.githubusercontent.com/u/542836?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Mike Lewis</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=mtlewis" title="Documentation">π</a></td>
|
|
341
|
+
<td align="center"><a href="https://twitter.com/SamVerschueren"><img src="https://avatars.githubusercontent.com/u/1913805?v=4?s=60" width="60px;" alt=""/><br /><sub><b>Sam Verschueren</b></sub></a><br /><a href="https://github.com/isomorphic-git/isomorphic-git/commits?author=SamVerschueren" title="Code">π»</a></td>
|
|
339
342
|
</tr>
|
|
340
343
|
</table>
|
|
341
344
|
|
package/browser-tests.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
[
|
|
2
2
|
"HeadlessChrome 0.0.0 (Linux 0.0.0)",
|
|
3
|
-
"Firefox
|
|
4
|
-
"
|
|
3
|
+
"Firefox 95.0.0 (Ubuntu 0.0.0)",
|
|
4
|
+
"Chrome Mobile 94.0.4606 (Android 0.0.0)",
|
|
5
5
|
"Chrome 79.0.3945 (Windows 10 0.0.0)",
|
|
6
6
|
"Safari 13.1.0 (Mac OS X 10.15.4)",
|
|
7
|
-
"Mobile Safari 13.0.0 (iOS 13.0.0)"
|
|
8
|
-
"Chrome Mobile 91.0.4472 (Android 0.0.0)"
|
|
7
|
+
"Mobile Safari 13.0.0 (iOS 13.0.0)"
|
|
9
8
|
]
|
package/index.cjs
CHANGED
|
@@ -1694,8 +1694,8 @@ class GitRefManager {
|
|
|
1694
1694
|
if (serverRef.startsWith('refs/tags') && !serverRef.endsWith('^{}')) {
|
|
1695
1695
|
// Git's behavior is to only fetch tags that do not conflict with tags already present.
|
|
1696
1696
|
if (!(await GitRefManager.exists({ fs, gitdir, ref: serverRef }))) {
|
|
1697
|
-
//
|
|
1698
|
-
const oid = refs.get(serverRef
|
|
1697
|
+
// Always use the object id of the tag itself, and not the peeled object id.
|
|
1698
|
+
const oid = refs.get(serverRef);
|
|
1699
1699
|
actualRefsToWrite.set(serverRef, oid);
|
|
1700
1700
|
}
|
|
1701
1701
|
}
|
|
@@ -3976,7 +3976,15 @@ class GitWalkerFs {
|
|
|
3976
3976
|
oid = await shasum(
|
|
3977
3977
|
GitObject.wrap({ type: 'blob', object: await entry.content() })
|
|
3978
3978
|
);
|
|
3979
|
-
|
|
3979
|
+
// Update the stats in the index so we will get a "cache hit" next time
|
|
3980
|
+
// 1) if we can (because the oid and mode are the same)
|
|
3981
|
+
// 2) and only if we need to (because other stats differ)
|
|
3982
|
+
if (
|
|
3983
|
+
stage &&
|
|
3984
|
+
oid === stage.oid &&
|
|
3985
|
+
stats.mode === stage.mode &&
|
|
3986
|
+
compareStats(stats, stage)
|
|
3987
|
+
) {
|
|
3980
3988
|
index.insert({
|
|
3981
3989
|
filepath: entry._fullpath,
|
|
3982
3990
|
stats,
|
|
@@ -6425,7 +6433,14 @@ async function parseRefsAdResponse(stream, { service }) {
|
|
|
6425
6433
|
let lineOne = await read();
|
|
6426
6434
|
// skip past any flushes
|
|
6427
6435
|
while (lineOne === null) lineOne = await read();
|
|
6436
|
+
|
|
6428
6437
|
if (lineOne === true) throw new EmptyServerResponseError()
|
|
6438
|
+
|
|
6439
|
+
// Handle protocol v2 responses (Bitbucket Server doesn't include a `# service=` line)
|
|
6440
|
+
if (lineOne.includes('version 2')) {
|
|
6441
|
+
return parseCapabilitiesV2(read)
|
|
6442
|
+
}
|
|
6443
|
+
|
|
6429
6444
|
// Clients MUST ignore an LF at the end of the line.
|
|
6430
6445
|
if (lineOne.toString('utf8').replace(/\n$/, '') !== `# service=${service}`) {
|
|
6431
6446
|
throw new ParseError(`# service=${service}\\n`, lineOne.toString('utf8'))
|
|
@@ -6437,10 +6452,12 @@ async function parseRefsAdResponse(stream, { service }) {
|
|
|
6437
6452
|
// are returned.
|
|
6438
6453
|
if (lineTwo === true) return { capabilities, refs, symrefs }
|
|
6439
6454
|
lineTwo = lineTwo.toString('utf8');
|
|
6455
|
+
|
|
6440
6456
|
// Handle protocol v2 responses
|
|
6441
6457
|
if (lineTwo.includes('version 2')) {
|
|
6442
6458
|
return parseCapabilitiesV2(read)
|
|
6443
6459
|
}
|
|
6460
|
+
|
|
6444
6461
|
const [firstRef, capabilitiesLine] = splitAndAssert(lineTwo, '\x00', '\\x00');
|
|
6445
6462
|
capabilitiesLine.split(' ').map(x => capabilities.add(x));
|
|
6446
6463
|
const [ref, name] = splitAndAssert(firstRef, ' ', ' ');
|
|
@@ -6848,8 +6865,8 @@ function filterCapabilities(server, client) {
|
|
|
6848
6865
|
|
|
6849
6866
|
const pkg = {
|
|
6850
6867
|
name: 'isomorphic-git',
|
|
6851
|
-
version: '1.
|
|
6852
|
-
agent: 'git/isomorphic-git@1.
|
|
6868
|
+
version: '1.10.3',
|
|
6869
|
+
agent: 'git/isomorphic-git@1.10.3',
|
|
6853
6870
|
};
|
|
6854
6871
|
|
|
6855
6872
|
class FIFO {
|
|
@@ -9877,6 +9894,47 @@ async function isDescendent({
|
|
|
9877
9894
|
|
|
9878
9895
|
// @ts-check
|
|
9879
9896
|
|
|
9897
|
+
/**
|
|
9898
|
+
* Test whether a filepath should be ignored (because of .gitignore or .git/exclude)
|
|
9899
|
+
*
|
|
9900
|
+
* @param {object} args
|
|
9901
|
+
* @param {FsClient} args.fs - a file system client
|
|
9902
|
+
* @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
|
|
9903
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
9904
|
+
* @param {string} args.filepath - The filepath to test
|
|
9905
|
+
*
|
|
9906
|
+
* @returns {Promise<boolean>} Resolves to true if the file should be ignored
|
|
9907
|
+
*
|
|
9908
|
+
* @example
|
|
9909
|
+
* await git.isIgnored({ fs, dir: '/tutorial', filepath: 'docs/add.md' })
|
|
9910
|
+
*
|
|
9911
|
+
*/
|
|
9912
|
+
async function isIgnored({
|
|
9913
|
+
fs,
|
|
9914
|
+
dir,
|
|
9915
|
+
gitdir = join(dir, '.git'),
|
|
9916
|
+
filepath,
|
|
9917
|
+
}) {
|
|
9918
|
+
try {
|
|
9919
|
+
assertParameter('fs', fs);
|
|
9920
|
+
assertParameter('dir', dir);
|
|
9921
|
+
assertParameter('gitdir', gitdir);
|
|
9922
|
+
assertParameter('filepath', filepath);
|
|
9923
|
+
|
|
9924
|
+
return GitIgnoreManager.isIgnored({
|
|
9925
|
+
fs: new FileSystem(fs),
|
|
9926
|
+
dir,
|
|
9927
|
+
gitdir,
|
|
9928
|
+
filepath,
|
|
9929
|
+
})
|
|
9930
|
+
} catch (err) {
|
|
9931
|
+
err.caller = 'git.isIgnored';
|
|
9932
|
+
throw err
|
|
9933
|
+
}
|
|
9934
|
+
}
|
|
9935
|
+
|
|
9936
|
+
// @ts-check
|
|
9937
|
+
|
|
9880
9938
|
/**
|
|
9881
9939
|
* List branches
|
|
9882
9940
|
*
|
|
@@ -14094,6 +14152,7 @@ var index = {
|
|
|
14094
14152
|
indexPack,
|
|
14095
14153
|
init,
|
|
14096
14154
|
isDescendent,
|
|
14155
|
+
isIgnored,
|
|
14097
14156
|
listBranches,
|
|
14098
14157
|
listFiles,
|
|
14099
14158
|
listNotes,
|
|
@@ -14161,6 +14220,7 @@ exports.hashBlob = hashBlob;
|
|
|
14161
14220
|
exports.indexPack = indexPack;
|
|
14162
14221
|
exports.init = init;
|
|
14163
14222
|
exports.isDescendent = isDescendent;
|
|
14223
|
+
exports.isIgnored = isIgnored;
|
|
14164
14224
|
exports.listBranches = listBranches;
|
|
14165
14225
|
exports.listFiles = listFiles;
|
|
14166
14226
|
exports.listNotes = listNotes;
|
package/index.d.ts
CHANGED
|
@@ -659,6 +659,7 @@ declare namespace index {
|
|
|
659
659
|
export { indexPack };
|
|
660
660
|
export { init };
|
|
661
661
|
export { isDescendent };
|
|
662
|
+
export { isIgnored };
|
|
662
663
|
export { listBranches };
|
|
663
664
|
export { listFiles };
|
|
664
665
|
export { listNotes };
|
|
@@ -1762,6 +1763,27 @@ export function isDescendent({ fs, dir, gitdir, oid, ancestor, depth, cache, }:
|
|
|
1762
1763
|
depth?: number;
|
|
1763
1764
|
cache?: any;
|
|
1764
1765
|
}): Promise<boolean>;
|
|
1766
|
+
/**
|
|
1767
|
+
* Test whether a filepath should be ignored (because of .gitignore or .git/exclude)
|
|
1768
|
+
*
|
|
1769
|
+
* @param {object} args
|
|
1770
|
+
* @param {FsClient} args.fs - a file system client
|
|
1771
|
+
* @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
|
|
1772
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
1773
|
+
* @param {string} args.filepath - The filepath to test
|
|
1774
|
+
*
|
|
1775
|
+
* @returns {Promise<boolean>} Resolves to true if the file should be ignored
|
|
1776
|
+
*
|
|
1777
|
+
* @example
|
|
1778
|
+
* await git.isIgnored({ fs, dir: '/tutorial', filepath: 'docs/add.md' })
|
|
1779
|
+
*
|
|
1780
|
+
*/
|
|
1781
|
+
export function isIgnored({ fs, dir, gitdir, filepath, }: {
|
|
1782
|
+
fs: CallbackFsClient | PromiseFsClient;
|
|
1783
|
+
dir: string;
|
|
1784
|
+
gitdir?: string;
|
|
1785
|
+
filepath: string;
|
|
1786
|
+
}): Promise<boolean>;
|
|
1765
1787
|
/**
|
|
1766
1788
|
* List branches
|
|
1767
1789
|
*
|
package/index.js
CHANGED
|
@@ -1688,8 +1688,8 @@ class GitRefManager {
|
|
|
1688
1688
|
if (serverRef.startsWith('refs/tags') && !serverRef.endsWith('^{}')) {
|
|
1689
1689
|
// Git's behavior is to only fetch tags that do not conflict with tags already present.
|
|
1690
1690
|
if (!(await GitRefManager.exists({ fs, gitdir, ref: serverRef }))) {
|
|
1691
|
-
//
|
|
1692
|
-
const oid = refs.get(serverRef
|
|
1691
|
+
// Always use the object id of the tag itself, and not the peeled object id.
|
|
1692
|
+
const oid = refs.get(serverRef);
|
|
1693
1693
|
actualRefsToWrite.set(serverRef, oid);
|
|
1694
1694
|
}
|
|
1695
1695
|
}
|
|
@@ -3970,7 +3970,15 @@ class GitWalkerFs {
|
|
|
3970
3970
|
oid = await shasum(
|
|
3971
3971
|
GitObject.wrap({ type: 'blob', object: await entry.content() })
|
|
3972
3972
|
);
|
|
3973
|
-
|
|
3973
|
+
// Update the stats in the index so we will get a "cache hit" next time
|
|
3974
|
+
// 1) if we can (because the oid and mode are the same)
|
|
3975
|
+
// 2) and only if we need to (because other stats differ)
|
|
3976
|
+
if (
|
|
3977
|
+
stage &&
|
|
3978
|
+
oid === stage.oid &&
|
|
3979
|
+
stats.mode === stage.mode &&
|
|
3980
|
+
compareStats(stats, stage)
|
|
3981
|
+
) {
|
|
3974
3982
|
index.insert({
|
|
3975
3983
|
filepath: entry._fullpath,
|
|
3976
3984
|
stats,
|
|
@@ -6419,7 +6427,14 @@ async function parseRefsAdResponse(stream, { service }) {
|
|
|
6419
6427
|
let lineOne = await read();
|
|
6420
6428
|
// skip past any flushes
|
|
6421
6429
|
while (lineOne === null) lineOne = await read();
|
|
6430
|
+
|
|
6422
6431
|
if (lineOne === true) throw new EmptyServerResponseError()
|
|
6432
|
+
|
|
6433
|
+
// Handle protocol v2 responses (Bitbucket Server doesn't include a `# service=` line)
|
|
6434
|
+
if (lineOne.includes('version 2')) {
|
|
6435
|
+
return parseCapabilitiesV2(read)
|
|
6436
|
+
}
|
|
6437
|
+
|
|
6423
6438
|
// Clients MUST ignore an LF at the end of the line.
|
|
6424
6439
|
if (lineOne.toString('utf8').replace(/\n$/, '') !== `# service=${service}`) {
|
|
6425
6440
|
throw new ParseError(`# service=${service}\\n`, lineOne.toString('utf8'))
|
|
@@ -6431,10 +6446,12 @@ async function parseRefsAdResponse(stream, { service }) {
|
|
|
6431
6446
|
// are returned.
|
|
6432
6447
|
if (lineTwo === true) return { capabilities, refs, symrefs }
|
|
6433
6448
|
lineTwo = lineTwo.toString('utf8');
|
|
6449
|
+
|
|
6434
6450
|
// Handle protocol v2 responses
|
|
6435
6451
|
if (lineTwo.includes('version 2')) {
|
|
6436
6452
|
return parseCapabilitiesV2(read)
|
|
6437
6453
|
}
|
|
6454
|
+
|
|
6438
6455
|
const [firstRef, capabilitiesLine] = splitAndAssert(lineTwo, '\x00', '\\x00');
|
|
6439
6456
|
capabilitiesLine.split(' ').map(x => capabilities.add(x));
|
|
6440
6457
|
const [ref, name] = splitAndAssert(firstRef, ' ', ' ');
|
|
@@ -6842,8 +6859,8 @@ function filterCapabilities(server, client) {
|
|
|
6842
6859
|
|
|
6843
6860
|
const pkg = {
|
|
6844
6861
|
name: 'isomorphic-git',
|
|
6845
|
-
version: '1.
|
|
6846
|
-
agent: 'git/isomorphic-git@1.
|
|
6862
|
+
version: '1.10.3',
|
|
6863
|
+
agent: 'git/isomorphic-git@1.10.3',
|
|
6847
6864
|
};
|
|
6848
6865
|
|
|
6849
6866
|
class FIFO {
|
|
@@ -9871,6 +9888,47 @@ async function isDescendent({
|
|
|
9871
9888
|
|
|
9872
9889
|
// @ts-check
|
|
9873
9890
|
|
|
9891
|
+
/**
|
|
9892
|
+
* Test whether a filepath should be ignored (because of .gitignore or .git/exclude)
|
|
9893
|
+
*
|
|
9894
|
+
* @param {object} args
|
|
9895
|
+
* @param {FsClient} args.fs - a file system client
|
|
9896
|
+
* @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
|
|
9897
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
9898
|
+
* @param {string} args.filepath - The filepath to test
|
|
9899
|
+
*
|
|
9900
|
+
* @returns {Promise<boolean>} Resolves to true if the file should be ignored
|
|
9901
|
+
*
|
|
9902
|
+
* @example
|
|
9903
|
+
* await git.isIgnored({ fs, dir: '/tutorial', filepath: 'docs/add.md' })
|
|
9904
|
+
*
|
|
9905
|
+
*/
|
|
9906
|
+
async function isIgnored({
|
|
9907
|
+
fs,
|
|
9908
|
+
dir,
|
|
9909
|
+
gitdir = join(dir, '.git'),
|
|
9910
|
+
filepath,
|
|
9911
|
+
}) {
|
|
9912
|
+
try {
|
|
9913
|
+
assertParameter('fs', fs);
|
|
9914
|
+
assertParameter('dir', dir);
|
|
9915
|
+
assertParameter('gitdir', gitdir);
|
|
9916
|
+
assertParameter('filepath', filepath);
|
|
9917
|
+
|
|
9918
|
+
return GitIgnoreManager.isIgnored({
|
|
9919
|
+
fs: new FileSystem(fs),
|
|
9920
|
+
dir,
|
|
9921
|
+
gitdir,
|
|
9922
|
+
filepath,
|
|
9923
|
+
})
|
|
9924
|
+
} catch (err) {
|
|
9925
|
+
err.caller = 'git.isIgnored';
|
|
9926
|
+
throw err
|
|
9927
|
+
}
|
|
9928
|
+
}
|
|
9929
|
+
|
|
9930
|
+
// @ts-check
|
|
9931
|
+
|
|
9874
9932
|
/**
|
|
9875
9933
|
* List branches
|
|
9876
9934
|
*
|
|
@@ -14088,6 +14146,7 @@ var index = {
|
|
|
14088
14146
|
indexPack,
|
|
14089
14147
|
init,
|
|
14090
14148
|
isDescendent,
|
|
14149
|
+
isIgnored,
|
|
14091
14150
|
listBranches,
|
|
14092
14151
|
listFiles,
|
|
14093
14152
|
listNotes,
|
|
@@ -14124,4 +14183,4 @@ var index = {
|
|
|
14124
14183
|
};
|
|
14125
14184
|
|
|
14126
14185
|
export default index;
|
|
14127
|
-
export { Errors, STAGE, TREE, WORKDIR, add, addNote, addRemote, annotatedTag, branch, checkout, clone, commit, currentBranch, deleteBranch, deleteRef, deleteRemote, deleteTag, expandOid, expandRef, fastForward, fetch, findMergeBase, findRoot, getConfig, getConfigAll, getRemoteInfo, getRemoteInfo2, hashBlob, indexPack, init, isDescendent, listBranches, listFiles, listNotes, listRemotes, listServerRefs, listTags, log, merge, packObjects, pull, push, readBlob, readCommit, readNote, readObject, readTag, readTree, remove, removeNote, renameBranch, resetIndex, resolveRef, setConfig, status, statusMatrix, tag, version, walk, writeBlob, writeCommit, writeObject, writeRef, writeTag, writeTree };
|
|
14186
|
+
export { Errors, STAGE, TREE, WORKDIR, add, addNote, addRemote, annotatedTag, branch, checkout, clone, commit, currentBranch, deleteBranch, deleteRef, deleteRemote, deleteTag, expandOid, expandRef, fastForward, fetch, findMergeBase, findRoot, getConfig, getConfigAll, getRemoteInfo, getRemoteInfo2, hashBlob, indexPack, init, isDescendent, isIgnored, listBranches, listFiles, listNotes, listRemotes, listServerRefs, listTags, log, merge, packObjects, pull, push, readBlob, readCommit, readNote, readObject, readTag, readTree, remove, removeNote, renameBranch, resetIndex, resolveRef, setConfig, status, statusMatrix, tag, version, walk, writeBlob, writeCommit, writeObject, writeRef, writeTag, writeTree };
|
package/index.umd.min.d.ts
CHANGED
|
@@ -659,6 +659,7 @@ declare namespace index {
|
|
|
659
659
|
export { indexPack };
|
|
660
660
|
export { init };
|
|
661
661
|
export { isDescendent };
|
|
662
|
+
export { isIgnored };
|
|
662
663
|
export { listBranches };
|
|
663
664
|
export { listFiles };
|
|
664
665
|
export { listNotes };
|
|
@@ -1762,6 +1763,27 @@ export function isDescendent({ fs, dir, gitdir, oid, ancestor, depth, cache, }:
|
|
|
1762
1763
|
depth?: number;
|
|
1763
1764
|
cache?: any;
|
|
1764
1765
|
}): Promise<boolean>;
|
|
1766
|
+
/**
|
|
1767
|
+
* Test whether a filepath should be ignored (because of .gitignore or .git/exclude)
|
|
1768
|
+
*
|
|
1769
|
+
* @param {object} args
|
|
1770
|
+
* @param {FsClient} args.fs - a file system client
|
|
1771
|
+
* @param {string} args.dir - The [working tree](dir-vs-gitdir.md) directory path
|
|
1772
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
1773
|
+
* @param {string} args.filepath - The filepath to test
|
|
1774
|
+
*
|
|
1775
|
+
* @returns {Promise<boolean>} Resolves to true if the file should be ignored
|
|
1776
|
+
*
|
|
1777
|
+
* @example
|
|
1778
|
+
* await git.isIgnored({ fs, dir: '/tutorial', filepath: 'docs/add.md' })
|
|
1779
|
+
*
|
|
1780
|
+
*/
|
|
1781
|
+
export function isIgnored({ fs, dir, gitdir, filepath, }: {
|
|
1782
|
+
fs: CallbackFsClient | PromiseFsClient;
|
|
1783
|
+
dir: string;
|
|
1784
|
+
gitdir?: string;
|
|
1785
|
+
filepath: string;
|
|
1786
|
+
}): Promise<boolean>;
|
|
1765
1787
|
/**
|
|
1766
1788
|
* List branches
|
|
1767
1789
|
*
|