isomorphic-git 1.44.13 → 1.44.15
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/index.cjs +159 -36
- package/index.js +159 -36
- package/index.umd.min.js +1 -1
- package/index.umd.min.js.map +1 -1
- package/managers/index.cjs +60 -3
- package/managers/index.js +60 -3
- package/managers/index.umd.min.js +1 -1
- package/managers/index.umd.min.js.map +1 -1
- package/package.json +1 -1
package/managers/index.cjs
CHANGED
|
@@ -1764,7 +1764,16 @@ class GitIndexManager {
|
|
|
1764
1764
|
if (unmergedPaths.length && !allowUnmerged)
|
|
1765
1765
|
throw new UnmergedPathsError(unmergedPaths)
|
|
1766
1766
|
|
|
1767
|
-
|
|
1767
|
+
try {
|
|
1768
|
+
result = await closure(index);
|
|
1769
|
+
} catch (err) {
|
|
1770
|
+
// A failed closure may already have mutated the in-memory index. Drop
|
|
1771
|
+
// it so the next acquire reloads the unchanged index from disk, rather
|
|
1772
|
+
// than flushing a half-applied change that was never written.
|
|
1773
|
+
theIndexCache.map.delete(filepath);
|
|
1774
|
+
theIndexCache.stats.delete(filepath);
|
|
1775
|
+
throw err
|
|
1776
|
+
}
|
|
1768
1777
|
if (index._dirty) {
|
|
1769
1778
|
// Acquire a file lock while we're writing the index file
|
|
1770
1779
|
// let fileLock = await Lock(filepath)
|
|
@@ -1887,16 +1896,45 @@ class GitPackedRefs {
|
|
|
1887
1896
|
}
|
|
1888
1897
|
|
|
1889
1898
|
class GitRefSpec {
|
|
1890
|
-
constructor({
|
|
1899
|
+
constructor({
|
|
1900
|
+
remotePath,
|
|
1901
|
+
remoteSuffix = '',
|
|
1902
|
+
localPath,
|
|
1903
|
+
force,
|
|
1904
|
+
matchPrefix,
|
|
1905
|
+
negative = false,
|
|
1906
|
+
}) {
|
|
1891
1907
|
Object.assign(this, {
|
|
1892
1908
|
remotePath,
|
|
1909
|
+
remoteSuffix,
|
|
1893
1910
|
localPath,
|
|
1894
1911
|
force,
|
|
1895
1912
|
matchPrefix,
|
|
1913
|
+
negative,
|
|
1896
1914
|
});
|
|
1897
1915
|
}
|
|
1898
1916
|
|
|
1899
1917
|
static from(refspec) {
|
|
1918
|
+
// A negative refspec like `^refs/heads/tmp/*` excludes the refs it matches,
|
|
1919
|
+
// and a refspec without a destination like `refs/heads/main` doesn't store
|
|
1920
|
+
// the ref locally.
|
|
1921
|
+
if (refspec.startsWith('^') || !refspec.includes(':')) {
|
|
1922
|
+
const negative = refspec.startsWith('^');
|
|
1923
|
+
const [, forceMatch, remote] = refspec
|
|
1924
|
+
.slice(negative ? 1 : 0)
|
|
1925
|
+
.match(/^(\+?)(.*)$/);
|
|
1926
|
+
// The `*` of a pattern can be followed by the rest of the name, like
|
|
1927
|
+
// `refs/heads/*-tmp`.
|
|
1928
|
+
const star = remote.indexOf('*');
|
|
1929
|
+
return new GitRefSpec({
|
|
1930
|
+
remotePath: star === -1 ? remote : remote.slice(0, star),
|
|
1931
|
+
remoteSuffix: star === -1 ? '' : remote.slice(star + 1),
|
|
1932
|
+
localPath: null,
|
|
1933
|
+
force: forceMatch === '+',
|
|
1934
|
+
matchPrefix: star !== -1,
|
|
1935
|
+
negative,
|
|
1936
|
+
})
|
|
1937
|
+
}
|
|
1900
1938
|
const [forceMatch, remotePath, remoteGlobMatch, localPath, localGlobMatch] =
|
|
1901
1939
|
refspec.match(/^(\+?)(.*?)(\*?):(.*?)(\*?)$/).slice(1);
|
|
1902
1940
|
const force = forceMatch === '+';
|
|
@@ -1916,7 +1954,19 @@ class GitRefSpec {
|
|
|
1916
1954
|
// TODO: We need to run resolveRef on both paths to expand them to their full name.
|
|
1917
1955
|
}
|
|
1918
1956
|
|
|
1957
|
+
matches(remoteBranch) {
|
|
1958
|
+
// Like canonical git, the `*` matches any part of the name, even an empty
|
|
1959
|
+
// one, as long as the prefix and the suffix don't overlap.
|
|
1960
|
+
return this.matchPrefix
|
|
1961
|
+
? remoteBranch.length >=
|
|
1962
|
+
this.remotePath.length + this.remoteSuffix.length &&
|
|
1963
|
+
remoteBranch.startsWith(this.remotePath) &&
|
|
1964
|
+
remoteBranch.endsWith(this.remoteSuffix)
|
|
1965
|
+
: remoteBranch === this.remotePath
|
|
1966
|
+
}
|
|
1967
|
+
|
|
1919
1968
|
translate(remoteBranch) {
|
|
1969
|
+
if (this.localPath === null) return null
|
|
1920
1970
|
if (this.matchPrefix) {
|
|
1921
1971
|
if (remoteBranch.startsWith(this.remotePath)) {
|
|
1922
1972
|
return this.localPath + remoteBranch.replace(this.remotePath, '')
|
|
@@ -1928,6 +1978,7 @@ class GitRefSpec {
|
|
|
1928
1978
|
}
|
|
1929
1979
|
|
|
1930
1980
|
reverseTranslate(localBranch) {
|
|
1981
|
+
if (this.localPath === null) return null
|
|
1931
1982
|
if (this.matchPrefix) {
|
|
1932
1983
|
if (localBranch.startsWith(this.localPath)) {
|
|
1933
1984
|
return this.remotePath + localBranch.replace(this.localPath, '')
|
|
@@ -1957,10 +2008,15 @@ class GitRefSpecSet {
|
|
|
1957
2008
|
this.rules.push(rule);
|
|
1958
2009
|
}
|
|
1959
2010
|
|
|
2011
|
+
isExcluded(remoteRef) {
|
|
2012
|
+
return this.rules.some(rule => rule.negative && rule.matches(remoteRef))
|
|
2013
|
+
}
|
|
2014
|
+
|
|
1960
2015
|
translate(remoteRefs) {
|
|
1961
2016
|
const result = [];
|
|
1962
2017
|
for (const rule of this.rules) {
|
|
1963
2018
|
for (const remoteRef of remoteRefs) {
|
|
2019
|
+
if (this.isExcluded(remoteRef)) continue
|
|
1964
2020
|
const localRef = rule.translate(remoteRef);
|
|
1965
2021
|
if (localRef) {
|
|
1966
2022
|
result.push([remoteRef, localRef]);
|
|
@@ -1972,6 +2028,7 @@ class GitRefSpecSet {
|
|
|
1972
2028
|
|
|
1973
2029
|
translateOne(remoteRef) {
|
|
1974
2030
|
let result = null;
|
|
2031
|
+
if (this.isExcluded(remoteRef)) return result
|
|
1975
2032
|
for (const rule of this.rules) {
|
|
1976
2033
|
const localRef = rule.translate(remoteRef);
|
|
1977
2034
|
if (localRef) {
|
|
@@ -1983,7 +2040,7 @@ class GitRefSpecSet {
|
|
|
1983
2040
|
|
|
1984
2041
|
localNamespaces() {
|
|
1985
2042
|
return this.rules
|
|
1986
|
-
.filter(rule => rule.matchPrefix)
|
|
2043
|
+
.filter(rule => rule.matchPrefix && rule.localPath !== null)
|
|
1987
2044
|
.map(rule => rule.localPath.replace(/\/$/, ''))
|
|
1988
2045
|
}
|
|
1989
2046
|
}
|
package/managers/index.js
CHANGED
|
@@ -1758,7 +1758,16 @@ class GitIndexManager {
|
|
|
1758
1758
|
if (unmergedPaths.length && !allowUnmerged)
|
|
1759
1759
|
throw new UnmergedPathsError(unmergedPaths)
|
|
1760
1760
|
|
|
1761
|
-
|
|
1761
|
+
try {
|
|
1762
|
+
result = await closure(index);
|
|
1763
|
+
} catch (err) {
|
|
1764
|
+
// A failed closure may already have mutated the in-memory index. Drop
|
|
1765
|
+
// it so the next acquire reloads the unchanged index from disk, rather
|
|
1766
|
+
// than flushing a half-applied change that was never written.
|
|
1767
|
+
theIndexCache.map.delete(filepath);
|
|
1768
|
+
theIndexCache.stats.delete(filepath);
|
|
1769
|
+
throw err
|
|
1770
|
+
}
|
|
1762
1771
|
if (index._dirty) {
|
|
1763
1772
|
// Acquire a file lock while we're writing the index file
|
|
1764
1773
|
// let fileLock = await Lock(filepath)
|
|
@@ -1881,16 +1890,45 @@ class GitPackedRefs {
|
|
|
1881
1890
|
}
|
|
1882
1891
|
|
|
1883
1892
|
class GitRefSpec {
|
|
1884
|
-
constructor({
|
|
1893
|
+
constructor({
|
|
1894
|
+
remotePath,
|
|
1895
|
+
remoteSuffix = '',
|
|
1896
|
+
localPath,
|
|
1897
|
+
force,
|
|
1898
|
+
matchPrefix,
|
|
1899
|
+
negative = false,
|
|
1900
|
+
}) {
|
|
1885
1901
|
Object.assign(this, {
|
|
1886
1902
|
remotePath,
|
|
1903
|
+
remoteSuffix,
|
|
1887
1904
|
localPath,
|
|
1888
1905
|
force,
|
|
1889
1906
|
matchPrefix,
|
|
1907
|
+
negative,
|
|
1890
1908
|
});
|
|
1891
1909
|
}
|
|
1892
1910
|
|
|
1893
1911
|
static from(refspec) {
|
|
1912
|
+
// A negative refspec like `^refs/heads/tmp/*` excludes the refs it matches,
|
|
1913
|
+
// and a refspec without a destination like `refs/heads/main` doesn't store
|
|
1914
|
+
// the ref locally.
|
|
1915
|
+
if (refspec.startsWith('^') || !refspec.includes(':')) {
|
|
1916
|
+
const negative = refspec.startsWith('^');
|
|
1917
|
+
const [, forceMatch, remote] = refspec
|
|
1918
|
+
.slice(negative ? 1 : 0)
|
|
1919
|
+
.match(/^(\+?)(.*)$/);
|
|
1920
|
+
// The `*` of a pattern can be followed by the rest of the name, like
|
|
1921
|
+
// `refs/heads/*-tmp`.
|
|
1922
|
+
const star = remote.indexOf('*');
|
|
1923
|
+
return new GitRefSpec({
|
|
1924
|
+
remotePath: star === -1 ? remote : remote.slice(0, star),
|
|
1925
|
+
remoteSuffix: star === -1 ? '' : remote.slice(star + 1),
|
|
1926
|
+
localPath: null,
|
|
1927
|
+
force: forceMatch === '+',
|
|
1928
|
+
matchPrefix: star !== -1,
|
|
1929
|
+
negative,
|
|
1930
|
+
})
|
|
1931
|
+
}
|
|
1894
1932
|
const [forceMatch, remotePath, remoteGlobMatch, localPath, localGlobMatch] =
|
|
1895
1933
|
refspec.match(/^(\+?)(.*?)(\*?):(.*?)(\*?)$/).slice(1);
|
|
1896
1934
|
const force = forceMatch === '+';
|
|
@@ -1910,7 +1948,19 @@ class GitRefSpec {
|
|
|
1910
1948
|
// TODO: We need to run resolveRef on both paths to expand them to their full name.
|
|
1911
1949
|
}
|
|
1912
1950
|
|
|
1951
|
+
matches(remoteBranch) {
|
|
1952
|
+
// Like canonical git, the `*` matches any part of the name, even an empty
|
|
1953
|
+
// one, as long as the prefix and the suffix don't overlap.
|
|
1954
|
+
return this.matchPrefix
|
|
1955
|
+
? remoteBranch.length >=
|
|
1956
|
+
this.remotePath.length + this.remoteSuffix.length &&
|
|
1957
|
+
remoteBranch.startsWith(this.remotePath) &&
|
|
1958
|
+
remoteBranch.endsWith(this.remoteSuffix)
|
|
1959
|
+
: remoteBranch === this.remotePath
|
|
1960
|
+
}
|
|
1961
|
+
|
|
1913
1962
|
translate(remoteBranch) {
|
|
1963
|
+
if (this.localPath === null) return null
|
|
1914
1964
|
if (this.matchPrefix) {
|
|
1915
1965
|
if (remoteBranch.startsWith(this.remotePath)) {
|
|
1916
1966
|
return this.localPath + remoteBranch.replace(this.remotePath, '')
|
|
@@ -1922,6 +1972,7 @@ class GitRefSpec {
|
|
|
1922
1972
|
}
|
|
1923
1973
|
|
|
1924
1974
|
reverseTranslate(localBranch) {
|
|
1975
|
+
if (this.localPath === null) return null
|
|
1925
1976
|
if (this.matchPrefix) {
|
|
1926
1977
|
if (localBranch.startsWith(this.localPath)) {
|
|
1927
1978
|
return this.remotePath + localBranch.replace(this.localPath, '')
|
|
@@ -1951,10 +2002,15 @@ class GitRefSpecSet {
|
|
|
1951
2002
|
this.rules.push(rule);
|
|
1952
2003
|
}
|
|
1953
2004
|
|
|
2005
|
+
isExcluded(remoteRef) {
|
|
2006
|
+
return this.rules.some(rule => rule.negative && rule.matches(remoteRef))
|
|
2007
|
+
}
|
|
2008
|
+
|
|
1954
2009
|
translate(remoteRefs) {
|
|
1955
2010
|
const result = [];
|
|
1956
2011
|
for (const rule of this.rules) {
|
|
1957
2012
|
for (const remoteRef of remoteRefs) {
|
|
2013
|
+
if (this.isExcluded(remoteRef)) continue
|
|
1958
2014
|
const localRef = rule.translate(remoteRef);
|
|
1959
2015
|
if (localRef) {
|
|
1960
2016
|
result.push([remoteRef, localRef]);
|
|
@@ -1966,6 +2022,7 @@ class GitRefSpecSet {
|
|
|
1966
2022
|
|
|
1967
2023
|
translateOne(remoteRef) {
|
|
1968
2024
|
let result = null;
|
|
2025
|
+
if (this.isExcluded(remoteRef)) return result
|
|
1969
2026
|
for (const rule of this.rules) {
|
|
1970
2027
|
const localRef = rule.translate(remoteRef);
|
|
1971
2028
|
if (localRef) {
|
|
@@ -1977,7 +2034,7 @@ class GitRefSpecSet {
|
|
|
1977
2034
|
|
|
1978
2035
|
localNamespaces() {
|
|
1979
2036
|
return this.rules
|
|
1980
|
-
.filter(rule => rule.matchPrefix)
|
|
2037
|
+
.filter(rule => rule.matchPrefix && rule.localPath !== null)
|
|
1981
2038
|
.map(rule => rule.localPath.replace(/\/$/, ''))
|
|
1982
2039
|
}
|
|
1983
2040
|
}
|