isomorphic-git 1.32.3 → 1.33.0
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 +410 -69
- package/index.js +410 -69
- package/index.umd.min.js +2 -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 +9 -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 +24 -2
- package/size_report.html +1 -1
package/index.cjs
CHANGED
|
@@ -962,8 +962,6 @@ function compareStats(entry, stats, filemode = true, trustino = true) {
|
|
|
962
962
|
return staleness
|
|
963
963
|
}
|
|
964
964
|
|
|
965
|
-
// import LockManager from 'travix-lock-manager'
|
|
966
|
-
|
|
967
965
|
// import Lock from '../utils.js'
|
|
968
966
|
|
|
969
967
|
// const lm = new LockManager()
|
|
@@ -971,6 +969,10 @@ let lock = null;
|
|
|
971
969
|
|
|
972
970
|
const IndexCache = Symbol('IndexCache');
|
|
973
971
|
|
|
972
|
+
/**
|
|
973
|
+
* Creates a cache object to store GitIndex and file stats.
|
|
974
|
+
* @returns {object} A cache object with `map` and `stats` properties.
|
|
975
|
+
*/
|
|
974
976
|
function createCache() {
|
|
975
977
|
return {
|
|
976
978
|
map: new Map(),
|
|
@@ -978,6 +980,13 @@ function createCache() {
|
|
|
978
980
|
}
|
|
979
981
|
}
|
|
980
982
|
|
|
983
|
+
/**
|
|
984
|
+
* Updates the cached index file by reading the file system and parsing the Git index.
|
|
985
|
+
* @param {FSClient} fs - A file system implementation.
|
|
986
|
+
* @param {string} filepath - The path to the Git index file.
|
|
987
|
+
* @param {object} cache - The cache object to update.
|
|
988
|
+
* @returns {Promise<void>}
|
|
989
|
+
*/
|
|
981
990
|
async function updateCachedIndexFile(fs, filepath, cache) {
|
|
982
991
|
const [stat, rawIndexFile] = await Promise.all([
|
|
983
992
|
fs.lstat(filepath),
|
|
@@ -991,7 +1000,13 @@ async function updateCachedIndexFile(fs, filepath, cache) {
|
|
|
991
1000
|
cache.stats.set(filepath, stat);
|
|
992
1001
|
}
|
|
993
1002
|
|
|
994
|
-
|
|
1003
|
+
/**
|
|
1004
|
+
* Determines whether the cached index file is stale by comparing file stats.
|
|
1005
|
+
* @param {FSClient} fs - A file system implementation.
|
|
1006
|
+
* @param {string} filepath - The path to the Git index file.
|
|
1007
|
+
* @param {object} cache - The cache object containing file stats.
|
|
1008
|
+
* @returns {Promise<boolean>} `true` if the index file is stale, otherwise `false`.
|
|
1009
|
+
*/
|
|
995
1010
|
async function isIndexStale(fs, filepath, cache) {
|
|
996
1011
|
const savedStats = cache.stats.get(filepath);
|
|
997
1012
|
if (savedStats === undefined) return true
|
|
@@ -1004,13 +1019,16 @@ async function isIndexStale(fs, filepath, cache) {
|
|
|
1004
1019
|
|
|
1005
1020
|
class GitIndexManager {
|
|
1006
1021
|
/**
|
|
1022
|
+
* Manages access to the Git index file, ensuring thread-safe operations and caching.
|
|
1007
1023
|
*
|
|
1008
|
-
* @param {object} opts
|
|
1009
|
-
* @param {
|
|
1010
|
-
* @param {string} opts.gitdir
|
|
1011
|
-
* @param {object} opts.cache
|
|
1012
|
-
* @param {
|
|
1013
|
-
* @param {function(GitIndex): any} closure
|
|
1024
|
+
* @param {object} opts - Options for acquiring the Git index.
|
|
1025
|
+
* @param {FSClient} opts.fs - A file system implementation.
|
|
1026
|
+
* @param {string} opts.gitdir - The path to the `.git` directory.
|
|
1027
|
+
* @param {object} opts.cache - A shared cache object for storing index data.
|
|
1028
|
+
* @param {boolean} [opts.allowUnmerged=true] - Whether to allow unmerged paths in the index.
|
|
1029
|
+
* @param {function(GitIndex): any} closure - A function to execute with the Git index.
|
|
1030
|
+
* @returns {Promise<any>} The result of the closure function.
|
|
1031
|
+
* @throws {UnmergedPathsError} If unmerged paths exist and `allowUnmerged` is `false`.
|
|
1014
1032
|
*/
|
|
1015
1033
|
static async acquire({ fs, gitdir, cache, allowUnmerged = true }, closure) {
|
|
1016
1034
|
if (!cache[IndexCache]) {
|
|
@@ -1791,7 +1809,18 @@ class GitConfig {
|
|
|
1791
1809
|
}
|
|
1792
1810
|
}
|
|
1793
1811
|
|
|
1812
|
+
/**
|
|
1813
|
+
* Manages access to the Git configuration file, providing methods to read and save configurations.
|
|
1814
|
+
*/
|
|
1794
1815
|
class GitConfigManager {
|
|
1816
|
+
/**
|
|
1817
|
+
* Reads the Git configuration file from the specified `.git` directory.
|
|
1818
|
+
*
|
|
1819
|
+
* @param {object} opts - Options for reading the Git configuration.
|
|
1820
|
+
* @param {FSClient} opts.fs - A file system implementation.
|
|
1821
|
+
* @param {string} opts.gitdir - The path to the `.git` directory.
|
|
1822
|
+
* @returns {Promise<GitConfig>} A `GitConfig` object representing the parsed configuration.
|
|
1823
|
+
*/
|
|
1795
1824
|
static async get({ fs, gitdir }) {
|
|
1796
1825
|
// We can improve efficiency later if needed.
|
|
1797
1826
|
// TODO: read from full list of git config files
|
|
@@ -1799,6 +1828,15 @@ class GitConfigManager {
|
|
|
1799
1828
|
return GitConfig.from(text)
|
|
1800
1829
|
}
|
|
1801
1830
|
|
|
1831
|
+
/**
|
|
1832
|
+
* Saves the provided Git configuration to the specified `.git` directory.
|
|
1833
|
+
*
|
|
1834
|
+
* @param {object} opts - Options for saving the Git configuration.
|
|
1835
|
+
* @param {FSClient} opts.fs - A file system implementation.
|
|
1836
|
+
* @param {string} opts.gitdir - The path to the `.git` directory.
|
|
1837
|
+
* @param {GitConfig} opts.config - The `GitConfig` object to save.
|
|
1838
|
+
* @returns {Promise<void>} Resolves when the configuration has been successfully saved.
|
|
1839
|
+
*/
|
|
1802
1840
|
static async save({ fs, gitdir, config }) {
|
|
1803
1841
|
// We can improve efficiency later if needed.
|
|
1804
1842
|
// TODO: handle saving to the correct global/user/repo location
|
|
@@ -1808,8 +1846,6 @@ class GitConfigManager {
|
|
|
1808
1846
|
}
|
|
1809
1847
|
}
|
|
1810
1848
|
|
|
1811
|
-
// This is a convenience wrapper for reading and writing files in the 'refs' directory.
|
|
1812
|
-
|
|
1813
1849
|
// @see https://git-scm.com/docs/git-rev-parse.html#_specifying_revisions
|
|
1814
1850
|
const refpaths = ref => [
|
|
1815
1851
|
`${ref}`,
|
|
@@ -1830,7 +1866,25 @@ async function acquireLock(ref, callback) {
|
|
|
1830
1866
|
return lock$1.acquire(ref, callback)
|
|
1831
1867
|
}
|
|
1832
1868
|
|
|
1869
|
+
/**
|
|
1870
|
+
* A class for managing Git references, including reading, writing, deleting, and resolving refs.
|
|
1871
|
+
*/
|
|
1833
1872
|
class GitRefManager {
|
|
1873
|
+
/**
|
|
1874
|
+
* Updates remote refs based on the provided refspecs and options.
|
|
1875
|
+
*
|
|
1876
|
+
* @param {Object} args
|
|
1877
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
1878
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
1879
|
+
* @param {string} args.remote - The name of the remote.
|
|
1880
|
+
* @param {Map<string, string>} args.refs - A map of refs to their object IDs.
|
|
1881
|
+
* @param {Map<string, string>} args.symrefs - A map of symbolic refs.
|
|
1882
|
+
* @param {boolean} args.tags - Whether to fetch tags.
|
|
1883
|
+
* @param {string[]} [args.refspecs = undefined] - The refspecs to use.
|
|
1884
|
+
* @param {boolean} [args.prune = false] - Whether to prune stale refs.
|
|
1885
|
+
* @param {boolean} [args.pruneTags = false] - Whether to prune tags.
|
|
1886
|
+
* @returns {Promise<Object>} - An object containing pruned refs.
|
|
1887
|
+
*/
|
|
1834
1888
|
static async updateRemoteRefs({
|
|
1835
1889
|
fs,
|
|
1836
1890
|
gitdir,
|
|
@@ -1943,6 +1997,16 @@ class GitRefManager {
|
|
|
1943
1997
|
return { pruned }
|
|
1944
1998
|
}
|
|
1945
1999
|
|
|
2000
|
+
/**
|
|
2001
|
+
* Writes a ref to the file system.
|
|
2002
|
+
*
|
|
2003
|
+
* @param {Object} args
|
|
2004
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2005
|
+
* @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2006
|
+
* @param {string} args.ref - The ref to write.
|
|
2007
|
+
* @param {string} args.value - The object ID to write.
|
|
2008
|
+
* @returns {Promise<void>}
|
|
2009
|
+
*/
|
|
1946
2010
|
// TODO: make this less crude?
|
|
1947
2011
|
static async writeRef({ fs, gitdir, ref, value }) {
|
|
1948
2012
|
// Validate input
|
|
@@ -1954,16 +2018,44 @@ class GitRefManager {
|
|
|
1954
2018
|
);
|
|
1955
2019
|
}
|
|
1956
2020
|
|
|
2021
|
+
/**
|
|
2022
|
+
* Writes a symbolic ref to the file system.
|
|
2023
|
+
*
|
|
2024
|
+
* @param {Object} args
|
|
2025
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2026
|
+
* @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2027
|
+
* @param {string} args.ref - The ref to write.
|
|
2028
|
+
* @param {string} args.value - The target ref.
|
|
2029
|
+
* @returns {Promise<void>}
|
|
2030
|
+
*/
|
|
1957
2031
|
static async writeSymbolicRef({ fs, gitdir, ref, value }) {
|
|
1958
2032
|
await acquireLock(ref, async () =>
|
|
1959
2033
|
fs.write(pathBrowserify.join(gitdir, ref), 'ref: ' + `${value.trim()}\n`, 'utf8')
|
|
1960
2034
|
);
|
|
1961
2035
|
}
|
|
1962
2036
|
|
|
2037
|
+
/**
|
|
2038
|
+
* Deletes a single ref.
|
|
2039
|
+
*
|
|
2040
|
+
* @param {Object} args
|
|
2041
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2042
|
+
* @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2043
|
+
* @param {string} args.ref - The ref to delete.
|
|
2044
|
+
* @returns {Promise<void>}
|
|
2045
|
+
*/
|
|
1963
2046
|
static async deleteRef({ fs, gitdir, ref }) {
|
|
1964
2047
|
return GitRefManager.deleteRefs({ fs, gitdir, refs: [ref] })
|
|
1965
2048
|
}
|
|
1966
2049
|
|
|
2050
|
+
/**
|
|
2051
|
+
* Deletes multiple refs.
|
|
2052
|
+
*
|
|
2053
|
+
* @param {Object} args
|
|
2054
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2055
|
+
* @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2056
|
+
* @param {string[]} args.refs - The refs to delete.
|
|
2057
|
+
* @returns {Promise<void>}
|
|
2058
|
+
*/
|
|
1967
2059
|
static async deleteRefs({ fs, gitdir, refs }) {
|
|
1968
2060
|
// Delete regular ref
|
|
1969
2061
|
await Promise.all(refs.map(ref => fs.rm(pathBrowserify.join(gitdir, ref))));
|
|
@@ -1987,12 +2079,14 @@ class GitRefManager {
|
|
|
1987
2079
|
}
|
|
1988
2080
|
|
|
1989
2081
|
/**
|
|
1990
|
-
*
|
|
1991
|
-
*
|
|
1992
|
-
* @param {
|
|
1993
|
-
* @param {
|
|
1994
|
-
* @param {
|
|
1995
|
-
* @
|
|
2082
|
+
* Resolves a ref to its object ID.
|
|
2083
|
+
*
|
|
2084
|
+
* @param {Object} args
|
|
2085
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2086
|
+
* @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2087
|
+
* @param {string} args.ref - The ref to resolve.
|
|
2088
|
+
* @param {number} [args.depth = undefined] - The maximum depth to resolve symbolic refs.
|
|
2089
|
+
* @returns {Promise<string>} - The resolved object ID.
|
|
1996
2090
|
*/
|
|
1997
2091
|
static async resolve({ fs, gitdir, ref, depth = undefined }) {
|
|
1998
2092
|
if (depth !== undefined) {
|
|
@@ -2031,6 +2125,15 @@ class GitRefManager {
|
|
|
2031
2125
|
throw new NotFoundError(ref)
|
|
2032
2126
|
}
|
|
2033
2127
|
|
|
2128
|
+
/**
|
|
2129
|
+
* Checks if a ref exists.
|
|
2130
|
+
*
|
|
2131
|
+
* @param {Object} args
|
|
2132
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2133
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2134
|
+
* @param {string} args.ref - The ref to check.
|
|
2135
|
+
* @returns {Promise<boolean>} - True if the ref exists, false otherwise.
|
|
2136
|
+
*/
|
|
2034
2137
|
static async exists({ fs, gitdir, ref }) {
|
|
2035
2138
|
try {
|
|
2036
2139
|
await GitRefManager.expand({ fs, gitdir, ref });
|
|
@@ -2040,6 +2143,15 @@ class GitRefManager {
|
|
|
2040
2143
|
}
|
|
2041
2144
|
}
|
|
2042
2145
|
|
|
2146
|
+
/**
|
|
2147
|
+
* Expands a ref to its full name.
|
|
2148
|
+
*
|
|
2149
|
+
* @param {Object} args
|
|
2150
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2151
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2152
|
+
* @param {string} args.ref - The ref to expand.
|
|
2153
|
+
* @returns {Promise<string>} - The full ref name.
|
|
2154
|
+
*/
|
|
2043
2155
|
static async expand({ fs, gitdir, ref }) {
|
|
2044
2156
|
// Is it a complete and valid SHA?
|
|
2045
2157
|
if (ref.length === 40 && /[0-9a-f]{40}/.test(ref)) {
|
|
@@ -2060,6 +2172,14 @@ class GitRefManager {
|
|
|
2060
2172
|
throw new NotFoundError(ref)
|
|
2061
2173
|
}
|
|
2062
2174
|
|
|
2175
|
+
/**
|
|
2176
|
+
* Expands a ref against a provided map.
|
|
2177
|
+
*
|
|
2178
|
+
* @param {Object} args
|
|
2179
|
+
* @param {string} args.ref - The ref to expand.
|
|
2180
|
+
* @param {Map<string, string>} args.map - The map of refs.
|
|
2181
|
+
* @returns {Promise<string>} - The expanded ref.
|
|
2182
|
+
*/
|
|
2063
2183
|
static async expandAgainstMap({ ref, map }) {
|
|
2064
2184
|
// Look in all the proper paths, in this order
|
|
2065
2185
|
const allpaths = refpaths(ref);
|
|
@@ -2070,6 +2190,16 @@ class GitRefManager {
|
|
|
2070
2190
|
throw new NotFoundError(ref)
|
|
2071
2191
|
}
|
|
2072
2192
|
|
|
2193
|
+
/**
|
|
2194
|
+
* Resolves a ref against a provided map.
|
|
2195
|
+
*
|
|
2196
|
+
* @param {Object} args
|
|
2197
|
+
* @param {string} args.ref - The ref to resolve.
|
|
2198
|
+
* @param {string} [args.fullref = args.ref] - The full ref name.
|
|
2199
|
+
* @param {number} [args.depth = undefined] - The maximum depth to resolve symbolic refs.
|
|
2200
|
+
* @param {Map<string, string>} args.map - The map of refs.
|
|
2201
|
+
* @returns {Object} - An object containing the full ref and its object ID.
|
|
2202
|
+
*/
|
|
2073
2203
|
static resolveAgainstMap({ ref, fullref = ref, depth = undefined, map }) {
|
|
2074
2204
|
if (depth !== undefined) {
|
|
2075
2205
|
depth--;
|
|
@@ -2103,6 +2233,14 @@ class GitRefManager {
|
|
|
2103
2233
|
throw new NotFoundError(ref)
|
|
2104
2234
|
}
|
|
2105
2235
|
|
|
2236
|
+
/**
|
|
2237
|
+
* Reads the packed refs file and returns a map of refs.
|
|
2238
|
+
*
|
|
2239
|
+
* @param {Object} args
|
|
2240
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2241
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2242
|
+
* @returns {Promise<Map<string, string>>} - A map of packed refs.
|
|
2243
|
+
*/
|
|
2106
2244
|
static async packedRefs({ fs, gitdir }) {
|
|
2107
2245
|
const text = await acquireLock('packed-refs', async () =>
|
|
2108
2246
|
fs.read(`${gitdir}/packed-refs`, { encoding: 'utf8' })
|
|
@@ -2111,7 +2249,15 @@ class GitRefManager {
|
|
|
2111
2249
|
return packed.refs
|
|
2112
2250
|
}
|
|
2113
2251
|
|
|
2114
|
-
|
|
2252
|
+
/**
|
|
2253
|
+
* Lists all refs matching a given filepath prefix.
|
|
2254
|
+
*
|
|
2255
|
+
* @param {Object} args
|
|
2256
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2257
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2258
|
+
* @param {string} args.filepath - The filepath prefix to match.
|
|
2259
|
+
* @returns {Promise<string[]>} - A sorted list of refs.
|
|
2260
|
+
*/
|
|
2115
2261
|
static async listRefs({ fs, gitdir, filepath }) {
|
|
2116
2262
|
const packedMap = GitRefManager.packedRefs({ fs, gitdir });
|
|
2117
2263
|
let files = null;
|
|
@@ -2138,6 +2284,15 @@ class GitRefManager {
|
|
|
2138
2284
|
return files
|
|
2139
2285
|
}
|
|
2140
2286
|
|
|
2287
|
+
/**
|
|
2288
|
+
* Lists all branches, optionally filtered by remote.
|
|
2289
|
+
*
|
|
2290
|
+
* @param {Object} args
|
|
2291
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2292
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2293
|
+
* @param {string} [args.remote] - The remote to filter branches by.
|
|
2294
|
+
* @returns {Promise<string[]>} - A list of branch names.
|
|
2295
|
+
*/
|
|
2141
2296
|
static async listBranches({ fs, gitdir, remote }) {
|
|
2142
2297
|
if (remote) {
|
|
2143
2298
|
return GitRefManager.listRefs({
|
|
@@ -2150,6 +2305,14 @@ class GitRefManager {
|
|
|
2150
2305
|
}
|
|
2151
2306
|
}
|
|
2152
2307
|
|
|
2308
|
+
/**
|
|
2309
|
+
* Lists all tags.
|
|
2310
|
+
*
|
|
2311
|
+
* @param {Object} args
|
|
2312
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
2313
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
2314
|
+
* @returns {Promise<string[]>} - A list of tag names.
|
|
2315
|
+
*/
|
|
2153
2316
|
static async listTags({ fs, gitdir }) {
|
|
2154
2317
|
const tags = await GitRefManager.listRefs({
|
|
2155
2318
|
fs,
|
|
@@ -4610,9 +4773,15 @@ function bindFs(target, fs) {
|
|
|
4610
4773
|
}
|
|
4611
4774
|
|
|
4612
4775
|
/**
|
|
4613
|
-
*
|
|
4776
|
+
* A wrapper class for file system operations, providing a consistent API for both promise-based
|
|
4777
|
+
* and callback-based file systems. It includes utility methods for common file system tasks.
|
|
4614
4778
|
*/
|
|
4615
4779
|
class FileSystem {
|
|
4780
|
+
/**
|
|
4781
|
+
* Creates an instance of FileSystem.
|
|
4782
|
+
*
|
|
4783
|
+
* @param {Object} fs - A file system implementation to wrap.
|
|
4784
|
+
*/
|
|
4616
4785
|
constructor(fs) {
|
|
4617
4786
|
if (typeof fs._original_unwrapped_fs !== 'undefined') return fs
|
|
4618
4787
|
|
|
@@ -4628,6 +4797,10 @@ class FileSystem {
|
|
|
4628
4797
|
/**
|
|
4629
4798
|
* Return true if a file exists, false if it doesn't exist.
|
|
4630
4799
|
* Rethrows errors that aren't related to file existence.
|
|
4800
|
+
*
|
|
4801
|
+
* @param {string} filepath - The path to the file.
|
|
4802
|
+
* @param {Object} [options] - Additional options.
|
|
4803
|
+
* @returns {Promise<boolean>} - `true` if the file exists, `false` otherwise.
|
|
4631
4804
|
*/
|
|
4632
4805
|
async exists(filepath, options = {}) {
|
|
4633
4806
|
try {
|
|
@@ -4650,10 +4823,9 @@ class FileSystem {
|
|
|
4650
4823
|
/**
|
|
4651
4824
|
* Return the contents of a file if it exists, otherwise returns null.
|
|
4652
4825
|
*
|
|
4653
|
-
* @param {string} filepath
|
|
4654
|
-
* @param {
|
|
4655
|
-
*
|
|
4656
|
-
* @returns {Promise<Buffer|string|null>}
|
|
4826
|
+
* @param {string} filepath - The path to the file.
|
|
4827
|
+
* @param {Object} [options] - Options for reading the file.
|
|
4828
|
+
* @returns {Promise<Buffer|string|null>} - The file contents, or `null` if the file doesn't exist.
|
|
4657
4829
|
*/
|
|
4658
4830
|
async read(filepath, options = {}) {
|
|
4659
4831
|
try {
|
|
@@ -4680,9 +4852,10 @@ class FileSystem {
|
|
|
4680
4852
|
/**
|
|
4681
4853
|
* Write a file (creating missing directories if need be) without throwing errors.
|
|
4682
4854
|
*
|
|
4683
|
-
* @param {string} filepath
|
|
4684
|
-
* @param {Buffer|Uint8Array|string} contents
|
|
4685
|
-
* @param {
|
|
4855
|
+
* @param {string} filepath - The path to the file.
|
|
4856
|
+
* @param {Buffer|Uint8Array|string} contents - The data to write.
|
|
4857
|
+
* @param {Object|string} [options] - Options for writing the file.
|
|
4858
|
+
* @returns {Promise<void>}
|
|
4686
4859
|
*/
|
|
4687
4860
|
async write(filepath, contents, options = {}) {
|
|
4688
4861
|
try {
|
|
@@ -4697,6 +4870,10 @@ class FileSystem {
|
|
|
4697
4870
|
|
|
4698
4871
|
/**
|
|
4699
4872
|
* Make a directory (or series of nested directories) without throwing an error if it already exists.
|
|
4873
|
+
*
|
|
4874
|
+
* @param {string} filepath - The path to the directory.
|
|
4875
|
+
* @param {boolean} [_selfCall=false] - Internal flag to prevent infinite recursion.
|
|
4876
|
+
* @returns {Promise<void>}
|
|
4700
4877
|
*/
|
|
4701
4878
|
async mkdir(filepath, _selfCall = false) {
|
|
4702
4879
|
try {
|
|
@@ -4723,6 +4900,9 @@ class FileSystem {
|
|
|
4723
4900
|
|
|
4724
4901
|
/**
|
|
4725
4902
|
* Delete a file without throwing an error if it is already deleted.
|
|
4903
|
+
*
|
|
4904
|
+
* @param {string} filepath - The path to the file.
|
|
4905
|
+
* @returns {Promise<void>}
|
|
4726
4906
|
*/
|
|
4727
4907
|
async rm(filepath) {
|
|
4728
4908
|
try {
|
|
@@ -4734,6 +4914,10 @@ class FileSystem {
|
|
|
4734
4914
|
|
|
4735
4915
|
/**
|
|
4736
4916
|
* Delete a directory without throwing an error if it is already deleted.
|
|
4917
|
+
*
|
|
4918
|
+
* @param {string} filepath - The path to the directory.
|
|
4919
|
+
* @param {Object} [opts] - Options for deleting the directory.
|
|
4920
|
+
* @returns {Promise<void>}
|
|
4737
4921
|
*/
|
|
4738
4922
|
async rmdir(filepath, opts) {
|
|
4739
4923
|
try {
|
|
@@ -4749,6 +4933,9 @@ class FileSystem {
|
|
|
4749
4933
|
|
|
4750
4934
|
/**
|
|
4751
4935
|
* Read a directory without throwing an error is the directory doesn't exist
|
|
4936
|
+
*
|
|
4937
|
+
* @param {string} filepath - The path to the directory.
|
|
4938
|
+
* @returns {Promise<string[]|null>} - An array of file names, or `null` if the path is not a directory.
|
|
4752
4939
|
*/
|
|
4753
4940
|
async readdir(filepath) {
|
|
4754
4941
|
try {
|
|
@@ -4764,10 +4951,13 @@ class FileSystem {
|
|
|
4764
4951
|
}
|
|
4765
4952
|
|
|
4766
4953
|
/**
|
|
4767
|
-
* Return a
|
|
4954
|
+
* Return a flat list of all the files nested inside a directory
|
|
4768
4955
|
*
|
|
4769
4956
|
* Based on an elegant concurrent recursive solution from SO
|
|
4770
4957
|
* https://stackoverflow.com/a/45130990/2168416
|
|
4958
|
+
*
|
|
4959
|
+
* @param {string} dir - The directory to read.
|
|
4960
|
+
* @returns {Promise<string[]>} - A flat list of all files in the directory.
|
|
4771
4961
|
*/
|
|
4772
4962
|
async readdirDeep(dir) {
|
|
4773
4963
|
const subdirs = await this._readdir(dir);
|
|
@@ -4785,6 +4975,9 @@ class FileSystem {
|
|
|
4785
4975
|
/**
|
|
4786
4976
|
* Return the Stats of a file/symlink if it exists, otherwise returns null.
|
|
4787
4977
|
* Rethrows errors that aren't related to file existence.
|
|
4978
|
+
*
|
|
4979
|
+
* @param {string} filename - The path to the file or symlink.
|
|
4980
|
+
* @returns {Promise<Object|null>} - The stats object, or `null` if the file doesn't exist.
|
|
4788
4981
|
*/
|
|
4789
4982
|
async lstat(filename) {
|
|
4790
4983
|
try {
|
|
@@ -4801,6 +4994,10 @@ class FileSystem {
|
|
|
4801
4994
|
/**
|
|
4802
4995
|
* Reads the contents of a symlink if it exists, otherwise returns null.
|
|
4803
4996
|
* Rethrows errors that aren't related to file existence.
|
|
4997
|
+
*
|
|
4998
|
+
* @param {string} filename - The path to the symlink.
|
|
4999
|
+
* @param {Object} [opts={ encoding: 'buffer' }] - Options for reading the symlink.
|
|
5000
|
+
* @returns {Promise<Buffer|null>} - The symlink target, or `null` if it doesn't exist.
|
|
4804
5001
|
*/
|
|
4805
5002
|
async readlink(filename, opts = { encoding: 'buffer' }) {
|
|
4806
5003
|
// Note: FileSystem.readlink returns a buffer by default
|
|
@@ -4818,6 +5015,10 @@ class FileSystem {
|
|
|
4818
5015
|
|
|
4819
5016
|
/**
|
|
4820
5017
|
* Write the contents of buffer to a symlink.
|
|
5018
|
+
*
|
|
5019
|
+
* @param {string} filename - The path to the symlink.
|
|
5020
|
+
* @param {Buffer} buffer - The symlink target.
|
|
5021
|
+
* @returns {Promise<void>}
|
|
4821
5022
|
*/
|
|
4822
5023
|
async writelink(filename, buffer) {
|
|
4823
5024
|
return this._symlink(buffer.toString('utf8'), filename)
|
|
@@ -4962,6 +5163,16 @@ async function abortMerge({
|
|
|
4962
5163
|
// I'm putting this in a Manager because I reckon it could benefit
|
|
4963
5164
|
// from a LOT of caching.
|
|
4964
5165
|
class GitIgnoreManager {
|
|
5166
|
+
/**
|
|
5167
|
+
* Determines whether a given file is ignored based on `.gitignore` rules and exclusion files.
|
|
5168
|
+
*
|
|
5169
|
+
* @param {Object} args
|
|
5170
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
5171
|
+
* @param {string} args.dir - The working directory.
|
|
5172
|
+
* @param {string} [args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
5173
|
+
* @param {string} args.filepath - The path of the file to check.
|
|
5174
|
+
* @returns {Promise<boolean>} - `true` if the file is ignored, `false` otherwise.
|
|
5175
|
+
*/
|
|
4965
5176
|
static async isIgnored({ fs, dir, gitdir = pathBrowserify.join(dir, '.git'), filepath }) {
|
|
4966
5177
|
// ALWAYS ignore ".git" folders.
|
|
4967
5178
|
if (basename(filepath) === '.git') return true
|
|
@@ -7469,22 +7680,33 @@ const stringifyBody = async res => {
|
|
|
7469
7680
|
};
|
|
7470
7681
|
|
|
7471
7682
|
class GitRemoteHTTP {
|
|
7683
|
+
/**
|
|
7684
|
+
* Returns the capabilities of the GitRemoteHTTP class.
|
|
7685
|
+
*
|
|
7686
|
+
* @returns {Promise<string[]>} - An array of supported capabilities.
|
|
7687
|
+
*/
|
|
7472
7688
|
static async capabilities() {
|
|
7473
7689
|
return ['discover', 'connect']
|
|
7474
7690
|
}
|
|
7475
7691
|
|
|
7476
7692
|
/**
|
|
7693
|
+
* Discovers references from a remote Git repository.
|
|
7694
|
+
*
|
|
7477
7695
|
* @param {Object} args
|
|
7478
|
-
* @param {HttpClient} args.http
|
|
7479
|
-
* @param {ProgressCallback} [args.onProgress]
|
|
7480
|
-
* @param {AuthCallback} [args.onAuth]
|
|
7481
|
-
* @param {AuthFailureCallback} [args.onAuthFailure]
|
|
7482
|
-
* @param {AuthSuccessCallback} [args.onAuthSuccess]
|
|
7483
|
-
* @param {string} [args.corsProxy]
|
|
7484
|
-
* @param {string} args.service
|
|
7485
|
-
* @param {string} args.url
|
|
7486
|
-
* @param {Object<string, string>} args.headers
|
|
7487
|
-
* @param {1 | 2} args.protocolVersion - Git
|
|
7696
|
+
* @param {HttpClient} args.http - The HTTP client to use for requests.
|
|
7697
|
+
* @param {ProgressCallback} [args.onProgress] - Callback for progress updates.
|
|
7698
|
+
* @param {AuthCallback} [args.onAuth] - Callback for providing authentication credentials.
|
|
7699
|
+
* @param {AuthFailureCallback} [args.onAuthFailure] - Callback for handling authentication failures.
|
|
7700
|
+
* @param {AuthSuccessCallback} [args.onAuthSuccess] - Callback for handling successful authentication.
|
|
7701
|
+
* @param {string} [args.corsProxy] - Optional CORS proxy URL.
|
|
7702
|
+
* @param {string} args.service - The Git service (e.g., "git-upload-pack").
|
|
7703
|
+
* @param {string} args.url - The URL of the remote repository.
|
|
7704
|
+
* @param {Object<string, string>} args.headers - HTTP headers to include in the request.
|
|
7705
|
+
* @param {1 | 2} args.protocolVersion - The Git protocol version to use.
|
|
7706
|
+
* @returns {Promise<Object>} - The parsed response from the remote repository.
|
|
7707
|
+
* @throws {HttpError} - If the HTTP request fails.
|
|
7708
|
+
* @throws {SmartHttpError} - If the response cannot be parsed.
|
|
7709
|
+
* @throws {UserCanceledError} - If the user cancels the operation.
|
|
7488
7710
|
*/
|
|
7489
7711
|
static async discover({
|
|
7490
7712
|
http,
|
|
@@ -7580,15 +7802,19 @@ class GitRemoteHTTP {
|
|
|
7580
7802
|
}
|
|
7581
7803
|
|
|
7582
7804
|
/**
|
|
7805
|
+
* Connects to a remote Git repository and sends a request.
|
|
7806
|
+
*
|
|
7583
7807
|
* @param {Object} args
|
|
7584
|
-
* @param {HttpClient} args.http
|
|
7585
|
-
* @param {ProgressCallback} [args.onProgress]
|
|
7586
|
-
* @param {string} [args.corsProxy]
|
|
7587
|
-
* @param {string} args.service
|
|
7588
|
-
* @param {string} args.url
|
|
7589
|
-
* @param {Object<string, string>} [args.headers]
|
|
7590
|
-
* @param {any} args.body
|
|
7591
|
-
* @param {any} args.auth
|
|
7808
|
+
* @param {HttpClient} args.http - The HTTP client to use for requests.
|
|
7809
|
+
* @param {ProgressCallback} [args.onProgress] - Callback for progress updates.
|
|
7810
|
+
* @param {string} [args.corsProxy] - Optional CORS proxy URL.
|
|
7811
|
+
* @param {string} args.service - The Git service (e.g., "git-upload-pack").
|
|
7812
|
+
* @param {string} args.url - The URL of the remote repository.
|
|
7813
|
+
* @param {Object<string, string>} [args.headers] - HTTP headers to include in the request.
|
|
7814
|
+
* @param {any} args.body - The request body to send.
|
|
7815
|
+
* @param {any} args.auth - Authentication credentials.
|
|
7816
|
+
* @returns {Promise<GitHttpResponse>} - The HTTP response from the remote repository.
|
|
7817
|
+
* @throws {HttpError} - If the HTTP request fails.
|
|
7592
7818
|
*/
|
|
7593
7819
|
static async connect({
|
|
7594
7820
|
http,
|
|
@@ -7626,6 +7852,47 @@ class GitRemoteHTTP {
|
|
|
7626
7852
|
}
|
|
7627
7853
|
}
|
|
7628
7854
|
|
|
7855
|
+
/**
|
|
7856
|
+
* A class for managing Git remotes and determining the appropriate remote helper for a given URL.
|
|
7857
|
+
*/
|
|
7858
|
+
class GitRemoteManager {
|
|
7859
|
+
/**
|
|
7860
|
+
* Determines the appropriate remote helper for the given URL.
|
|
7861
|
+
*
|
|
7862
|
+
* @param {Object} args
|
|
7863
|
+
* @param {string} args.url - The URL of the remote repository.
|
|
7864
|
+
* @returns {Object} - The remote helper class for the specified transport.
|
|
7865
|
+
* @throws {UrlParseError} - If the URL cannot be parsed.
|
|
7866
|
+
* @throws {UnknownTransportError} - If the transport is not supported.
|
|
7867
|
+
*/
|
|
7868
|
+
static getRemoteHelperFor({ url }) {
|
|
7869
|
+
// TODO: clean up the remoteHelper API and move into PluginCore
|
|
7870
|
+
const remoteHelpers = new Map();
|
|
7871
|
+
remoteHelpers.set('http', GitRemoteHTTP);
|
|
7872
|
+
remoteHelpers.set('https', GitRemoteHTTP);
|
|
7873
|
+
|
|
7874
|
+
const parts = parseRemoteUrl({ url });
|
|
7875
|
+
if (!parts) {
|
|
7876
|
+
throw new UrlParseError(url)
|
|
7877
|
+
}
|
|
7878
|
+
if (remoteHelpers.has(parts.transport)) {
|
|
7879
|
+
return remoteHelpers.get(parts.transport)
|
|
7880
|
+
}
|
|
7881
|
+
throw new UnknownTransportError(
|
|
7882
|
+
url,
|
|
7883
|
+
parts.transport,
|
|
7884
|
+
parts.transport === 'ssh' ? translateSSHtoHTTP(url) : undefined
|
|
7885
|
+
)
|
|
7886
|
+
}
|
|
7887
|
+
}
|
|
7888
|
+
|
|
7889
|
+
/**
|
|
7890
|
+
* Parses a remote URL and extracts its transport and address.
|
|
7891
|
+
*
|
|
7892
|
+
* @param {Object} args
|
|
7893
|
+
* @param {string} args.url - The URL of the remote repository.
|
|
7894
|
+
* @returns {Object|undefined} - An object containing the transport and address, or undefined if parsing fails.
|
|
7895
|
+
*/
|
|
7629
7896
|
function parseRemoteUrl({ url }) {
|
|
7630
7897
|
// the stupid "shorter scp-like syntax"
|
|
7631
7898
|
if (url.startsWith('git@')) {
|
|
@@ -7663,31 +7930,17 @@ function parseRemoteUrl({ url }) {
|
|
|
7663
7930
|
}
|
|
7664
7931
|
}
|
|
7665
7932
|
|
|
7666
|
-
class GitRemoteManager {
|
|
7667
|
-
static getRemoteHelperFor({ url }) {
|
|
7668
|
-
// TODO: clean up the remoteHelper API and move into PluginCore
|
|
7669
|
-
const remoteHelpers = new Map();
|
|
7670
|
-
remoteHelpers.set('http', GitRemoteHTTP);
|
|
7671
|
-
remoteHelpers.set('https', GitRemoteHTTP);
|
|
7672
|
-
|
|
7673
|
-
const parts = parseRemoteUrl({ url });
|
|
7674
|
-
if (!parts) {
|
|
7675
|
-
throw new UrlParseError(url)
|
|
7676
|
-
}
|
|
7677
|
-
if (remoteHelpers.has(parts.transport)) {
|
|
7678
|
-
return remoteHelpers.get(parts.transport)
|
|
7679
|
-
}
|
|
7680
|
-
throw new UnknownTransportError(
|
|
7681
|
-
url,
|
|
7682
|
-
parts.transport,
|
|
7683
|
-
parts.transport === 'ssh' ? translateSSHtoHTTP(url) : undefined
|
|
7684
|
-
)
|
|
7685
|
-
}
|
|
7686
|
-
}
|
|
7687
|
-
|
|
7688
7933
|
let lock$2 = null;
|
|
7689
7934
|
|
|
7690
7935
|
class GitShallowManager {
|
|
7936
|
+
/**
|
|
7937
|
+
* Reads the `shallow` file in the Git repository and returns a set of object IDs (OIDs).
|
|
7938
|
+
*
|
|
7939
|
+
* @param {Object} args
|
|
7940
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
7941
|
+
* @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
7942
|
+
* @returns {Promise<Set<string>>} - A set of shallow object IDs.
|
|
7943
|
+
*/
|
|
7691
7944
|
static async read({ fs, gitdir }) {
|
|
7692
7945
|
if (lock$2 === null) lock$2 = new AsyncLock();
|
|
7693
7946
|
const filepath = pathBrowserify.join(gitdir, 'shallow');
|
|
@@ -7704,6 +7957,16 @@ class GitShallowManager {
|
|
|
7704
7957
|
return oids
|
|
7705
7958
|
}
|
|
7706
7959
|
|
|
7960
|
+
/**
|
|
7961
|
+
* Writes a set of object IDs (OIDs) to the `shallow` file in the Git repository.
|
|
7962
|
+
* If the set is empty, the `shallow` file is removed.
|
|
7963
|
+
*
|
|
7964
|
+
* @param {Object} args
|
|
7965
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
7966
|
+
* @param {string} [args.gitdir] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
7967
|
+
* @param {Set<string>} args.oids - A set of shallow object IDs to write.
|
|
7968
|
+
* @returns {Promise<void>}
|
|
7969
|
+
*/
|
|
7707
7970
|
static async write({ fs, gitdir, oids }) {
|
|
7708
7971
|
if (lock$2 === null) lock$2 = new AsyncLock();
|
|
7709
7972
|
const filepath = pathBrowserify.join(gitdir, 'shallow');
|
|
@@ -7803,8 +8066,8 @@ function filterCapabilities(server, client) {
|
|
|
7803
8066
|
|
|
7804
8067
|
const pkg = {
|
|
7805
8068
|
name: 'isomorphic-git',
|
|
7806
|
-
version: '1.
|
|
7807
|
-
agent: 'git/isomorphic-git@1.
|
|
8069
|
+
version: '1.33.0',
|
|
8070
|
+
agent: 'git/isomorphic-git@1.33.0',
|
|
7808
8071
|
};
|
|
7809
8072
|
|
|
7810
8073
|
class FIFO {
|
|
@@ -14553,6 +14816,14 @@ async function applyTreeChanges({
|
|
|
14553
14816
|
}
|
|
14554
14817
|
|
|
14555
14818
|
class GitStashManager {
|
|
14819
|
+
/**
|
|
14820
|
+
* Creates an instance of GitStashManager.
|
|
14821
|
+
*
|
|
14822
|
+
* @param {Object} args
|
|
14823
|
+
* @param {FSClient} args.fs - A file system implementation.
|
|
14824
|
+
* @param {string} args.dir - The working directory.
|
|
14825
|
+
* @param {string}[args.gitdir=join(dir, '.git')] - [required] The [git directory](dir-vs-gitdir.md) path
|
|
14826
|
+
*/
|
|
14556
14827
|
constructor({ fs, dir, gitdir = pathBrowserify.join(dir, '.git') }) {
|
|
14557
14828
|
Object.assign(this, {
|
|
14558
14829
|
fs,
|
|
@@ -14562,22 +14833,48 @@ class GitStashManager {
|
|
|
14562
14833
|
});
|
|
14563
14834
|
}
|
|
14564
14835
|
|
|
14836
|
+
/**
|
|
14837
|
+
* Gets the reference name for the stash.
|
|
14838
|
+
*
|
|
14839
|
+
* @returns {string} - The stash reference name.
|
|
14840
|
+
*/
|
|
14565
14841
|
static get refStash() {
|
|
14566
14842
|
return 'refs/stash'
|
|
14567
14843
|
}
|
|
14568
14844
|
|
|
14845
|
+
/**
|
|
14846
|
+
* Gets the reference name for the stash reflogs.
|
|
14847
|
+
*
|
|
14848
|
+
* @returns {string} - The stash reflogs reference name.
|
|
14849
|
+
*/
|
|
14569
14850
|
static get refLogsStash() {
|
|
14570
14851
|
return 'logs/refs/stash'
|
|
14571
14852
|
}
|
|
14572
14853
|
|
|
14854
|
+
/**
|
|
14855
|
+
* Gets the file path for the stash reference.
|
|
14856
|
+
*
|
|
14857
|
+
* @returns {string} - The file path for the stash reference.
|
|
14858
|
+
*/
|
|
14573
14859
|
get refStashPath() {
|
|
14574
14860
|
return pathBrowserify.join(this.gitdir, GitStashManager.refStash)
|
|
14575
14861
|
}
|
|
14576
14862
|
|
|
14863
|
+
/**
|
|
14864
|
+
* Gets the file path for the stash reflogs.
|
|
14865
|
+
*
|
|
14866
|
+
* @returns {string} - The file path for the stash reflogs.
|
|
14867
|
+
*/
|
|
14577
14868
|
get refLogsStashPath() {
|
|
14578
14869
|
return pathBrowserify.join(this.gitdir, GitStashManager.refLogsStash)
|
|
14579
14870
|
}
|
|
14580
14871
|
|
|
14872
|
+
/**
|
|
14873
|
+
* Retrieves the author information for the stash.
|
|
14874
|
+
*
|
|
14875
|
+
* @returns {Promise<Object>} - The author object.
|
|
14876
|
+
* @throws {MissingNameError} - If the author name is missing.
|
|
14877
|
+
*/
|
|
14581
14878
|
async getAuthor() {
|
|
14582
14879
|
if (!this._author) {
|
|
14583
14880
|
this._author = await normalizeAuthorObject({
|
|
@@ -14590,6 +14887,13 @@ class GitStashManager {
|
|
|
14590
14887
|
return this._author
|
|
14591
14888
|
}
|
|
14592
14889
|
|
|
14890
|
+
/**
|
|
14891
|
+
* Gets the SHA of a stash entry by its index.
|
|
14892
|
+
*
|
|
14893
|
+
* @param {number} refIdx - The index of the stash entry.
|
|
14894
|
+
* @param {string[]} [stashEntries] - Optional preloaded stash entries.
|
|
14895
|
+
* @returns {Promise<string|null>} - The SHA of the stash entry or `null` if not found.
|
|
14896
|
+
*/
|
|
14593
14897
|
async getStashSHA(refIdx, stashEntries) {
|
|
14594
14898
|
if (!(await this.fs.exists(this.refStashPath))) {
|
|
14595
14899
|
return null
|
|
@@ -14600,6 +14904,15 @@ class GitStashManager {
|
|
|
14600
14904
|
return entries[refIdx].split(' ')[1]
|
|
14601
14905
|
}
|
|
14602
14906
|
|
|
14907
|
+
/**
|
|
14908
|
+
* Writes a stash commit to the repository.
|
|
14909
|
+
*
|
|
14910
|
+
* @param {Object} args
|
|
14911
|
+
* @param {string} args.message - The commit message.
|
|
14912
|
+
* @param {string} args.tree - The tree object ID.
|
|
14913
|
+
* @param {string[]} args.parent - The parent commit object IDs.
|
|
14914
|
+
* @returns {Promise<string>} - The object ID of the written commit.
|
|
14915
|
+
*/
|
|
14603
14916
|
async writeStashCommit({ message, tree, parent }) {
|
|
14604
14917
|
return _writeCommit({
|
|
14605
14918
|
fs: this.fs,
|
|
@@ -14614,6 +14927,13 @@ class GitStashManager {
|
|
|
14614
14927
|
})
|
|
14615
14928
|
}
|
|
14616
14929
|
|
|
14930
|
+
/**
|
|
14931
|
+
* Reads a stash commit by its index.
|
|
14932
|
+
*
|
|
14933
|
+
* @param {number} refIdx - The index of the stash entry.
|
|
14934
|
+
* @returns {Promise<Object>} - The stash commit object.
|
|
14935
|
+
* @throws {InvalidRefNameError} - If the index is invalid.
|
|
14936
|
+
*/
|
|
14617
14937
|
async readStashCommit(refIdx) {
|
|
14618
14938
|
const stashEntries = await this.readStashReflogs({ parsed: false });
|
|
14619
14939
|
if (refIdx !== 0) {
|
|
@@ -14640,6 +14960,12 @@ class GitStashManager {
|
|
|
14640
14960
|
})
|
|
14641
14961
|
}
|
|
14642
14962
|
|
|
14963
|
+
/**
|
|
14964
|
+
* Writes a stash reference to the repository.
|
|
14965
|
+
*
|
|
14966
|
+
* @param {string} stashCommit - The object ID of the stash commit.
|
|
14967
|
+
* @returns {Promise<void>}
|
|
14968
|
+
*/
|
|
14643
14969
|
async writeStashRef(stashCommit) {
|
|
14644
14970
|
return GitRefManager.writeRef({
|
|
14645
14971
|
fs: this.fs,
|
|
@@ -14649,6 +14975,14 @@ class GitStashManager {
|
|
|
14649
14975
|
})
|
|
14650
14976
|
}
|
|
14651
14977
|
|
|
14978
|
+
/**
|
|
14979
|
+
* Writes a reflog entry for a stash commit.
|
|
14980
|
+
*
|
|
14981
|
+
* @param {Object} args
|
|
14982
|
+
* @param {string} args.stashCommit - The object ID of the stash commit.
|
|
14983
|
+
* @param {string} args.message - The reflog message.
|
|
14984
|
+
* @returns {Promise<void>}
|
|
14985
|
+
*/
|
|
14652
14986
|
async writeStashReflogEntry({ stashCommit, message }) {
|
|
14653
14987
|
const author = await this.getAuthor();
|
|
14654
14988
|
const entry = GitRefStash.createStashReflogEntry(
|
|
@@ -14666,6 +15000,13 @@ class GitStashManager {
|
|
|
14666
15000
|
});
|
|
14667
15001
|
}
|
|
14668
15002
|
|
|
15003
|
+
/**
|
|
15004
|
+
* Reads the stash reflogs.
|
|
15005
|
+
*
|
|
15006
|
+
* @param {Object} args
|
|
15007
|
+
* @param {boolean} [args.parsed=false] - Whether to parse the reflog entries.
|
|
15008
|
+
* @returns {Promise<string[]|Object[]>} - The reflog entries as strings or parsed objects.
|
|
15009
|
+
*/
|
|
14669
15010
|
async readStashReflogs({ parsed = false }) {
|
|
14670
15011
|
if (!(await this.fs.exists(this.refLogsStashPath))) {
|
|
14671
15012
|
return []
|