isomorphic-git 1.32.3 → 1.33.1
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/browser-tests.json +6 -3
- package/index.cjs +410 -69
- package/index.js +410 -69
- package/index.umd.min.js +6 -2
- package/index.umd.min.js.map +1 -1
- package/managers/index.cjs +6084 -0
- package/managers/index.d.cts +953 -0
- package/managers/index.d.ts +952 -0
- package/managers/index.js +6071 -0
- package/managers/index.umd.min.js +13 -0
- package/managers/index.umd.min.js.map +1 -0
- package/models/index.cjs +365 -0
- package/models/index.d.cts +105 -0
- package/models/index.d.ts +104 -0
- package/models/index.js +359 -0
- package/models/index.umd.min.js +9 -0
- package/models/index.umd.min.js.map +1 -0
- package/package.json +25 -3
- package/size_report.html +1 -1
package/index.js
CHANGED
|
@@ -956,8 +956,6 @@ function compareStats(entry, stats, filemode = true, trustino = true) {
|
|
|
956
956
|
return staleness
|
|
957
957
|
}
|
|
958
958
|
|
|
959
|
-
// import LockManager from 'travix-lock-manager'
|
|
960
|
-
|
|
961
959
|
// import Lock from '../utils.js'
|
|
962
960
|
|
|
963
961
|
// const lm = new LockManager()
|
|
@@ -965,6 +963,10 @@ let lock = null;
|
|
|
965
963
|
|
|
966
964
|
const IndexCache = Symbol('IndexCache');
|
|
967
965
|
|
|
966
|
+
/**
|
|
967
|
+
* Creates a cache object to store GitIndex and file stats.
|
|
968
|
+
* @returns {object} A cache object with `map` and `stats` properties.
|
|
969
|
+
*/
|
|
968
970
|
function createCache() {
|
|
969
971
|
return {
|
|
970
972
|
map: new Map(),
|
|
@@ -972,6 +974,13 @@ function createCache() {
|
|
|
972
974
|
}
|
|
973
975
|
}
|
|
974
976
|
|
|
977
|
+
/**
|
|
978
|
+
* Updates the cached index file by reading the file system and parsing the Git index.
|
|
979
|
+
* @param {FSClient} fs - A file system implementation.
|
|
980
|
+
* @param {string} filepath - The path to the Git index file.
|
|
981
|
+
* @param {object} cache - The cache object to update.
|
|
982
|
+
* @returns {Promise<void>}
|
|
983
|
+
*/
|
|
975
984
|
async function updateCachedIndexFile(fs, filepath, cache) {
|
|
976
985
|
const [stat, rawIndexFile] = await Promise.all([
|
|
977
986
|
fs.lstat(filepath),
|
|
@@ -985,7 +994,13 @@ async function updateCachedIndexFile(fs, filepath, cache) {
|
|
|
985
994
|
cache.stats.set(filepath, stat);
|
|
986
995
|
}
|
|
987
996
|
|
|
988
|
-
|
|
997
|
+
/**
|
|
998
|
+
* Determines whether the cached index file is stale by comparing file stats.
|
|
999
|
+
* @param {FSClient} fs - A file system implementation.
|
|
1000
|
+
* @param {string} filepath - The path to the Git index file.
|
|
1001
|
+
* @param {object} cache - The cache object containing file stats.
|
|
1002
|
+
* @returns {Promise<boolean>} `true` if the index file is stale, otherwise `false`.
|
|
1003
|
+
*/
|
|
989
1004
|
async function isIndexStale(fs, filepath, cache) {
|
|
990
1005
|
const savedStats = cache.stats.get(filepath);
|
|
991
1006
|
if (savedStats === undefined) return true
|
|
@@ -998,13 +1013,16 @@ async function isIndexStale(fs, filepath, cache) {
|
|
|
998
1013
|
|
|
999
1014
|
class GitIndexManager {
|
|
1000
1015
|
/**
|
|
1016
|
+
* Manages access to the Git index file, ensuring thread-safe operations and caching.
|
|
1001
1017
|
*
|
|
1002
|
-
* @param {object} opts
|
|
1003
|
-
* @param {
|
|
1004
|
-
* @param {string} opts.gitdir
|
|
1005
|
-
* @param {object} opts.cache
|
|
1006
|
-
* @param {
|
|
1007
|
-
* @param {function(GitIndex): any} closure
|
|
1018
|
+
* @param {object} opts - Options for acquiring the Git index.
|
|
1019
|
+
* @param {FSClient} opts.fs - A file system implementation.
|
|
1020
|
+
* @param {string} opts.gitdir - The path to the `.git` directory.
|
|
1021
|
+
* @param {object} opts.cache - A shared cache object for storing index data.
|
|
1022
|
+
* @param {boolean} [opts.allowUnmerged=true] - Whether to allow unmerged paths in the index.
|
|
1023
|
+
* @param {function(GitIndex): any} closure - A function to execute with the Git index.
|
|
1024
|
+
* @returns {Promise<any>} The result of the closure function.
|
|
1025
|
+
* @throws {UnmergedPathsError} If unmerged paths exist and `allowUnmerged` is `false`.
|
|
1008
1026
|
*/
|
|
1009
1027
|
static async acquire({ fs, gitdir, cache, allowUnmerged = true }, closure) {
|
|
1010
1028
|
if (!cache[IndexCache]) {
|
|
@@ -1785,7 +1803,18 @@ class GitConfig {
|
|
|
1785
1803
|
}
|
|
1786
1804
|
}
|
|
1787
1805
|
|
|
1806
|
+
/**
|
|
1807
|
+
* Manages access to the Git configuration file, providing methods to read and save configurations.
|
|
1808
|
+
*/
|
|
1788
1809
|
class GitConfigManager {
|
|
1810
|
+
/**
|
|
1811
|
+
* Reads the Git configuration file from the specified `.git` directory.
|
|
1812
|
+
*
|
|
1813
|
+
* @param {object} opts - Options for reading the Git configuration.
|
|
1814
|
+
* @param {FSClient} opts.fs - A file system implementation.
|
|
1815
|
+
* @param {string} opts.gitdir - The path to the `.git` directory.
|
|
1816
|
+
* @returns {Promise<GitConfig>} A `GitConfig` object representing the parsed configuration.
|
|
1817
|
+
*/
|
|
1789
1818
|
static async get({ fs, gitdir }) {
|
|
1790
1819
|
// We can improve efficiency later if needed.
|
|
1791
1820
|
// TODO: read from full list of git config files
|
|
@@ -1793,6 +1822,15 @@ class GitConfigManager {
|
|
|
1793
1822
|
return GitConfig.from(text)
|
|
1794
1823
|
}
|
|
1795
1824
|
|
|
1825
|
+
/**
|
|
1826
|
+
* Saves the provided Git configuration to the specified `.git` directory.
|
|
1827
|
+
*
|
|
1828
|
+
* @param {object} opts - Options for saving the Git configuration.
|
|
1829
|
+
* @param {FSClient} opts.fs - A file system implementation.
|
|
1830
|
+
* @param {string} opts.gitdir - The path to the `.git` directory.
|
|
1831
|
+
* @param {GitConfig} opts.config - The `GitConfig` object to save.
|
|
1832
|
+
* @returns {Promise<void>} Resolves when the configuration has been successfully saved.
|
|
1833
|
+
*/
|
|
1796
1834
|
static async save({ fs, gitdir, config }) {
|
|
1797
1835
|
// We can improve efficiency later if needed.
|
|
1798
1836
|
// TODO: handle saving to the correct global/user/repo location
|
|
@@ -1802,8 +1840,6 @@ class GitConfigManager {
|
|
|
1802
1840
|
}
|
|
1803
1841
|
}
|
|
1804
1842
|
|
|
1805
|
-
// This is a convenience wrapper for reading and writing files in the 'refs' directory.
|
|
1806
|
-
|
|
1807
1843
|
// @see https://git-scm.com/docs/git-rev-parse.html#_specifying_revisions
|
|
1808
1844
|
const refpaths = ref => [
|
|
1809
1845
|
`${ref}`,
|
|
@@ -1824,7 +1860,25 @@ async function acquireLock(ref, callback) {
|
|
|
1824
1860
|
return lock$1.acquire(ref, callback)
|
|
1825
1861
|
}
|
|
1826
1862
|
|
|
1863
|
+
/**
|
|
1864
|
+
* A class for managing Git references, including reading, writing, deleting, and resolving refs.
|
|
1865
|
+
*/
|
|
1827
1866
|
class GitRefManager {
|
|
1867
|
+
/**
|
|
1868
|
+
* Updates remote refs based on the provided refspecs and options.
|
|
1869
|
+
*
|
|
1870
|
+
* @param {Object} args
|
|
1871
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
1872
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
1873
|
+
* @param {string} args.remote - The name of the remote.
|
|
1874
|
+
* @param {Map<string, string>} args.refs - A map of refs to their object IDs.
|
|
1875
|
+
* @param {Map<string, string>} args.symrefs - A map of symbolic refs.
|
|
1876
|
+
* @param {boolean} args.tags - Whether to fetch tags.
|
|
1877
|
+
* @param {string[]} [args.refspecs = undefined] - The refspecs to use.
|
|
1878
|
+
* @param {boolean} [args.prune = false] - Whether to prune stale refs.
|
|
1879
|
+
* @param {boolean} [args.pruneTags = false] - Whether to prune tags.
|
|
1880
|
+
* @returns {Promise<Object>} - An object containing pruned refs.
|
|
1881
|
+
*/
|
|
1828
1882
|
static async updateRemoteRefs({
|
|
1829
1883
|
fs,
|
|
1830
1884
|
gitdir,
|
|
@@ -1937,6 +1991,16 @@ class GitRefManager {
|
|
|
1937
1991
|
return { pruned }
|
|
1938
1992
|
}
|
|
1939
1993
|
|
|
1994
|
+
/**
|
|
1995
|
+
* Writes a ref to the file system.
|
|
1996
|
+
*
|
|
1997
|
+
* @param {Object} args
|
|
1998
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
1999
|
+
* @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2000
|
+
* @param {string} args.ref - The ref to write.
|
|
2001
|
+
* @param {string} args.value - The object ID to write.
|
|
2002
|
+
* @returns {Promise<void>}
|
|
2003
|
+
*/
|
|
1940
2004
|
// TODO: make this less crude?
|
|
1941
2005
|
static async writeRef({ fs, gitdir, ref, value }) {
|
|
1942
2006
|
// Validate input
|
|
@@ -1948,16 +2012,44 @@ class GitRefManager {
|
|
|
1948
2012
|
);
|
|
1949
2013
|
}
|
|
1950
2014
|
|
|
2015
|
+
/**
|
|
2016
|
+
* Writes a symbolic ref to the file system.
|
|
2017
|
+
*
|
|
2018
|
+
* @param {Object} args
|
|
2019
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2020
|
+
* @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2021
|
+
* @param {string} args.ref - The ref to write.
|
|
2022
|
+
* @param {string} args.value - The target ref.
|
|
2023
|
+
* @returns {Promise<void>}
|
|
2024
|
+
*/
|
|
1951
2025
|
static async writeSymbolicRef({ fs, gitdir, ref, value }) {
|
|
1952
2026
|
await acquireLock(ref, async () =>
|
|
1953
2027
|
fs.write(join(gitdir, ref), 'ref: ' + `${value.trim()}\n`, 'utf8')
|
|
1954
2028
|
);
|
|
1955
2029
|
}
|
|
1956
2030
|
|
|
2031
|
+
/**
|
|
2032
|
+
* Deletes a single ref.
|
|
2033
|
+
*
|
|
2034
|
+
* @param {Object} args
|
|
2035
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2036
|
+
* @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2037
|
+
* @param {string} args.ref - The ref to delete.
|
|
2038
|
+
* @returns {Promise<void>}
|
|
2039
|
+
*/
|
|
1957
2040
|
static async deleteRef({ fs, gitdir, ref }) {
|
|
1958
2041
|
return GitRefManager.deleteRefs({ fs, gitdir, refs: [ref] })
|
|
1959
2042
|
}
|
|
1960
2043
|
|
|
2044
|
+
/**
|
|
2045
|
+
* Deletes multiple refs.
|
|
2046
|
+
*
|
|
2047
|
+
* @param {Object} args
|
|
2048
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2049
|
+
* @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2050
|
+
* @param {string[]} args.refs - The refs to delete.
|
|
2051
|
+
* @returns {Promise<void>}
|
|
2052
|
+
*/
|
|
1961
2053
|
static async deleteRefs({ fs, gitdir, refs }) {
|
|
1962
2054
|
// Delete regular ref
|
|
1963
2055
|
await Promise.all(refs.map(ref => fs.rm(join(gitdir, ref))));
|
|
@@ -1981,12 +2073,14 @@ class GitRefManager {
|
|
|
1981
2073
|
}
|
|
1982
2074
|
|
|
1983
2075
|
/**
|
|
1984
|
-
*
|
|
1985
|
-
*
|
|
1986
|
-
* @param {
|
|
1987
|
-
* @param {
|
|
1988
|
-
* @param {
|
|
1989
|
-
* @
|
|
2076
|
+
* Resolves a ref to its object ID.
|
|
2077
|
+
*
|
|
2078
|
+
* @param {Object} args
|
|
2079
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2080
|
+
* @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2081
|
+
* @param {string} args.ref - The ref to resolve.
|
|
2082
|
+
* @param {number} [args.depth = undefined] - The maximum depth to resolve symbolic refs.
|
|
2083
|
+
* @returns {Promise<string>} - The resolved object ID.
|
|
1990
2084
|
*/
|
|
1991
2085
|
static async resolve({ fs, gitdir, ref, depth = undefined }) {
|
|
1992
2086
|
if (depth !== undefined) {
|
|
@@ -2025,6 +2119,15 @@ class GitRefManager {
|
|
|
2025
2119
|
throw new NotFoundError(ref)
|
|
2026
2120
|
}
|
|
2027
2121
|
|
|
2122
|
+
/**
|
|
2123
|
+
* Checks if a ref exists.
|
|
2124
|
+
*
|
|
2125
|
+
* @param {Object} args
|
|
2126
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2127
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2128
|
+
* @param {string} args.ref - The ref to check.
|
|
2129
|
+
* @returns {Promise<boolean>} - True if the ref exists, false otherwise.
|
|
2130
|
+
*/
|
|
2028
2131
|
static async exists({ fs, gitdir, ref }) {
|
|
2029
2132
|
try {
|
|
2030
2133
|
await GitRefManager.expand({ fs, gitdir, ref });
|
|
@@ -2034,6 +2137,15 @@ class GitRefManager {
|
|
|
2034
2137
|
}
|
|
2035
2138
|
}
|
|
2036
2139
|
|
|
2140
|
+
/**
|
|
2141
|
+
* Expands a ref to its full name.
|
|
2142
|
+
*
|
|
2143
|
+
* @param {Object} args
|
|
2144
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2145
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2146
|
+
* @param {string} args.ref - The ref to expand.
|
|
2147
|
+
* @returns {Promise<string>} - The full ref name.
|
|
2148
|
+
*/
|
|
2037
2149
|
static async expand({ fs, gitdir, ref }) {
|
|
2038
2150
|
// Is it a complete and valid SHA?
|
|
2039
2151
|
if (ref.length === 40 && /[0-9a-f]{40}/.test(ref)) {
|
|
@@ -2054,6 +2166,14 @@ class GitRefManager {
|
|
|
2054
2166
|
throw new NotFoundError(ref)
|
|
2055
2167
|
}
|
|
2056
2168
|
|
|
2169
|
+
/**
|
|
2170
|
+
* Expands a ref against a provided map.
|
|
2171
|
+
*
|
|
2172
|
+
* @param {Object} args
|
|
2173
|
+
* @param {string} args.ref - The ref to expand.
|
|
2174
|
+
* @param {Map<string, string>} args.map - The map of refs.
|
|
2175
|
+
* @returns {Promise<string>} - The expanded ref.
|
|
2176
|
+
*/
|
|
2057
2177
|
static async expandAgainstMap({ ref, map }) {
|
|
2058
2178
|
// Look in all the proper paths, in this order
|
|
2059
2179
|
const allpaths = refpaths(ref);
|
|
@@ -2064,6 +2184,16 @@ class GitRefManager {
|
|
|
2064
2184
|
throw new NotFoundError(ref)
|
|
2065
2185
|
}
|
|
2066
2186
|
|
|
2187
|
+
/**
|
|
2188
|
+
* Resolves a ref against a provided map.
|
|
2189
|
+
*
|
|
2190
|
+
* @param {Object} args
|
|
2191
|
+
* @param {string} args.ref - The ref to resolve.
|
|
2192
|
+
* @param {string} [args.fullref = args.ref] - The full ref name.
|
|
2193
|
+
* @param {number} [args.depth = undefined] - The maximum depth to resolve symbolic refs.
|
|
2194
|
+
* @param {Map<string, string>} args.map - The map of refs.
|
|
2195
|
+
* @returns {Object} - An object containing the full ref and its object ID.
|
|
2196
|
+
*/
|
|
2067
2197
|
static resolveAgainstMap({ ref, fullref = ref, depth = undefined, map }) {
|
|
2068
2198
|
if (depth !== undefined) {
|
|
2069
2199
|
depth--;
|
|
@@ -2097,6 +2227,14 @@ class GitRefManager {
|
|
|
2097
2227
|
throw new NotFoundError(ref)
|
|
2098
2228
|
}
|
|
2099
2229
|
|
|
2230
|
+
/**
|
|
2231
|
+
* Reads the packed refs file and returns a map of refs.
|
|
2232
|
+
*
|
|
2233
|
+
* @param {Object} args
|
|
2234
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2235
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2236
|
+
* @returns {Promise<Map<string, string>>} - A map of packed refs.
|
|
2237
|
+
*/
|
|
2100
2238
|
static async packedRefs({ fs, gitdir }) {
|
|
2101
2239
|
const text = await acquireLock('packed-refs', async () =>
|
|
2102
2240
|
fs.read(`${gitdir}/packed-refs`, { encoding: 'utf8' })
|
|
@@ -2105,7 +2243,15 @@ class GitRefManager {
|
|
|
2105
2243
|
return packed.refs
|
|
2106
2244
|
}
|
|
2107
2245
|
|
|
2108
|
-
|
|
2246
|
+
/**
|
|
2247
|
+
* Lists all refs matching a given filepath prefix.
|
|
2248
|
+
*
|
|
2249
|
+
* @param {Object} args
|
|
2250
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2251
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2252
|
+
* @param {string} args.filepath - The filepath prefix to match.
|
|
2253
|
+
* @returns {Promise<string[]>} - A sorted list of refs.
|
|
2254
|
+
*/
|
|
2109
2255
|
static async listRefs({ fs, gitdir, filepath }) {
|
|
2110
2256
|
const packedMap = GitRefManager.packedRefs({ fs, gitdir });
|
|
2111
2257
|
let files = null;
|
|
@@ -2132,6 +2278,15 @@ class GitRefManager {
|
|
|
2132
2278
|
return files
|
|
2133
2279
|
}
|
|
2134
2280
|
|
|
2281
|
+
/**
|
|
2282
|
+
* Lists all branches, optionally filtered by remote.
|
|
2283
|
+
*
|
|
2284
|
+
* @param {Object} args
|
|
2285
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2286
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2287
|
+
* @param {string} [args.remote] - The remote to filter branches by.
|
|
2288
|
+
* @returns {Promise<string[]>} - A list of branch names.
|
|
2289
|
+
*/
|
|
2135
2290
|
static async listBranches({ fs, gitdir, remote }) {
|
|
2136
2291
|
if (remote) {
|
|
2137
2292
|
return GitRefManager.listRefs({
|
|
@@ -2144,6 +2299,14 @@ class GitRefManager {
|
|
|
2144
2299
|
}
|
|
2145
2300
|
}
|
|
2146
2301
|
|
|
2302
|
+
/**
|
|
2303
|
+
* Lists all tags.
|
|
2304
|
+
*
|
|
2305
|
+
* @param {Object} args
|
|
2306
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2307
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2308
|
+
* @returns {Promise<string[]>} - A list of tag names.
|
|
2309
|
+
*/
|
|
2147
2310
|
static async listTags({ fs, gitdir }) {
|
|
2148
2311
|
const tags = await GitRefManager.listRefs({
|
|
2149
2312
|
fs,
|
|
@@ -4604,9 +4767,15 @@ function bindFs(target, fs) {
|
|
|
4604
4767
|
}
|
|
4605
4768
|
|
|
4606
4769
|
/**
|
|
4607
|
-
*
|
|
4770
|
+
* A wrapper class for file system operations, providing a consistent API for both promise-based
|
|
4771
|
+
* and callback-based file systems. It includes utility methods for common file system tasks.
|
|
4608
4772
|
*/
|
|
4609
4773
|
class FileSystem {
|
|
4774
|
+
/**
|
|
4775
|
+
* Creates an instance of FileSystem.
|
|
4776
|
+
*
|
|
4777
|
+
* @param {Object} fs - A file system implementation to wrap.
|
|
4778
|
+
*/
|
|
4610
4779
|
constructor(fs) {
|
|
4611
4780
|
if (typeof fs._original_unwrapped_fs !== 'undefined') return fs
|
|
4612
4781
|
|
|
@@ -4622,6 +4791,10 @@ class FileSystem {
|
|
|
4622
4791
|
/**
|
|
4623
4792
|
* Return true if a file exists, false if it doesn't exist.
|
|
4624
4793
|
* Rethrows errors that aren't related to file existence.
|
|
4794
|
+
*
|
|
4795
|
+
* @param {string} filepath - The path to the file.
|
|
4796
|
+
* @param {Object} [options] - Additional options.
|
|
4797
|
+
* @returns {Promise<boolean>} - `true` if the file exists, `false` otherwise.
|
|
4625
4798
|
*/
|
|
4626
4799
|
async exists(filepath, options = {}) {
|
|
4627
4800
|
try {
|
|
@@ -4644,10 +4817,9 @@ class FileSystem {
|
|
|
4644
4817
|
/**
|
|
4645
4818
|
* Return the contents of a file if it exists, otherwise returns null.
|
|
4646
4819
|
*
|
|
4647
|
-
* @param {string} filepath
|
|
4648
|
-
* @param {
|
|
4649
|
-
*
|
|
4650
|
-
* @returns {Promise<Buffer|string|null>}
|
|
4820
|
+
* @param {string} filepath - The path to the file.
|
|
4821
|
+
* @param {Object} [options] - Options for reading the file.
|
|
4822
|
+
* @returns {Promise<Buffer|string|null>} - The file contents, or `null` if the file doesn't exist.
|
|
4651
4823
|
*/
|
|
4652
4824
|
async read(filepath, options = {}) {
|
|
4653
4825
|
try {
|
|
@@ -4674,9 +4846,10 @@ class FileSystem {
|
|
|
4674
4846
|
/**
|
|
4675
4847
|
* Write a file (creating missing directories if need be) without throwing errors.
|
|
4676
4848
|
*
|
|
4677
|
-
* @param {string} filepath
|
|
4678
|
-
* @param {Buffer|Uint8Array|string} contents
|
|
4679
|
-
* @param {
|
|
4849
|
+
* @param {string} filepath - The path to the file.
|
|
4850
|
+
* @param {Buffer|Uint8Array|string} contents - The data to write.
|
|
4851
|
+
* @param {Object|string} [options] - Options for writing the file.
|
|
4852
|
+
* @returns {Promise<void>}
|
|
4680
4853
|
*/
|
|
4681
4854
|
async write(filepath, contents, options = {}) {
|
|
4682
4855
|
try {
|
|
@@ -4691,6 +4864,10 @@ class FileSystem {
|
|
|
4691
4864
|
|
|
4692
4865
|
/**
|
|
4693
4866
|
* Make a directory (or series of nested directories) without throwing an error if it already exists.
|
|
4867
|
+
*
|
|
4868
|
+
* @param {string} filepath - The path to the directory.
|
|
4869
|
+
* @param {boolean} [_selfCall=false] - Internal flag to prevent infinite recursion.
|
|
4870
|
+
* @returns {Promise<void>}
|
|
4694
4871
|
*/
|
|
4695
4872
|
async mkdir(filepath, _selfCall = false) {
|
|
4696
4873
|
try {
|
|
@@ -4717,6 +4894,9 @@ class FileSystem {
|
|
|
4717
4894
|
|
|
4718
4895
|
/**
|
|
4719
4896
|
* Delete a file without throwing an error if it is already deleted.
|
|
4897
|
+
*
|
|
4898
|
+
* @param {string} filepath - The path to the file.
|
|
4899
|
+
* @returns {Promise<void>}
|
|
4720
4900
|
*/
|
|
4721
4901
|
async rm(filepath) {
|
|
4722
4902
|
try {
|
|
@@ -4728,6 +4908,10 @@ class FileSystem {
|
|
|
4728
4908
|
|
|
4729
4909
|
/**
|
|
4730
4910
|
* Delete a directory without throwing an error if it is already deleted.
|
|
4911
|
+
*
|
|
4912
|
+
* @param {string} filepath - The path to the directory.
|
|
4913
|
+
* @param {Object} [opts] - Options for deleting the directory.
|
|
4914
|
+
* @returns {Promise<void>}
|
|
4731
4915
|
*/
|
|
4732
4916
|
async rmdir(filepath, opts) {
|
|
4733
4917
|
try {
|
|
@@ -4743,6 +4927,9 @@ class FileSystem {
|
|
|
4743
4927
|
|
|
4744
4928
|
/**
|
|
4745
4929
|
* Read a directory without throwing an error is the directory doesn't exist
|
|
4930
|
+
*
|
|
4931
|
+
* @param {string} filepath - The path to the directory.
|
|
4932
|
+
* @returns {Promise<string[]|null>} - An array of file names, or `null` if the path is not a directory.
|
|
4746
4933
|
*/
|
|
4747
4934
|
async readdir(filepath) {
|
|
4748
4935
|
try {
|
|
@@ -4758,10 +4945,13 @@ class FileSystem {
|
|
|
4758
4945
|
}
|
|
4759
4946
|
|
|
4760
4947
|
/**
|
|
4761
|
-
* Return a
|
|
4948
|
+
* Return a flat list of all the files nested inside a directory
|
|
4762
4949
|
*
|
|
4763
4950
|
* Based on an elegant concurrent recursive solution from SO
|
|
4764
4951
|
* https://stackoverflow.com/a/45130990/2168416
|
|
4952
|
+
*
|
|
4953
|
+
* @param {string} dir - The directory to read.
|
|
4954
|
+
* @returns {Promise<string[]>} - A flat list of all files in the directory.
|
|
4765
4955
|
*/
|
|
4766
4956
|
async readdirDeep(dir) {
|
|
4767
4957
|
const subdirs = await this._readdir(dir);
|
|
@@ -4779,6 +4969,9 @@ class FileSystem {
|
|
|
4779
4969
|
/**
|
|
4780
4970
|
* Return the Stats of a file/symlink if it exists, otherwise returns null.
|
|
4781
4971
|
* Rethrows errors that aren't related to file existence.
|
|
4972
|
+
*
|
|
4973
|
+
* @param {string} filename - The path to the file or symlink.
|
|
4974
|
+
* @returns {Promise<Object|null>} - The stats object, or `null` if the file doesn't exist.
|
|
4782
4975
|
*/
|
|
4783
4976
|
async lstat(filename) {
|
|
4784
4977
|
try {
|
|
@@ -4795,6 +4988,10 @@ class FileSystem {
|
|
|
4795
4988
|
/**
|
|
4796
4989
|
* Reads the contents of a symlink if it exists, otherwise returns null.
|
|
4797
4990
|
* Rethrows errors that aren't related to file existence.
|
|
4991
|
+
*
|
|
4992
|
+
* @param {string} filename - The path to the symlink.
|
|
4993
|
+
* @param {Object} [opts={ encoding: 'buffer' }] - Options for reading the symlink.
|
|
4994
|
+
* @returns {Promise<Buffer|null>} - The symlink target, or `null` if it doesn't exist.
|
|
4798
4995
|
*/
|
|
4799
4996
|
async readlink(filename, opts = { encoding: 'buffer' }) {
|
|
4800
4997
|
// Note: FileSystem.readlink returns a buffer by default
|
|
@@ -4812,6 +5009,10 @@ class FileSystem {
|
|
|
4812
5009
|
|
|
4813
5010
|
/**
|
|
4814
5011
|
* Write the contents of buffer to a symlink.
|
|
5012
|
+
*
|
|
5013
|
+
* @param {string} filename - The path to the symlink.
|
|
5014
|
+
* @param {Buffer} buffer - The symlink target.
|
|
5015
|
+
* @returns {Promise<void>}
|
|
4815
5016
|
*/
|
|
4816
5017
|
async writelink(filename, buffer) {
|
|
4817
5018
|
return this._symlink(buffer.toString('utf8'), filename)
|
|
@@ -4956,6 +5157,16 @@ async function abortMerge({
|
|
|
4956
5157
|
// I'm putting this in a Manager because I reckon it could benefit
|
|
4957
5158
|
// from a LOT of caching.
|
|
4958
5159
|
class GitIgnoreManager {
|
|
5160
|
+
/**
|
|
5161
|
+
* Determines whether a given file is ignored based on `.gitignore` rules and exclusion files.
|
|
5162
|
+
*
|
|
5163
|
+
* @param {Object} args
|
|
5164
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
5165
|
+
* @param {string} args.dir - The working directory.
|
|
5166
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
5167
|
+
* @param {string} args.filepath - The path of the file to check.
|
|
5168
|
+
* @returns {Promise<boolean>} - `true` if the file is ignored, `false` otherwise.
|
|
5169
|
+
*/
|
|
4959
5170
|
static async isIgnored({ fs, dir, gitdir = join(dir, '.git'), filepath }) {
|
|
4960
5171
|
// ALWAYS ignore ".git" folders.
|
|
4961
5172
|
if (basename(filepath) === '.git') return true
|
|
@@ -7463,22 +7674,33 @@ const stringifyBody = async res => {
|
|
|
7463
7674
|
};
|
|
7464
7675
|
|
|
7465
7676
|
class GitRemoteHTTP {
|
|
7677
|
+
/**
|
|
7678
|
+
* Returns the capabilities of the GitRemoteHTTP class.
|
|
7679
|
+
*
|
|
7680
|
+
* @returns {Promise<string[]>} - An array of supported capabilities.
|
|
7681
|
+
*/
|
|
7466
7682
|
static async capabilities() {
|
|
7467
7683
|
return ['discover', 'connect']
|
|
7468
7684
|
}
|
|
7469
7685
|
|
|
7470
7686
|
/**
|
|
7687
|
+
* Discovers references from a remote Git repository.
|
|
7688
|
+
*
|
|
7471
7689
|
* @param {Object} args
|
|
7472
|
-
* @param {HttpClient} args.http
|
|
7473
|
-
* @param {ProgressCallback} [args.onProgress]
|
|
7474
|
-
* @param {AuthCallback} [args.onAuth]
|
|
7475
|
-
* @param {AuthFailureCallback} [args.onAuthFailure]
|
|
7476
|
-
* @param {AuthSuccessCallback} [args.onAuthSuccess]
|
|
7477
|
-
* @param {string} [args.corsProxy]
|
|
7478
|
-
* @param {string} args.service
|
|
7479
|
-
* @param {string} args.url
|
|
7480
|
-
* @param {Object<string, string>} args.headers
|
|
7481
|
-
* @param {1 | 2} args.protocolVersion - Git
|
|
7690
|
+
* @param {HttpClient} args.http - The HTTP client to use for requests.
|
|
7691
|
+
* @param {ProgressCallback} [args.onProgress] - Callback for progress updates.
|
|
7692
|
+
* @param {AuthCallback} [args.onAuth] - Callback for providing authentication credentials.
|
|
7693
|
+
* @param {AuthFailureCallback} [args.onAuthFailure] - Callback for handling authentication failures.
|
|
7694
|
+
* @param {AuthSuccessCallback} [args.onAuthSuccess] - Callback for handling successful authentication.
|
|
7695
|
+
* @param {string} [args.corsProxy] - Optional CORS proxy URL.
|
|
7696
|
+
* @param {string} args.service - The Git service (e.g., "git-upload-pack").
|
|
7697
|
+
* @param {string} args.url - The URL of the remote repository.
|
|
7698
|
+
* @param {Object<string, string>} args.headers - HTTP headers to include in the request.
|
|
7699
|
+
* @param {1 | 2} args.protocolVersion - The Git protocol version to use.
|
|
7700
|
+
* @returns {Promise<Object>} - The parsed response from the remote repository.
|
|
7701
|
+
* @throws {HttpError} - If the HTTP request fails.
|
|
7702
|
+
* @throws {SmartHttpError} - If the response cannot be parsed.
|
|
7703
|
+
* @throws {UserCanceledError} - If the user cancels the operation.
|
|
7482
7704
|
*/
|
|
7483
7705
|
static async discover({
|
|
7484
7706
|
http,
|
|
@@ -7574,15 +7796,19 @@ class GitRemoteHTTP {
|
|
|
7574
7796
|
}
|
|
7575
7797
|
|
|
7576
7798
|
/**
|
|
7799
|
+
* Connects to a remote Git repository and sends a request.
|
|
7800
|
+
*
|
|
7577
7801
|
* @param {Object} args
|
|
7578
|
-
* @param {HttpClient} args.http
|
|
7579
|
-
* @param {ProgressCallback} [args.onProgress]
|
|
7580
|
-
* @param {string} [args.corsProxy]
|
|
7581
|
-
* @param {string} args.service
|
|
7582
|
-
* @param {string} args.url
|
|
7583
|
-
* @param {Object<string, string>} [args.headers]
|
|
7584
|
-
* @param {any} args.body
|
|
7585
|
-
* @param {any} args.auth
|
|
7802
|
+
* @param {HttpClient} args.http - The HTTP client to use for requests.
|
|
7803
|
+
* @param {ProgressCallback} [args.onProgress] - Callback for progress updates.
|
|
7804
|
+
* @param {string} [args.corsProxy] - Optional CORS proxy URL.
|
|
7805
|
+
* @param {string} args.service - The Git service (e.g., "git-upload-pack").
|
|
7806
|
+
* @param {string} args.url - The URL of the remote repository.
|
|
7807
|
+
* @param {Object<string, string>} [args.headers] - HTTP headers to include in the request.
|
|
7808
|
+
* @param {any} args.body - The request body to send.
|
|
7809
|
+
* @param {any} args.auth - Authentication credentials.
|
|
7810
|
+
* @returns {Promise<GitHttpResponse>} - The HTTP response from the remote repository.
|
|
7811
|
+
* @throws {HttpError} - If the HTTP request fails.
|
|
7586
7812
|
*/
|
|
7587
7813
|
static async connect({
|
|
7588
7814
|
http,
|
|
@@ -7620,6 +7846,47 @@ class GitRemoteHTTP {
|
|
|
7620
7846
|
}
|
|
7621
7847
|
}
|
|
7622
7848
|
|
|
7849
|
+
/**
|
|
7850
|
+
* A class for managing Git remotes and determining the appropriate remote helper for a given URL.
|
|
7851
|
+
*/
|
|
7852
|
+
class GitRemoteManager {
|
|
7853
|
+
/**
|
|
7854
|
+
* Determines the appropriate remote helper for the given URL.
|
|
7855
|
+
*
|
|
7856
|
+
* @param {Object} args
|
|
7857
|
+
* @param {string} args.url - The URL of the remote repository.
|
|
7858
|
+
* @returns {Object} - The remote helper class for the specified transport.
|
|
7859
|
+
* @throws {UrlParseError} - If the URL cannot be parsed.
|
|
7860
|
+
* @throws {UnknownTransportError} - If the transport is not supported.
|
|
7861
|
+
*/
|
|
7862
|
+
static getRemoteHelperFor({ url }) {
|
|
7863
|
+
// TODO: clean up the remoteHelper API and move into PluginCore
|
|
7864
|
+
const remoteHelpers = new Map();
|
|
7865
|
+
remoteHelpers.set('http', GitRemoteHTTP);
|
|
7866
|
+
remoteHelpers.set('https', GitRemoteHTTP);
|
|
7867
|
+
|
|
7868
|
+
const parts = parseRemoteUrl({ url });
|
|
7869
|
+
if (!parts) {
|
|
7870
|
+
throw new UrlParseError(url)
|
|
7871
|
+
}
|
|
7872
|
+
if (remoteHelpers.has(parts.transport)) {
|
|
7873
|
+
return remoteHelpers.get(parts.transport)
|
|
7874
|
+
}
|
|
7875
|
+
throw new UnknownTransportError(
|
|
7876
|
+
url,
|
|
7877
|
+
parts.transport,
|
|
7878
|
+
parts.transport === 'ssh' ? translateSSHtoHTTP(url) : undefined
|
|
7879
|
+
)
|
|
7880
|
+
}
|
|
7881
|
+
}
|
|
7882
|
+
|
|
7883
|
+
/**
|
|
7884
|
+
* Parses a remote URL and extracts its transport and address.
|
|
7885
|
+
*
|
|
7886
|
+
* @param {Object} args
|
|
7887
|
+
* @param {string} args.url - The URL of the remote repository.
|
|
7888
|
+
* @returns {Object|undefined} - An object containing the transport and address, or undefined if parsing fails.
|
|
7889
|
+
*/
|
|
7623
7890
|
function parseRemoteUrl({ url }) {
|
|
7624
7891
|
// the stupid "shorter scp-like syntax"
|
|
7625
7892
|
if (url.startsWith('git@')) {
|
|
@@ -7657,31 +7924,17 @@ function parseRemoteUrl({ url }) {
|
|
|
7657
7924
|
}
|
|
7658
7925
|
}
|
|
7659
7926
|
|
|
7660
|
-
class GitRemoteManager {
|
|
7661
|
-
static getRemoteHelperFor({ url }) {
|
|
7662
|
-
// TODO: clean up the remoteHelper API and move into PluginCore
|
|
7663
|
-
const remoteHelpers = new Map();
|
|
7664
|
-
remoteHelpers.set('http', GitRemoteHTTP);
|
|
7665
|
-
remoteHelpers.set('https', GitRemoteHTTP);
|
|
7666
|
-
|
|
7667
|
-
const parts = parseRemoteUrl({ url });
|
|
7668
|
-
if (!parts) {
|
|
7669
|
-
throw new UrlParseError(url)
|
|
7670
|
-
}
|
|
7671
|
-
if (remoteHelpers.has(parts.transport)) {
|
|
7672
|
-
return remoteHelpers.get(parts.transport)
|
|
7673
|
-
}
|
|
7674
|
-
throw new UnknownTransportError(
|
|
7675
|
-
url,
|
|
7676
|
-
parts.transport,
|
|
7677
|
-
parts.transport === 'ssh' ? translateSSHtoHTTP(url) : undefined
|
|
7678
|
-
)
|
|
7679
|
-
}
|
|
7680
|
-
}
|
|
7681
|
-
|
|
7682
7927
|
let lock$2 = null;
|
|
7683
7928
|
|
|
7684
7929
|
class GitShallowManager {
|
|
7930
|
+
/**
|
|
7931
|
+
* Reads the `shallow` file in the Git repository and returns a set of object IDs (OIDs).
|
|
7932
|
+
*
|
|
7933
|
+
* @param {Object} args
|
|
7934
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
7935
|
+
* @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
7936
|
+
* @returns {Promise<Set<string>>} - A set of shallow object IDs.
|
|
7937
|
+
*/
|
|
7685
7938
|
static async read({ fs, gitdir }) {
|
|
7686
7939
|
if (lock$2 === null) lock$2 = new AsyncLock();
|
|
7687
7940
|
const filepath = join(gitdir, 'shallow');
|
|
@@ -7698,6 +7951,16 @@ class GitShallowManager {
|
|
|
7698
7951
|
return oids
|
|
7699
7952
|
}
|
|
7700
7953
|
|
|
7954
|
+
/**
|
|
7955
|
+
* Writes a set of object IDs (OIDs) to the `shallow` file in the Git repository.
|
|
7956
|
+
* If the set is empty, the `shallow` file is removed.
|
|
7957
|
+
*
|
|
7958
|
+
* @param {Object} args
|
|
7959
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
7960
|
+
* @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
7961
|
+
* @param {Set<string>} args.oids - A set of shallow object IDs to write.
|
|
7962
|
+
* @returns {Promise<void>}
|
|
7963
|
+
*/
|
|
7701
7964
|
static async write({ fs, gitdir, oids }) {
|
|
7702
7965
|
if (lock$2 === null) lock$2 = new AsyncLock();
|
|
7703
7966
|
const filepath = join(gitdir, 'shallow');
|
|
@@ -7797,8 +8060,8 @@ function filterCapabilities(server, client) {
|
|
|
7797
8060
|
|
|
7798
8061
|
const pkg = {
|
|
7799
8062
|
name: 'isomorphic-git',
|
|
7800
|
-
version: '1.
|
|
7801
|
-
agent: 'git/isomorphic-git@1.
|
|
8063
|
+
version: '1.33.1',
|
|
8064
|
+
agent: 'git/isomorphic-git@1.33.1',
|
|
7802
8065
|
};
|
|
7803
8066
|
|
|
7804
8067
|
class FIFO {
|
|
@@ -14547,6 +14810,14 @@ async function applyTreeChanges({
|
|
|
14547
14810
|
}
|
|
14548
14811
|
|
|
14549
14812
|
class GitStashManager {
|
|
14813
|
+
/**
|
|
14814
|
+
* Creates an instance of GitStashManager.
|
|
14815
|
+
*
|
|
14816
|
+
* @param {Object} args
|
|
14817
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
14818
|
+
* @param {string} args.dir - The working directory.
|
|
14819
|
+
* @param {string}[args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
14820
|
+
*/
|
|
14550
14821
|
constructor({ fs, dir, gitdir = join(dir, '.git') }) {
|
|
14551
14822
|
Object.assign(this, {
|
|
14552
14823
|
fs,
|
|
@@ -14556,22 +14827,48 @@ class GitStashManager {
|
|
|
14556
14827
|
});
|
|
14557
14828
|
}
|
|
14558
14829
|
|
|
14830
|
+
/**
|
|
14831
|
+
* Gets the reference name for the stash.
|
|
14832
|
+
*
|
|
14833
|
+
* @returns {string} - The stash reference name.
|
|
14834
|
+
*/
|
|
14559
14835
|
static get refStash() {
|
|
14560
14836
|
return 'refs/stash'
|
|
14561
14837
|
}
|
|
14562
14838
|
|
|
14839
|
+
/**
|
|
14840
|
+
* Gets the reference name for the stash reflogs.
|
|
14841
|
+
*
|
|
14842
|
+
* @returns {string} - The stash reflogs reference name.
|
|
14843
|
+
*/
|
|
14563
14844
|
static get refLogsStash() {
|
|
14564
14845
|
return 'logs/refs/stash'
|
|
14565
14846
|
}
|
|
14566
14847
|
|
|
14848
|
+
/**
|
|
14849
|
+
* Gets the file path for the stash reference.
|
|
14850
|
+
*
|
|
14851
|
+
* @returns {string} - The file path for the stash reference.
|
|
14852
|
+
*/
|
|
14567
14853
|
get refStashPath() {
|
|
14568
14854
|
return join(this.gitdir, GitStashManager.refStash)
|
|
14569
14855
|
}
|
|
14570
14856
|
|
|
14857
|
+
/**
|
|
14858
|
+
* Gets the file path for the stash reflogs.
|
|
14859
|
+
*
|
|
14860
|
+
* @returns {string} - The file path for the stash reflogs.
|
|
14861
|
+
*/
|
|
14571
14862
|
get refLogsStashPath() {
|
|
14572
14863
|
return join(this.gitdir, GitStashManager.refLogsStash)
|
|
14573
14864
|
}
|
|
14574
14865
|
|
|
14866
|
+
/**
|
|
14867
|
+
* Retrieves the author information for the stash.
|
|
14868
|
+
*
|
|
14869
|
+
* @returns {Promise<Object>} - The author object.
|
|
14870
|
+
* @throws {MissingNameError} - If the author name is missing.
|
|
14871
|
+
*/
|
|
14575
14872
|
async getAuthor() {
|
|
14576
14873
|
if (!this._author) {
|
|
14577
14874
|
this._author = await normalizeAuthorObject({
|
|
@@ -14584,6 +14881,13 @@ class GitStashManager {
|
|
|
14584
14881
|
return this._author
|
|
14585
14882
|
}
|
|
14586
14883
|
|
|
14884
|
+
/**
|
|
14885
|
+
* Gets the SHA of a stash entry by its index.
|
|
14886
|
+
*
|
|
14887
|
+
* @param {number} refIdx - The index of the stash entry.
|
|
14888
|
+
* @param {string[]} [stashEntries] - Optional preloaded stash entries.
|
|
14889
|
+
* @returns {Promise<string|null>} - The SHA of the stash entry or `null` if not found.
|
|
14890
|
+
*/
|
|
14587
14891
|
async getStashSHA(refIdx, stashEntries) {
|
|
14588
14892
|
if (!(await this.fs.exists(this.refStashPath))) {
|
|
14589
14893
|
return null
|
|
@@ -14594,6 +14898,15 @@ class GitStashManager {
|
|
|
14594
14898
|
return entries[refIdx].split(' ')[1]
|
|
14595
14899
|
}
|
|
14596
14900
|
|
|
14901
|
+
/**
|
|
14902
|
+
* Writes a stash commit to the repository.
|
|
14903
|
+
*
|
|
14904
|
+
* @param {Object} args
|
|
14905
|
+
* @param {string} args.message - The commit message.
|
|
14906
|
+
* @param {string} args.tree - The tree object ID.
|
|
14907
|
+
* @param {string[]} args.parent - The parent commit object IDs.
|
|
14908
|
+
* @returns {Promise<string>} - The object ID of the written commit.
|
|
14909
|
+
*/
|
|
14597
14910
|
async writeStashCommit({ message, tree, parent }) {
|
|
14598
14911
|
return _writeCommit({
|
|
14599
14912
|
fs: this.fs,
|
|
@@ -14608,6 +14921,13 @@ class GitStashManager {
|
|
|
14608
14921
|
})
|
|
14609
14922
|
}
|
|
14610
14923
|
|
|
14924
|
+
/**
|
|
14925
|
+
* Reads a stash commit by its index.
|
|
14926
|
+
*
|
|
14927
|
+
* @param {number} refIdx - The index of the stash entry.
|
|
14928
|
+
* @returns {Promise<Object>} - The stash commit object.
|
|
14929
|
+
* @throws {InvalidRefNameError} - If the index is invalid.
|
|
14930
|
+
*/
|
|
14611
14931
|
async readStashCommit(refIdx) {
|
|
14612
14932
|
const stashEntries = await this.readStashReflogs({ parsed: false });
|
|
14613
14933
|
if (refIdx !== 0) {
|
|
@@ -14634,6 +14954,12 @@ class GitStashManager {
|
|
|
14634
14954
|
})
|
|
14635
14955
|
}
|
|
14636
14956
|
|
|
14957
|
+
/**
|
|
14958
|
+
* Writes a stash reference to the repository.
|
|
14959
|
+
*
|
|
14960
|
+
* @param {string} stashCommit - The object ID of the stash commit.
|
|
14961
|
+
* @returns {Promise<void>}
|
|
14962
|
+
*/
|
|
14637
14963
|
async writeStashRef(stashCommit) {
|
|
14638
14964
|
return GitRefManager.writeRef({
|
|
14639
14965
|
fs: this.fs,
|
|
@@ -14643,6 +14969,14 @@ class GitStashManager {
|
|
|
14643
14969
|
})
|
|
14644
14970
|
}
|
|
14645
14971
|
|
|
14972
|
+
/**
|
|
14973
|
+
* Writes a reflog entry for a stash commit.
|
|
14974
|
+
*
|
|
14975
|
+
* @param {Object} args
|
|
14976
|
+
* @param {string} args.stashCommit - The object ID of the stash commit.
|
|
14977
|
+
* @param {string} args.message - The reflog message.
|
|
14978
|
+
* @returns {Promise<void>}
|
|
14979
|
+
*/
|
|
14646
14980
|
async writeStashReflogEntry({ stashCommit, message }) {
|
|
14647
14981
|
const author = await this.getAuthor();
|
|
14648
14982
|
const entry = GitRefStash.createStashReflogEntry(
|
|
@@ -14660,6 +14994,13 @@ class GitStashManager {
|
|
|
14660
14994
|
});
|
|
14661
14995
|
}
|
|
14662
14996
|
|
|
14997
|
+
/**
|
|
14998
|
+
* Reads the stash reflogs.
|
|
14999
|
+
*
|
|
15000
|
+
* @param {Object} args
|
|
15001
|
+
* @param {boolean} [args.parsed=false] - Whether to parse the reflog entries.
|
|
15002
|
+
* @returns {Promise<string[]|Object[]>} - The reflog entries as strings or parsed objects.
|
|
15003
|
+
*/
|
|
14663
15004
|
async readStashReflogs({ parsed = false }) {
|
|
14664
15005
|
if (!(await this.fs.exists(this.refLogsStashPath))) {
|
|
14665
15006
|
return []
|