isomorphic-git 1.44.14 → 1.44.16
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/LICENSE.md +52 -0
- package/index.cjs +120 -56
- package/index.js +120 -56
- package/index.umd.min.js +1 -1
- package/index.umd.min.js.LICENSE.txt +20 -12
- package/index.umd.min.js.map +1 -1
- package/managers/index.cjs +118 -54
- package/managers/index.js +118 -54
- package/managers/index.umd.min.js +1 -1
- package/managers/index.umd.min.js.LICENSE.txt +20 -12
- package/managers/index.umd.min.js.map +1 -1
- package/models/index.cjs +69 -53
- package/models/index.js +69 -53
- package/models/index.umd.min.js +1 -1
- package/models/index.umd.min.js.LICENSE.txt +14 -6
- package/models/index.umd.min.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1551,16 +1551,45 @@ class GitPackedRefs {
|
|
|
1551
1551
|
}
|
|
1552
1552
|
|
|
1553
1553
|
class GitRefSpec {
|
|
1554
|
-
constructor({
|
|
1554
|
+
constructor({
|
|
1555
|
+
remotePath,
|
|
1556
|
+
remoteSuffix = '',
|
|
1557
|
+
localPath,
|
|
1558
|
+
force,
|
|
1559
|
+
matchPrefix,
|
|
1560
|
+
negative = false,
|
|
1561
|
+
}) {
|
|
1555
1562
|
Object.assign(this, {
|
|
1556
1563
|
remotePath,
|
|
1564
|
+
remoteSuffix,
|
|
1557
1565
|
localPath,
|
|
1558
1566
|
force,
|
|
1559
1567
|
matchPrefix,
|
|
1568
|
+
negative,
|
|
1560
1569
|
});
|
|
1561
1570
|
}
|
|
1562
1571
|
|
|
1563
1572
|
static from(refspec) {
|
|
1573
|
+
// A negative refspec like `^refs/heads/tmp/*` excludes the refs it matches,
|
|
1574
|
+
// and a refspec without a destination like `refs/heads/main` doesn't store
|
|
1575
|
+
// the ref locally.
|
|
1576
|
+
if (refspec.startsWith('^') || !refspec.includes(':')) {
|
|
1577
|
+
const negative = refspec.startsWith('^');
|
|
1578
|
+
const [, forceMatch, remote] = refspec
|
|
1579
|
+
.slice(negative ? 1 : 0)
|
|
1580
|
+
.match(/^(\+?)(.*)$/);
|
|
1581
|
+
// The `*` of a pattern can be followed by the rest of the name, like
|
|
1582
|
+
// `refs/heads/*-tmp`.
|
|
1583
|
+
const star = remote.indexOf('*');
|
|
1584
|
+
return new GitRefSpec({
|
|
1585
|
+
remotePath: star === -1 ? remote : remote.slice(0, star),
|
|
1586
|
+
remoteSuffix: star === -1 ? '' : remote.slice(star + 1),
|
|
1587
|
+
localPath: null,
|
|
1588
|
+
force: forceMatch === '+',
|
|
1589
|
+
matchPrefix: star !== -1,
|
|
1590
|
+
negative,
|
|
1591
|
+
})
|
|
1592
|
+
}
|
|
1564
1593
|
const [forceMatch, remotePath, remoteGlobMatch, localPath, localGlobMatch] =
|
|
1565
1594
|
refspec.match(/^(\+?)(.*?)(\*?):(.*?)(\*?)$/).slice(1);
|
|
1566
1595
|
const force = forceMatch === '+';
|
|
@@ -1580,7 +1609,19 @@ class GitRefSpec {
|
|
|
1580
1609
|
// TODO: We need to run resolveRef on both paths to expand them to their full name.
|
|
1581
1610
|
}
|
|
1582
1611
|
|
|
1612
|
+
matches(remoteBranch) {
|
|
1613
|
+
// Like canonical git, the `*` matches any part of the name, even an empty
|
|
1614
|
+
// one, as long as the prefix and the suffix don't overlap.
|
|
1615
|
+
return this.matchPrefix
|
|
1616
|
+
? remoteBranch.length >=
|
|
1617
|
+
this.remotePath.length + this.remoteSuffix.length &&
|
|
1618
|
+
remoteBranch.startsWith(this.remotePath) &&
|
|
1619
|
+
remoteBranch.endsWith(this.remoteSuffix)
|
|
1620
|
+
: remoteBranch === this.remotePath
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1583
1623
|
translate(remoteBranch) {
|
|
1624
|
+
if (this.localPath === null) return null
|
|
1584
1625
|
if (this.matchPrefix) {
|
|
1585
1626
|
if (remoteBranch.startsWith(this.remotePath)) {
|
|
1586
1627
|
return this.localPath + remoteBranch.replace(this.remotePath, '')
|
|
@@ -1592,6 +1633,7 @@ class GitRefSpec {
|
|
|
1592
1633
|
}
|
|
1593
1634
|
|
|
1594
1635
|
reverseTranslate(localBranch) {
|
|
1636
|
+
if (this.localPath === null) return null
|
|
1595
1637
|
if (this.matchPrefix) {
|
|
1596
1638
|
if (localBranch.startsWith(this.localPath)) {
|
|
1597
1639
|
return this.remotePath + localBranch.replace(this.localPath, '')
|
|
@@ -1621,10 +1663,15 @@ class GitRefSpecSet {
|
|
|
1621
1663
|
this.rules.push(rule);
|
|
1622
1664
|
}
|
|
1623
1665
|
|
|
1666
|
+
isExcluded(remoteRef) {
|
|
1667
|
+
return this.rules.some(rule => rule.negative && rule.matches(remoteRef))
|
|
1668
|
+
}
|
|
1669
|
+
|
|
1624
1670
|
translate(remoteRefs) {
|
|
1625
1671
|
const result = [];
|
|
1626
1672
|
for (const rule of this.rules) {
|
|
1627
1673
|
for (const remoteRef of remoteRefs) {
|
|
1674
|
+
if (this.isExcluded(remoteRef)) continue
|
|
1628
1675
|
const localRef = rule.translate(remoteRef);
|
|
1629
1676
|
if (localRef) {
|
|
1630
1677
|
result.push([remoteRef, localRef]);
|
|
@@ -1636,6 +1683,7 @@ class GitRefSpecSet {
|
|
|
1636
1683
|
|
|
1637
1684
|
translateOne(remoteRef) {
|
|
1638
1685
|
let result = null;
|
|
1686
|
+
if (this.isExcluded(remoteRef)) return result
|
|
1639
1687
|
for (const rule of this.rules) {
|
|
1640
1688
|
const localRef = rule.translate(remoteRef);
|
|
1641
1689
|
if (localRef) {
|
|
@@ -1647,7 +1695,7 @@ class GitRefSpecSet {
|
|
|
1647
1695
|
|
|
1648
1696
|
localNamespaces() {
|
|
1649
1697
|
return this.rules
|
|
1650
|
-
.filter(rule => rule.matchPrefix)
|
|
1698
|
+
.filter(rule => rule.matchPrefix && rule.localPath !== null)
|
|
1651
1699
|
.map(rule => rule.localPath.replace(/\/$/, ''))
|
|
1652
1700
|
}
|
|
1653
1701
|
}
|
|
@@ -1680,57 +1728,75 @@ function isValidRef(name, onelevel) {
|
|
|
1680
1728
|
}
|
|
1681
1729
|
|
|
1682
1730
|
/*!
|
|
1683
|
-
*
|
|
1684
|
-
*
|
|
1685
|
-
*
|
|
1731
|
+
* The POSIX core below - `assertPath`, `normalizeStringPosix` and the body of
|
|
1732
|
+
* `normalize` - comes from path-browserify, which extracted it from Node.js.
|
|
1733
|
+
* Reformatted to this project's style (`const`/`let`, no semicolons); the
|
|
1734
|
+
* algorithm is unchanged.
|
|
1686
1735
|
*
|
|
1687
|
-
*
|
|
1736
|
+
* SPDX-License-Identifier: MIT
|
|
1737
|
+
* Copyright (c) 2013 James Halliday
|
|
1738
|
+
* Copyright Joyent, Inc. and other Node contributors.
|
|
1739
|
+
*
|
|
1740
|
+
* @see https://github.com/browserify/path-browserify
|
|
1741
|
+
*
|
|
1742
|
+
* The Windows handling is this project's own, added in #2302. path-browserify
|
|
1743
|
+
* is the POSIX part of `path` only, so `normalize` and `join` are wrapped with:
|
|
1688
1744
|
* - Backslashes are normalised to forward slashes before processing.
|
|
1689
1745
|
* - Drive-letter prefixes (e.g. "C:") are detected and preserved through
|
|
1690
1746
|
* normalisation, so absolute Windows paths are handled correctly.
|
|
1691
|
-
* -
|
|
1747
|
+
* - A drive-letter argument passed to join() resets the accumulated path,
|
|
1692
1748
|
* matching Node behaviour and handling worktree gitdir paths properly.
|
|
1693
1749
|
*
|
|
1694
1750
|
* Limitation: UNC paths (e.g. \\server\share) are not supported. The leading
|
|
1695
1751
|
* backslashes are normalised to forward slashes and then collapsed by
|
|
1696
|
-
*
|
|
1752
|
+
* normalizeStringPosix, losing the UNC root. Git on Windows works with
|
|
1697
1753
|
* drive-letter paths, so this is not expected to be a practical issue.
|
|
1698
1754
|
*/
|
|
1699
1755
|
|
|
1700
|
-
function
|
|
1756
|
+
function assertPath(path) {
|
|
1757
|
+
if (typeof path !== 'string') {
|
|
1758
|
+
throw new TypeError(
|
|
1759
|
+
'Path must be a string. Received ' + JSON.stringify(path)
|
|
1760
|
+
)
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
// Resolves . and .. elements in a path with directory names
|
|
1765
|
+
function normalizeStringPosix(path, allowAboveRoot) {
|
|
1701
1766
|
let res = '';
|
|
1702
1767
|
let lastSegmentLength = 0;
|
|
1703
1768
|
let lastSlash = -1;
|
|
1704
1769
|
let dots = 0;
|
|
1705
|
-
let
|
|
1770
|
+
let code;
|
|
1706
1771
|
for (let i = 0; i <= path.length; ++i) {
|
|
1707
|
-
if (i < path.length)
|
|
1708
|
-
else if (
|
|
1709
|
-
else
|
|
1710
|
-
|
|
1711
|
-
if (char === '/') {
|
|
1772
|
+
if (i < path.length) code = path.charCodeAt(i);
|
|
1773
|
+
else if (code === 47 /* / */) break
|
|
1774
|
+
else code = 47; /* / */
|
|
1775
|
+
if (code === 47 /* / */) {
|
|
1712
1776
|
if (lastSlash === i - 1 || dots === 1) {
|
|
1713
1777
|
// NOOP
|
|
1714
|
-
} else if (dots === 2) {
|
|
1778
|
+
} else if (lastSlash !== i - 1 && dots === 2) {
|
|
1715
1779
|
if (
|
|
1716
1780
|
res.length < 2 ||
|
|
1717
1781
|
lastSegmentLength !== 2 ||
|
|
1718
|
-
res.
|
|
1719
|
-
res.
|
|
1782
|
+
res.charCodeAt(res.length - 1) !== 46 /* . */ ||
|
|
1783
|
+
res.charCodeAt(res.length - 2) !== 46 /* . */
|
|
1720
1784
|
) {
|
|
1721
1785
|
if (res.length > 2) {
|
|
1722
1786
|
const lastSlashIndex = res.lastIndexOf('/');
|
|
1723
|
-
if (lastSlashIndex
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1787
|
+
if (lastSlashIndex !== res.length - 1) {
|
|
1788
|
+
if (lastSlashIndex === -1) {
|
|
1789
|
+
res = '';
|
|
1790
|
+
lastSegmentLength = 0;
|
|
1791
|
+
} else {
|
|
1792
|
+
res = res.slice(0, lastSlashIndex);
|
|
1793
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
|
|
1794
|
+
}
|
|
1795
|
+
lastSlash = i;
|
|
1796
|
+
dots = 0;
|
|
1797
|
+
continue
|
|
1729
1798
|
}
|
|
1730
|
-
|
|
1731
|
-
dots = 0;
|
|
1732
|
-
continue
|
|
1733
|
-
} else if (res.length !== 0) {
|
|
1799
|
+
} else if (res.length === 2 || res.length === 1) {
|
|
1734
1800
|
res = '';
|
|
1735
1801
|
lastSegmentLength = 0;
|
|
1736
1802
|
lastSlash = i;
|
|
@@ -1738,8 +1804,9 @@ function normalizeString(path, aar) {
|
|
|
1738
1804
|
continue
|
|
1739
1805
|
}
|
|
1740
1806
|
}
|
|
1741
|
-
if (
|
|
1742
|
-
|
|
1807
|
+
if (allowAboveRoot) {
|
|
1808
|
+
if (res.length > 0) res += '/..';
|
|
1809
|
+
else res = '..';
|
|
1743
1810
|
lastSegmentLength = 2;
|
|
1744
1811
|
}
|
|
1745
1812
|
} else {
|
|
@@ -1749,7 +1816,7 @@ function normalizeString(path, aar) {
|
|
|
1749
1816
|
}
|
|
1750
1817
|
lastSlash = i;
|
|
1751
1818
|
dots = 0;
|
|
1752
|
-
} else if (
|
|
1819
|
+
} else if (code === 46 /* . */ && dots !== -1) {
|
|
1753
1820
|
++dots;
|
|
1754
1821
|
} else {
|
|
1755
1822
|
dots = -1;
|
|
@@ -1767,7 +1834,9 @@ function getWindowsDrivePrefix(path) {
|
|
|
1767
1834
|
}
|
|
1768
1835
|
|
|
1769
1836
|
function normalize(path) {
|
|
1770
|
-
|
|
1837
|
+
assertPath(path);
|
|
1838
|
+
|
|
1839
|
+
if (path.length === 0) return '.'
|
|
1771
1840
|
|
|
1772
1841
|
// Normalise backslashes to forward slashes before any other processing.
|
|
1773
1842
|
path = path.replace(/\\/g, '/');
|
|
@@ -1775,26 +1844,19 @@ function normalize(path) {
|
|
|
1775
1844
|
const drivePrefix = getWindowsDrivePrefix(path);
|
|
1776
1845
|
// isAbsolute: Unix root ('/foo') OR Windows drive+slash ('C:/foo').
|
|
1777
1846
|
const isAbsolute =
|
|
1778
|
-
path
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
//
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1847
|
+
path.charCodeAt(0) === 47 /* / */ ||
|
|
1848
|
+
(drivePrefix !== null && path.charCodeAt(2) === 47); /* / */
|
|
1849
|
+
const trailingSeparator = path.charCodeAt(path.length - 1) === 47; /* / */
|
|
1850
|
+
|
|
1851
|
+
// Strip the drive prefix before normalizing so that the core algorithm only
|
|
1852
|
+
// ever sees a plain POSIX-style string.
|
|
1853
|
+
let normalized = normalizeStringPosix(
|
|
1854
|
+
drivePrefix ? path.slice(2) : path,
|
|
1855
|
+
!isAbsolute
|
|
1856
|
+
);
|
|
1786
1857
|
|
|
1787
|
-
if (
|
|
1788
|
-
|
|
1789
|
-
? isAbsolute
|
|
1790
|
-
? drivePrefix + '/'
|
|
1791
|
-
: drivePrefix
|
|
1792
|
-
: isAbsolute
|
|
1793
|
-
? '/'
|
|
1794
|
-
: '.';
|
|
1795
|
-
return trailingSeparator && !isAbsolute ? root + '/' : root
|
|
1796
|
-
}
|
|
1797
|
-
if (trailingSeparator) normalized += '/';
|
|
1858
|
+
if (normalized.length === 0 && !isAbsolute) normalized = '.';
|
|
1859
|
+
if (normalized.length > 0 && trailingSeparator) normalized += '/';
|
|
1798
1860
|
|
|
1799
1861
|
if (drivePrefix) {
|
|
1800
1862
|
return isAbsolute
|
|
@@ -1808,19 +1870,21 @@ function join(...args) {
|
|
|
1808
1870
|
if (args.length === 0) return '.'
|
|
1809
1871
|
let joined;
|
|
1810
1872
|
for (let i = 0; i < args.length; ++i) {
|
|
1873
|
+
assertPath(args[i]);
|
|
1811
1874
|
// Normalise separators before processing.
|
|
1812
1875
|
const arg = args[i].replace(/\\/g, '/');
|
|
1813
1876
|
if (arg.length === 0) continue
|
|
1814
1877
|
|
|
1815
1878
|
// A Windows drive-letter path (e.g. "C:/worktrees/foo") cannot be
|
|
1816
1879
|
// meaningfully appended to any base, so it resets the accumulator.
|
|
1817
|
-
// Unix absolute paths (leading '/') are NOT reset here
|
|
1880
|
+
// Unix absolute paths (leading '/') are NOT reset here - that would be
|
|
1818
1881
|
// path.resolve() semantics; path.join('foo', '/bar') must yield 'foo/bar'.
|
|
1819
1882
|
if (/^[a-zA-Z]:\//.test(arg)) {
|
|
1820
1883
|
joined = arg;
|
|
1884
|
+
} else if (joined === undefined) {
|
|
1885
|
+
joined = arg;
|
|
1821
1886
|
} else {
|
|
1822
|
-
|
|
1823
|
-
else joined += '/' + arg;
|
|
1887
|
+
joined += '/' + arg;
|
|
1824
1888
|
}
|
|
1825
1889
|
}
|
|
1826
1890
|
if (joined === undefined) return '.'
|
|
@@ -10365,8 +10429,8 @@ function filterCapabilities(server, client) {
|
|
|
10365
10429
|
|
|
10366
10430
|
const pkg = {
|
|
10367
10431
|
name: 'isomorphic-git',
|
|
10368
|
-
version: '1.44.
|
|
10369
|
-
agent: 'git/isomorphic-git@1.44.
|
|
10432
|
+
version: '1.44.16',
|
|
10433
|
+
agent: 'git/isomorphic-git@1.44.16',
|
|
10370
10434
|
};
|
|
10371
10435
|
|
|
10372
10436
|
class FIFO {
|