isomorphic-git 1.41.7 → 1.41.9
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 +1 -1
- package/index.cjs +53 -8
- package/index.js +53 -8
- package/index.umd.min.js +1 -1
- package/index.umd.min.js.map +1 -1
- package/managers/index.cjs +41 -2
- package/managers/index.d.cts +20 -0
- package/managers/index.d.ts +20 -0
- package/managers/index.js +41 -2
- package/managers/index.umd.min.js +1 -1
- package/managers/index.umd.min.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -109,7 +109,7 @@ import git from 'isomorphic-git'
|
|
|
109
109
|
// or
|
|
110
110
|
import * as git from 'isomorphic-git'
|
|
111
111
|
// or
|
|
112
|
-
import {
|
|
112
|
+
import {add, clone, commit, push} from 'isomorphic-git'
|
|
113
113
|
```
|
|
114
114
|
|
|
115
115
|
View the full [Getting Started guide](https://isomorphic-git.github.io/docs/quickstart.html) on the docs website.
|
package/index.cjs
CHANGED
|
@@ -2365,6 +2365,38 @@ class GitRefManager {
|
|
|
2365
2365
|
throw new NotFoundError(ref)
|
|
2366
2366
|
}
|
|
2367
2367
|
|
|
2368
|
+
/**
|
|
2369
|
+
* Checks whether a ref names the branch HEAD points at in a repository where
|
|
2370
|
+
* that branch has no commits yet.
|
|
2371
|
+
*
|
|
2372
|
+
* A repository created by `git init` has a HEAD pointing at a branch that
|
|
2373
|
+
* does not exist on disk. Resolving that branch fails the same way resolving
|
|
2374
|
+
* a misspelled ref does, so callers that want to treat the two differently
|
|
2375
|
+
* need this to tell them apart.
|
|
2376
|
+
*
|
|
2377
|
+
* @param {Object} args
|
|
2378
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2379
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2380
|
+
* @param {string} args.ref - The ref to check.
|
|
2381
|
+
* @returns {Promise<boolean>} - True if the ref names an unborn branch.
|
|
2382
|
+
*/
|
|
2383
|
+
static async isUnbornBranch({ fs, gitdir, ref }) {
|
|
2384
|
+
let target;
|
|
2385
|
+
try {
|
|
2386
|
+
// depth 2 stops at the symbolic target instead of following it to an oid.
|
|
2387
|
+
target = await GitRefManager.resolve({
|
|
2388
|
+
fs,
|
|
2389
|
+
gitdir,
|
|
2390
|
+
ref: 'HEAD',
|
|
2391
|
+
depth: 2,
|
|
2392
|
+
});
|
|
2393
|
+
} catch (_) {
|
|
2394
|
+
return false
|
|
2395
|
+
}
|
|
2396
|
+
if (!target.startsWith('refs/heads/')) return false
|
|
2397
|
+
return ref === 'HEAD' || refpaths(ref).includes(target)
|
|
2398
|
+
}
|
|
2399
|
+
|
|
2368
2400
|
/**
|
|
2369
2401
|
* Checks if a ref exists.
|
|
2370
2402
|
*
|
|
@@ -4544,9 +4576,16 @@ class GitWalkerRepo {
|
|
|
4544
4576
|
try {
|
|
4545
4577
|
oid = await GitRefManager.resolve({ fs, gitdir, ref });
|
|
4546
4578
|
} catch (e) {
|
|
4547
|
-
|
|
4548
|
-
|
|
4579
|
+
// Only a branch that has no commits yet gets the empty tree. Anything
|
|
4580
|
+
// else that fails to resolve is a ref the caller got wrong, and
|
|
4581
|
+
// swallowing it here would walk an empty tree instead of saying so.
|
|
4582
|
+
if (
|
|
4583
|
+
e instanceof NotFoundError &&
|
|
4584
|
+
(await GitRefManager.isUnbornBranch({ fs, gitdir, ref }))
|
|
4585
|
+
) {
|
|
4549
4586
|
oid = '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
|
|
4587
|
+
} else {
|
|
4588
|
+
throw e
|
|
4550
4589
|
}
|
|
4551
4590
|
}
|
|
4552
4591
|
const tree = await resolveTree({ fs, cache: this.cache, gitdir, oid });
|
|
@@ -7084,11 +7123,17 @@ const worthWalking = (filepath, root) => {
|
|
|
7084
7123
|
if (filepath === '.' || root == null || root.length === 0 || root === '.') {
|
|
7085
7124
|
return true
|
|
7086
7125
|
}
|
|
7087
|
-
|
|
7088
|
-
|
|
7089
|
-
|
|
7090
|
-
|
|
7126
|
+
// A shared prefix only counts when it lands on a path component boundary,
|
|
7127
|
+
// otherwise the root 'src' would also pull in 'src2/a.js' and 'srcfoo.txt'.
|
|
7128
|
+
const base = root.endsWith('/') ? root.slice(0, -1) : root;
|
|
7129
|
+
if (base === '.') {
|
|
7130
|
+
return true
|
|
7131
|
+
}
|
|
7132
|
+
if (base.length >= filepath.length) {
|
|
7133
|
+
// Keep walking while filepath is still an ancestor of the wanted root.
|
|
7134
|
+
return base === filepath || base.startsWith(`${filepath}/`)
|
|
7091
7135
|
}
|
|
7136
|
+
return filepath.startsWith(`${base}/`)
|
|
7092
7137
|
};
|
|
7093
7138
|
|
|
7094
7139
|
// @ts-check
|
|
@@ -9728,8 +9773,8 @@ function filterCapabilities(server, client) {
|
|
|
9728
9773
|
|
|
9729
9774
|
const pkg = {
|
|
9730
9775
|
name: 'isomorphic-git',
|
|
9731
|
-
version: '1.41.
|
|
9732
|
-
agent: 'git/isomorphic-git@1.41.
|
|
9776
|
+
version: '1.41.9',
|
|
9777
|
+
agent: 'git/isomorphic-git@1.41.9',
|
|
9733
9778
|
};
|
|
9734
9779
|
|
|
9735
9780
|
class FIFO {
|
package/index.js
CHANGED
|
@@ -2358,6 +2358,38 @@ class GitRefManager {
|
|
|
2358
2358
|
throw new NotFoundError(ref)
|
|
2359
2359
|
}
|
|
2360
2360
|
|
|
2361
|
+
/**
|
|
2362
|
+
* Checks whether a ref names the branch HEAD points at in a repository where
|
|
2363
|
+
* that branch has no commits yet.
|
|
2364
|
+
*
|
|
2365
|
+
* A repository created by `git init` has a HEAD pointing at a branch that
|
|
2366
|
+
* does not exist on disk. Resolving that branch fails the same way resolving
|
|
2367
|
+
* a misspelled ref does, so callers that want to treat the two differently
|
|
2368
|
+
* need this to tell them apart.
|
|
2369
|
+
*
|
|
2370
|
+
* @param {Object} args
|
|
2371
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2372
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2373
|
+
* @param {string} args.ref - The ref to check.
|
|
2374
|
+
* @returns {Promise<boolean>} - True if the ref names an unborn branch.
|
|
2375
|
+
*/
|
|
2376
|
+
static async isUnbornBranch({ fs, gitdir, ref }) {
|
|
2377
|
+
let target;
|
|
2378
|
+
try {
|
|
2379
|
+
// depth 2 stops at the symbolic target instead of following it to an oid.
|
|
2380
|
+
target = await GitRefManager.resolve({
|
|
2381
|
+
fs,
|
|
2382
|
+
gitdir,
|
|
2383
|
+
ref: 'HEAD',
|
|
2384
|
+
depth: 2,
|
|
2385
|
+
});
|
|
2386
|
+
} catch (_) {
|
|
2387
|
+
return false
|
|
2388
|
+
}
|
|
2389
|
+
if (!target.startsWith('refs/heads/')) return false
|
|
2390
|
+
return ref === 'HEAD' || refpaths(ref).includes(target)
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2361
2393
|
/**
|
|
2362
2394
|
* Checks if a ref exists.
|
|
2363
2395
|
*
|
|
@@ -4531,9 +4563,16 @@ class GitWalkerRepo {
|
|
|
4531
4563
|
try {
|
|
4532
4564
|
oid = await GitRefManager.resolve({ fs, gitdir, ref });
|
|
4533
4565
|
} catch (e) {
|
|
4534
|
-
|
|
4535
|
-
|
|
4566
|
+
// Only a branch that has no commits yet gets the empty tree. Anything
|
|
4567
|
+
// else that fails to resolve is a ref the caller got wrong, and
|
|
4568
|
+
// swallowing it here would walk an empty tree instead of saying so.
|
|
4569
|
+
if (
|
|
4570
|
+
e instanceof NotFoundError &&
|
|
4571
|
+
(await GitRefManager.isUnbornBranch({ fs, gitdir, ref }))
|
|
4572
|
+
) {
|
|
4536
4573
|
oid = '4b825dc642cb6eb9a060e54bf8d69288fbee4904';
|
|
4574
|
+
} else {
|
|
4575
|
+
throw e
|
|
4537
4576
|
}
|
|
4538
4577
|
}
|
|
4539
4578
|
const tree = await resolveTree({ fs, cache: this.cache, gitdir, oid });
|
|
@@ -7071,11 +7110,17 @@ const worthWalking = (filepath, root) => {
|
|
|
7071
7110
|
if (filepath === '.' || root == null || root.length === 0 || root === '.') {
|
|
7072
7111
|
return true
|
|
7073
7112
|
}
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7113
|
+
// A shared prefix only counts when it lands on a path component boundary,
|
|
7114
|
+
// otherwise the root 'src' would also pull in 'src2/a.js' and 'srcfoo.txt'.
|
|
7115
|
+
const base = root.endsWith('/') ? root.slice(0, -1) : root;
|
|
7116
|
+
if (base === '.') {
|
|
7117
|
+
return true
|
|
7118
|
+
}
|
|
7119
|
+
if (base.length >= filepath.length) {
|
|
7120
|
+
// Keep walking while filepath is still an ancestor of the wanted root.
|
|
7121
|
+
return base === filepath || base.startsWith(`${filepath}/`)
|
|
7078
7122
|
}
|
|
7123
|
+
return filepath.startsWith(`${base}/`)
|
|
7079
7124
|
};
|
|
7080
7125
|
|
|
7081
7126
|
// @ts-check
|
|
@@ -9715,8 +9760,8 @@ function filterCapabilities(server, client) {
|
|
|
9715
9760
|
|
|
9716
9761
|
const pkg = {
|
|
9717
9762
|
name: 'isomorphic-git',
|
|
9718
|
-
version: '1.41.
|
|
9719
|
-
agent: 'git/isomorphic-git@1.41.
|
|
9763
|
+
version: '1.41.9',
|
|
9764
|
+
agent: 'git/isomorphic-git@1.41.9',
|
|
9720
9765
|
};
|
|
9721
9766
|
|
|
9722
9767
|
class FIFO {
|