@gitkraken/core-gitlens 0.38.4 → 0.39.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/CHANGELOG.md +8 -1
- package/dist/git-cli/exec/git.d.ts +21 -0
- package/dist/git-cli/exec/git.js +21 -0
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/providers/branches.js +13 -6
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/remotes.js +1 -1
- package/dist/git-cli/providers/remotes.js.map +1 -1
- package/dist/plus/integrations/providers/issueSorts.d.ts +1 -0
- package/dist/plus/integrations/reads/drains.d.ts +1 -0
- package/package.json +1 -1
|
@@ -106,7 +106,7 @@ var RemotesGitSubProvider = class extends RemotesGitProviderBase {
|
|
|
106
106
|
cwd: repoPath,
|
|
107
107
|
cancellation: signal,
|
|
108
108
|
errors: "ignore",
|
|
109
|
-
env: probeRemoteEnv,
|
|
109
|
+
env: this.git.quietNetworkEnv(probeRemoteEnv),
|
|
110
110
|
priority: "interactive"
|
|
111
111
|
}, "ls-remote", url, "HEAD");
|
|
112
112
|
const { completion } = result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remotes.js","names":[],"sources":["../../../../git-cli/src/providers/remotes.ts"],"sourcesContent":["import type { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport type { GitRemote } from '@gitlens/git/models/remote.js';\nimport type {\n\tGitRemoteProbeFailureReason,\n\tGitRemoteProbeResult,\n\tGitRemotesSubProvider,\n} from '@gitlens/git/providers/remotes.js';\nimport { RemotesGitProviderBase } from '@gitlens/git/providers/shared/remotes.js';\nimport { createRemoteProviderMatcher } from '@gitlens/git/remotes/matcher.js';\nimport { sortRemotes } from '@gitlens/git/utils/sorting.js';\nimport { CancellationError } from '@gitlens/utils/cancellation.js';\nimport { gate } from '@gitlens/utils/decorators/gate.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport type { Git } from '../exec/git.js';\nimport { parseGitRemotes } from '../parsers/remoteParser.js';\n\n/** Long enough for a slow host to answer, short enough that a blackholed one doesn't stall the wizard */\nconst probeRemoteTimeoutMs = 5000;\n\n/**\n * Keeps the probe from asking anyone for credentials: an empty `GIT_ASKPASS` stops git's askpass lookup\n * outright (it doesn't fall through to `core.askPass` or `SSH_ASKPASS`), so the editor's askpass can't\n * open a credential prompt over the wizard, and `GIT_TERMINAL_PROMPT=0` refuses the tty fallback.\n * Non-interactive credential helpers still run, so a stored credential still authenticates.\n */\nconst probeRemoteEnv: Record<string, string> = {\n\tGIT_ASKPASS: '',\n\tGIT_TERMINAL_PROMPT: '0',\n\tGCM_INTERACTIVE: 'NEVER',\n\tSSH_ASKPASS: '',\n};\n\nexport function getProbeFailureReason(stderr: string): GitRemoteProbeFailureReason {\n\tif (/Could not resolve host|nodename nor servname|Name or service not known|No such host/i.test(stderr)) {\n\t\treturn 'hostNotFound';\n\t}\n\t// Checked before auth: the probe forbids ssh's prompt to trust an unknown host, so a correct URL on a host\n\t// not yet in known_hosts fails here, and that isn't an authentication problem\n\tif (/Host key verification failed/i.test(stderr)) {\n\t\treturn 'hostKeyUnverified';\n\t}\n\t// HTTP statuses are matched on git's own wording so digits elsewhere (e.g. a `/403/` URL path) don't count\n\tif (\n\t\t/could not read (?:Username|Password)|terminal prompts disabled|Authentication failed|Permission denied|returned error: 40[13]\\b/i.test(\n\t\t\tstderr,\n\t\t)\n\t) {\n\t\treturn 'authRequired';\n\t}\n\tif (\n\t\t/Repository not found|repository '.*' not found|does not appear to be a git repository|returned error: 404\\b/i.test(\n\t\t\tstderr,\n\t\t)\n\t) {\n\t\treturn 'notFound';\n\t}\n\treturn 'other';\n}\n\n/** SSH's generic tail, which follows (and buries) the host's own explanation of the failure */\nconst genericProbeFailureLine =\n\t/^(?:fatal:\\s*)?(?:Could not read from remote repository|Please make sure you have the correct access rights|and the repository exists)/;\n\n/**\n * The line of stderr that names what went wrong most plainly: SSH's generic trailer is dropped first so the host's\n * message before it (e.g. `ERROR: Repository not found.`) can win; then the last `fatal:` line (prefix stripped),\n * else the last line. If only the generic trailer remains, it is used rather than returning nothing.\n */\nexport function getProbeFailureMessage(stderr: string): string | undefined {\n\tconst lines = stderr\n\t\t.split(/\\r?\\n/)\n\t\t.map(l => l.trim())\n\t\t.filter(l => l.length);\n\tconst specific = lines.filter(l => !genericProbeFailureLine.test(l));\n\tconst candidates = specific.length ? specific : lines;\n\tconst fatal = candidates.findLast(l => l.startsWith('fatal:'));\n\treturn (fatal ?? candidates.at(-1))?.replace(/^fatal:\\s*/, '') || undefined;\n}\n\nexport class RemotesGitSubProvider extends RemotesGitProviderBase implements GitRemotesSubProvider {\n\tconstructor(\n\t\tcontext: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tcache: Cache,\n\t\tprovider: CliGitProviderInternal,\n\t) {\n\t\tsuper(context, cache, provider);\n\t}\n\n\t@debug({ quiet: true, args: repoPath => ({ repoPath: repoPath }) })\n\tasync getRemotes(\n\t\trepoPath: string | undefined,\n\t\toptions?: { filter?: (remote: GitRemote) => boolean; sort?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitRemote[]> {\n\t\tif (repoPath == null) return [];\n\n\t\tconst scope = getScopedLogger();\n\n\t\tlet remotes = await this.cache.getRemotes(\n\t\t\trepoPath,\n\t\t\tasync (commonPath, cacheable, signal) => {\n\t\t\t\t// Prefer the aggregate signal from the cache; fall back to the caller's cancellation.\n\t\t\t\tsignal ??= cancellation;\n\t\t\t\tconst configs = await this.context.remotes?.getCustomProviders?.(repoPath);\n\t\t\t\tconst remoteProviderMatcher = createRemoteProviderMatcher(configs, this.context.remotes);\n\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcwd: repoPath,\n\t\t\t\t\t\t\tcancellation: signal,\n\t\t\t\t\t\t\tcaching: { cache: this.cache.gitResults, commonPath: commonPath },\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'remote',\n\t\t\t\t\t\t'-v',\n\t\t\t\t\t);\n\n\t\t\t\t\t// Fetch default remote name from GK config before parsing so it's set at construction time\n\t\t\t\t\tconst defaultName = await this.provider.config.getGkConfig?.(repoPath, 'gk.defaultRemote');\n\t\t\t\t\tconst remotes = parseGitRemotes(result.stdout, commonPath, remoteProviderMatcher, defaultName);\n\n\t\t\t\t\treturn remotes;\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t\tscope?.error(ex);\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\n\t\tif (options?.filter != null) {\n\t\t\tremotes = remotes.filter(options.filter);\n\t\t}\n\n\t\tif (options?.sort) {\n\t\t\tsortRemotes(remotes);\n\t\t}\n\n\t\treturn remotes;\n\t}\n\n\t@gate()\n\t@debug()\n\tasync addRemote(repoPath: string, name: string, url: string, options?: { fetch?: boolean }): Promise<void> {\n\t\tif (!options?.fetch) {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'remote', 'add', name, url);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'remotes');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['config', 'remotes']);\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'remote', 'add', '-f', name, url);\n\t\t} finally {\n\t\t\t// Reset even on failure: `remote add -f` keeps the remote when only its fetch fails, and a\n\t\t\t// caller checking whether the remote now exists must not read the pre-add cache.\n\t\t\t// A fetch creates the remote's tracking branches, which the branch, ref and history caches hold\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'remotes', 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['config', 'remotes']);\n\t\t}\n\t}\n\n\t@gate()\n\t@debug()\n\tasync addRemoteWithResult(\n\t\trepoPath: string,\n\t\tname: string,\n\t\turl: string,\n\t\toptions?: { fetch?: boolean },\n\t): Promise<GitRemote | undefined> {\n\t\tawait this.addRemote(repoPath, name, url, options);\n\t\tconst [remote] = await this.getRemotes(repoPath, { filter: r => r.url === url });\n\t\treturn remote;\n\t}\n\n\t// The URL is left out of the log — it can carry credentials (`https://<token>@host/...`)\n\t@debug({ args: repoPath => ({ repoPath: repoPath }) })\n\tasync probeRemote(repoPath: string, url: string, cancellation?: AbortSignal): Promise<GitRemoteProbeResult> {\n\t\t// A leading `-` would be parsed as an option rather than the repository to query\n\t\tif (url.startsWith('-')) return { reachable: false, reason: 'other' };\n\n\t\tconst timeoutSignal = AbortSignal.timeout(probeRemoteTimeoutMs);\n\t\tconst signal = cancellation != null ? AbortSignal.any([cancellation, timeoutSignal]) : timeoutSignal;\n\n\t\tconst result = await this.git.run(\n\t\t\t{ cwd: repoPath, cancellation: signal, errors: 'ignore', env: probeRemoteEnv, priority: 'interactive' },\n\t\t\t// No `--exit-code`: a freshly created, empty repository advertises no HEAD but is a valid remote\n\t\t\t'ls-remote',\n\t\t\turl,\n\t\t\t'HEAD',\n\t\t);\n\n\t\tconst { completion } = result;\n\t\tif (completion.status === 'exited' && completion.code === 0) return { reachable: true };\n\n\t\tif (completion.status === 'cancelled') {\n\t\t\tif (cancellation?.aborted) throw new CancellationError(completion.error, 'aborted');\n\n\t\t\treturn { reachable: false, reason: 'timeout' };\n\t\t}\n\n\t\t// A run that never exited (spawn failure, missing binary, queue rejection) says nothing about the remote;\n\t\t// throw so callers treat it as unprobed rather than unreachable\n\t\tif (completion.status === 'failed') {\n\t\t\tif (cancellation?.aborted) throw new CancellationError(completion.error, 'aborted');\n\n\t\t\tthrow completion.error;\n\t\t}\n\n\t\t// Under `errors: 'ignore'` a non-zero exit resolves with its stderr; a run that never exited has none\n\t\tconst stderr = typeof result.stderr === 'string' ? result.stderr : '';\n\t\treturn {\n\t\t\treachable: false,\n\t\t\treason: getProbeFailureReason(stderr),\n\t\t\tmessage: getProbeFailureMessage(stderr),\n\t\t};\n\t}\n\n\t@gate()\n\t@debug()\n\tasync pruneRemote(repoPath: string, name: string): Promise<void> {\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'remote', 'prune', name);\n\t\t} finally {\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'remotes', 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['remotes']);\n\t\t}\n\t}\n\n\t@gate()\n\t@debug()\n\tasync removeRemote(repoPath: string, name: string): Promise<void> {\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'remote', 'remove', name);\n\t\t} finally {\n\t\t\t// Removing a remote deletes its tracking branches too\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'remotes', 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['config', 'remotes']);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAoBA,MAAM,uBAAuB;;;;;;;AAQ7B,MAAM,iBAAyC;CAC9C,aAAa;CACb,qBAAqB;CACrB,iBAAiB;CACjB,aAAa;AACd;AAEA,SAAgB,sBAAsB,QAA6C;CAClF,IAAI,uFAAuF,KAAK,MAAM,GACrG,OAAO;CAIR,IAAI,gCAAgC,KAAK,MAAM,GAC9C,OAAO;CAGR,IACC,mIAAmI,KAClI,MACD,GAEA,OAAO;CAER,IACC,+GAA+G,KAC9G,MACD,GAEA,OAAO;CAER,OAAO;AACR;;AAGA,MAAM,0BACL;;;;;;AAOD,SAAgB,uBAAuB,QAAoC;CAC1E,MAAM,QAAQ,OACZ,MAAM,OAAO,CAAC,CACd,KAAI,MAAK,EAAE,KAAK,CAAC,CAAC,CAClB,QAAO,MAAK,EAAE,MAAM;CACtB,MAAM,WAAW,MAAM,QAAO,MAAK,CAAC,wBAAwB,KAAK,CAAC,CAAC;CACnE,MAAM,aAAa,SAA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"remotes.js","names":[],"sources":["../../../../git-cli/src/providers/remotes.ts"],"sourcesContent":["import type { Cache } from '@gitlens/git/cache.js';\nimport type { GitServiceContext } from '@gitlens/git/context.js';\nimport type { GitRemote } from '@gitlens/git/models/remote.js';\nimport type {\n\tGitRemoteProbeFailureReason,\n\tGitRemoteProbeResult,\n\tGitRemotesSubProvider,\n} from '@gitlens/git/providers/remotes.js';\nimport { RemotesGitProviderBase } from '@gitlens/git/providers/shared/remotes.js';\nimport { createRemoteProviderMatcher } from '@gitlens/git/remotes/matcher.js';\nimport { sortRemotes } from '@gitlens/git/utils/sorting.js';\nimport { CancellationError } from '@gitlens/utils/cancellation.js';\nimport { gate } from '@gitlens/utils/decorators/gate.js';\nimport { debug } from '@gitlens/utils/decorators/log.js';\nimport { getScopedLogger } from '@gitlens/utils/logger.scoped.js';\nimport type { CliGitProviderInternal } from '../cliGitProvider.js';\nimport type { Git } from '../exec/git.js';\nimport { parseGitRemotes } from '../parsers/remoteParser.js';\n\n/** Long enough for a slow host to answer, short enough that a blackholed one doesn't stall the wizard */\nconst probeRemoteTimeoutMs = 5000;\n\n/**\n * Keeps the probe from asking anyone for credentials: an empty `GIT_ASKPASS` stops git's askpass lookup\n * outright (it doesn't fall through to `core.askPass` or `SSH_ASKPASS`), so the editor's askpass can't\n * open a credential prompt over the wizard, and `GIT_TERMINAL_PROMPT=0` refuses the tty fallback.\n * Non-interactive credential helpers still run, so a stored credential still authenticates.\n */\nconst probeRemoteEnv: Record<string, string> = {\n\tGIT_ASKPASS: '',\n\tGIT_TERMINAL_PROMPT: '0',\n\tGCM_INTERACTIVE: 'NEVER',\n\tSSH_ASKPASS: '',\n};\n\nexport function getProbeFailureReason(stderr: string): GitRemoteProbeFailureReason {\n\tif (/Could not resolve host|nodename nor servname|Name or service not known|No such host/i.test(stderr)) {\n\t\treturn 'hostNotFound';\n\t}\n\t// Checked before auth: the probe forbids ssh's prompt to trust an unknown host, so a correct URL on a host\n\t// not yet in known_hosts fails here, and that isn't an authentication problem\n\tif (/Host key verification failed/i.test(stderr)) {\n\t\treturn 'hostKeyUnverified';\n\t}\n\t// HTTP statuses are matched on git's own wording so digits elsewhere (e.g. a `/403/` URL path) don't count\n\tif (\n\t\t/could not read (?:Username|Password)|terminal prompts disabled|Authentication failed|Permission denied|returned error: 40[13]\\b/i.test(\n\t\t\tstderr,\n\t\t)\n\t) {\n\t\treturn 'authRequired';\n\t}\n\tif (\n\t\t/Repository not found|repository '.*' not found|does not appear to be a git repository|returned error: 404\\b/i.test(\n\t\t\tstderr,\n\t\t)\n\t) {\n\t\treturn 'notFound';\n\t}\n\treturn 'other';\n}\n\n/** SSH's generic tail, which follows (and buries) the host's own explanation of the failure */\nconst genericProbeFailureLine =\n\t/^(?:fatal:\\s*)?(?:Could not read from remote repository|Please make sure you have the correct access rights|and the repository exists)/;\n\n/**\n * The line of stderr that names what went wrong most plainly: SSH's generic trailer is dropped first so the host's\n * message before it (e.g. `ERROR: Repository not found.`) can win; then the last `fatal:` line (prefix stripped),\n * else the last line. If only the generic trailer remains, it is used rather than returning nothing.\n */\nexport function getProbeFailureMessage(stderr: string): string | undefined {\n\tconst lines = stderr\n\t\t.split(/\\r?\\n/)\n\t\t.map(l => l.trim())\n\t\t.filter(l => l.length);\n\tconst specific = lines.filter(l => !genericProbeFailureLine.test(l));\n\tconst candidates = specific.length ? specific : lines;\n\tconst fatal = candidates.findLast(l => l.startsWith('fatal:'));\n\treturn (fatal ?? candidates.at(-1))?.replace(/^fatal:\\s*/, '') || undefined;\n}\n\nexport class RemotesGitSubProvider extends RemotesGitProviderBase implements GitRemotesSubProvider {\n\tconstructor(\n\t\tcontext: GitServiceContext,\n\t\tprivate readonly git: Git,\n\t\tcache: Cache,\n\t\tprovider: CliGitProviderInternal,\n\t) {\n\t\tsuper(context, cache, provider);\n\t}\n\n\t@debug({ quiet: true, args: repoPath => ({ repoPath: repoPath }) })\n\tasync getRemotes(\n\t\trepoPath: string | undefined,\n\t\toptions?: { filter?: (remote: GitRemote) => boolean; sort?: boolean },\n\t\tcancellation?: AbortSignal,\n\t): Promise<GitRemote[]> {\n\t\tif (repoPath == null) return [];\n\n\t\tconst scope = getScopedLogger();\n\n\t\tlet remotes = await this.cache.getRemotes(\n\t\t\trepoPath,\n\t\t\tasync (commonPath, cacheable, signal) => {\n\t\t\t\t// Prefer the aggregate signal from the cache; fall back to the caller's cancellation.\n\t\t\t\tsignal ??= cancellation;\n\t\t\t\tconst configs = await this.context.remotes?.getCustomProviders?.(repoPath);\n\t\t\t\tconst remoteProviderMatcher = createRemoteProviderMatcher(configs, this.context.remotes);\n\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await this.git.run(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcwd: repoPath,\n\t\t\t\t\t\t\tcancellation: signal,\n\t\t\t\t\t\t\tcaching: { cache: this.cache.gitResults, commonPath: commonPath },\n\t\t\t\t\t\t},\n\t\t\t\t\t\t'remote',\n\t\t\t\t\t\t'-v',\n\t\t\t\t\t);\n\n\t\t\t\t\t// Fetch default remote name from GK config before parsing so it's set at construction time\n\t\t\t\t\tconst defaultName = await this.provider.config.getGkConfig?.(repoPath, 'gk.defaultRemote');\n\t\t\t\t\tconst remotes = parseGitRemotes(result.stdout, commonPath, remoteProviderMatcher, defaultName);\n\n\t\t\t\t\treturn remotes;\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tcacheable.invalidate();\n\t\t\t\t\tscope?.error(ex);\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t},\n\t\t\tcancellation,\n\t\t);\n\n\t\tif (options?.filter != null) {\n\t\t\tremotes = remotes.filter(options.filter);\n\t\t}\n\n\t\tif (options?.sort) {\n\t\t\tsortRemotes(remotes);\n\t\t}\n\n\t\treturn remotes;\n\t}\n\n\t@gate()\n\t@debug()\n\tasync addRemote(repoPath: string, name: string, url: string, options?: { fetch?: boolean }): Promise<void> {\n\t\tif (!options?.fetch) {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'remote', 'add', name, url);\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'remotes');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['config', 'remotes']);\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'remote', 'add', '-f', name, url);\n\t\t} finally {\n\t\t\t// Reset even on failure: `remote add -f` keeps the remote when only its fetch fails, and a\n\t\t\t// caller checking whether the remote now exists must not read the pre-add cache.\n\t\t\t// A fetch creates the remote's tracking branches, which the branch, ref and history caches hold\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'remotes', 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['config', 'remotes']);\n\t\t}\n\t}\n\n\t@gate()\n\t@debug()\n\tasync addRemoteWithResult(\n\t\trepoPath: string,\n\t\tname: string,\n\t\turl: string,\n\t\toptions?: { fetch?: boolean },\n\t): Promise<GitRemote | undefined> {\n\t\tawait this.addRemote(repoPath, name, url, options);\n\t\tconst [remote] = await this.getRemotes(repoPath, { filter: r => r.url === url });\n\t\treturn remote;\n\t}\n\n\t// The URL is left out of the log — it can carry credentials (`https://<token>@host/...`)\n\t@debug({ args: repoPath => ({ repoPath: repoPath }) })\n\tasync probeRemote(repoPath: string, url: string, cancellation?: AbortSignal): Promise<GitRemoteProbeResult> {\n\t\t// A leading `-` would be parsed as an option rather than the repository to query\n\t\tif (url.startsWith('-')) return { reachable: false, reason: 'other' };\n\n\t\tconst timeoutSignal = AbortSignal.timeout(probeRemoteTimeoutMs);\n\t\tconst signal = cancellation != null ? AbortSignal.any([cancellation, timeoutSignal]) : timeoutSignal;\n\n\t\tconst result = await this.git.run(\n\t\t\t{\n\t\t\t\tcwd: repoPath,\n\t\t\t\tcancellation: signal,\n\t\t\t\terrors: 'ignore',\n\t\t\t\tenv: this.git.quietNetworkEnv(probeRemoteEnv),\n\t\t\t\tpriority: 'interactive',\n\t\t\t},\n\t\t\t// No `--exit-code`: a freshly created, empty repository advertises no HEAD but is a valid remote\n\t\t\t'ls-remote',\n\t\t\turl,\n\t\t\t'HEAD',\n\t\t);\n\n\t\tconst { completion } = result;\n\t\tif (completion.status === 'exited' && completion.code === 0) return { reachable: true };\n\n\t\tif (completion.status === 'cancelled') {\n\t\t\tif (cancellation?.aborted) throw new CancellationError(completion.error, 'aborted');\n\n\t\t\treturn { reachable: false, reason: 'timeout' };\n\t\t}\n\n\t\t// A run that never exited (spawn failure, missing binary, queue rejection) says nothing about the remote;\n\t\t// throw so callers treat it as unprobed rather than unreachable\n\t\tif (completion.status === 'failed') {\n\t\t\tif (cancellation?.aborted) throw new CancellationError(completion.error, 'aborted');\n\n\t\t\tthrow completion.error;\n\t\t}\n\n\t\t// Under `errors: 'ignore'` a non-zero exit resolves with its stderr; a run that never exited has none\n\t\tconst stderr = typeof result.stderr === 'string' ? result.stderr : '';\n\t\treturn {\n\t\t\treachable: false,\n\t\t\treason: getProbeFailureReason(stderr),\n\t\t\tmessage: getProbeFailureMessage(stderr),\n\t\t};\n\t}\n\n\t@gate()\n\t@debug()\n\tasync pruneRemote(repoPath: string, name: string): Promise<void> {\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'remote', 'prune', name);\n\t\t} finally {\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'remotes', 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['remotes']);\n\t\t}\n\t}\n\n\t@gate()\n\t@debug()\n\tasync removeRemote(repoPath: string, name: string): Promise<void> {\n\t\ttry {\n\t\t\tawait this.git.run({ cwd: repoPath }, 'remote', 'remove', name);\n\t\t} finally {\n\t\t\t// Removing a remote deletes its tracking branches too\n\t\t\tthis.context.hooks?.cache?.onReset?.(repoPath, 'remotes', 'branches');\n\t\t\tthis.context.hooks?.repository?.onChanged?.(repoPath, ['config', 'remotes']);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAoBA,MAAM,uBAAuB;;;;;;;AA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AU,SAAS,CAAC;EAC5E;CACD;AACD;AA/JE,WAAA,CAAA,MAAM;CAAE,OAAO;CAAM,OAAM,cAAa,EAAY,SAAS;AAAG,CAAC,CAAA,GAAA,sBAAA,WAAA,cAAA,IAAA;AAsDjE,WAAA,CAAA,KAAK,GACL,MAAM,CAAA,GAAA,sBAAA,WAAA,aAAA,IAAA;AAoBN,WAAA,CAAA,KAAK,GACL,MAAM,CAAA,GAAA,sBAAA,WAAA,uBAAA,IAAA;AAaN,WAAA,CAAA,MAAM,EAAE,OAAM,cAAa,EAAY,SAAS,GAAG,CAAC,CAAA,GAAA,sBAAA,WAAA,eAAA,IAAA;AAgDpD,WAAA,CAAA,KAAK,GACL,MAAM,CAAA,GAAA,sBAAA,WAAA,eAAA,IAAA;AAUN,WAAA,CAAA,KAAK,GACL,MAAM,CAAA,GAAA,sBAAA,WAAA,gBAAA,IAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IssueSorting } from "../../../git/models/issue.js";
|
|
2
|
+
import "../providerFilters.js";
|
|
2
3
|
//#region ../plus/integrations/src/providers/issueSorts.d.ts
|
|
3
4
|
/** GitHub and GHE: one `search` channel serves all three issue reads, so all three order the same way. */
|
|
4
5
|
export declare const githubIssueSorts: IssueSorting[];
|
|
@@ -2,6 +2,7 @@ import { ResourceDescriptor } from "../../../git/models/resourceDescriptor.js";
|
|
|
2
2
|
import { PullRequest, PullRequestFilter, PullRequestStateFilter } from "../../../git/models/pullRequest.js";
|
|
3
3
|
import { IntegrationIds } from "../constants.js";
|
|
4
4
|
import { ProviderWarning } from "../results.js";
|
|
5
|
+
import "../providerFilters.js";
|
|
5
6
|
import { ProviderPullRequest, ProviderReposInput, ProviderRepository } from "../providers/models.js";
|
|
6
7
|
import { GitHostIntegration } from "../models/gitHostIntegration.js";
|
|
7
8
|
import { IssuesIntegration } from "../models/issuesIntegration.js";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gitkraken/core-gitlens",
|
|
3
3
|
"description": "GitLens core — shared Git / AI / GitHub primitives for internal GitKraken consumption",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.39.0",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "GitKraken",
|