@gitkraken/core-gitlens 0.9.9 → 0.10.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 +18 -1
- package/dist/git/errors.d.ts +7 -0
- package/dist/git/errors.js +14 -1
- package/dist/git/errors.js.map +1 -1
- package/dist/git/providers/status.d.ts +6 -1
- package/dist/git/run.types.d.ts +9 -4
- package/dist/git-cli/exec/git.js +36 -16
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/providers/diff.d.ts +5 -2
- package/dist/git-cli/providers/diff.js +21 -9
- package/dist/git-cli/providers/diff.js.map +1 -1
- package/dist/git-cli/providers/patch.js +5 -7
- package/dist/git-cli/providers/patch.js.map +1 -1
- package/dist/git-cli/providers/status.d.ts +0 -1
- package/dist/git-cli/providers/status.js +119 -142
- package/dist/git-cli/providers/status.js.map +1 -1
- package/dist/plus/git-github/providers/github/status.d.ts +0 -1
- package/dist/plus/git-github/providers/github/status.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/dist/utils/cancellation.d.ts +4 -1
- package/dist/utils/cancellation.js +4 -2
- package/dist/utils/cancellation.js.map +1 -1
- package/dist/utils/env/node/exec.d.ts +5 -1
- package/dist/utils/env/node/exec.js +8 -5
- package/dist/utils/env/node/exec.js.map +1 -1
- package/package.json +1 -1
|
@@ -11,6 +11,7 @@ export interface GitWorkingChangesState {
|
|
|
11
11
|
untracked: boolean;
|
|
12
12
|
}
|
|
13
13
|
export interface GitStatusSubProvider {
|
|
14
|
+
/** Rejects when git fails; resolves `undefined` only for an undefined `repoPath` */
|
|
14
15
|
getStatus(repoPath: string | undefined, options?: {
|
|
15
16
|
priority?: GitCommandPriority;
|
|
16
17
|
force?: boolean;
|
|
@@ -25,16 +26,20 @@ export interface GitStatusSubProvider {
|
|
|
25
26
|
getStatusForPath?(repoPath: string, pathOrUri: string | Uri, options?: {
|
|
26
27
|
renames?: boolean;
|
|
27
28
|
}, cancellation?: AbortSignal): Promise<GitStatusFile[] | undefined>;
|
|
29
|
+
/** Rejects when git fails, rather than answering `false` */
|
|
28
30
|
hasWorkingChanges(repoPath: string, options?: {
|
|
29
31
|
staged?: boolean;
|
|
30
32
|
unstaged?: boolean;
|
|
31
33
|
untracked?: boolean;
|
|
32
|
-
throwOnError?: boolean;
|
|
33
34
|
priority?: GitCommandPriority;
|
|
34
35
|
}, cancellation?: AbortSignal): Promise<boolean>;
|
|
36
|
+
/** Rejects when git fails, rather than answering all `false` */
|
|
35
37
|
getWorkingChangesState(repoPath: string, cancellation?: AbortSignal): Promise<GitWorkingChangesState>;
|
|
38
|
+
/** Rejects when git fails, rather than answering `false` */
|
|
36
39
|
hasConflictingFiles(repoPath: string, cancellation?: AbortSignal): Promise<boolean>;
|
|
40
|
+
/** Rejects when git fails, rather than answering empty */
|
|
37
41
|
getConflictingFiles(repoPath: string, cancellation?: AbortSignal): Promise<GitConflictFile[]>;
|
|
42
|
+
/** Rejects when git fails, rather than answering empty */
|
|
38
43
|
getUntrackedFiles(repoPath: string, cancellation?: AbortSignal): Promise<GitFile[]>;
|
|
39
44
|
}
|
|
40
45
|
//#endregion
|
package/dist/git/run.types.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { CacheController } from "../utils/promiseCache.js";
|
|
2
2
|
import { GitWarningKey } from "./errors.js";
|
|
3
3
|
import { RepositoryChange } from "./models/repository.js";
|
|
4
|
+
import { CancellationReason } from "../utils/cancellation.js";
|
|
4
5
|
import { GitHealthSlownessCategory } from "./gitHealth.js";
|
|
5
6
|
//#region ../git/src/run.types.d.ts
|
|
6
7
|
export type GitErrorHandling = 'throw' | 'ignore';
|
|
7
8
|
/**
|
|
8
|
-
* Why a run was
|
|
9
|
-
*
|
|
10
|
-
* from a duration heuristic and can be wrong near the timeout boundary.
|
|
9
|
+
* Why a run was cancelled. Exact, read from how the process ended: a caller abort, the run's own `timeout`, or a
|
|
10
|
+
* SIGTERM from outside (`unknown`).
|
|
11
11
|
*/
|
|
12
|
-
export type GitRunCancellation =
|
|
12
|
+
export type GitRunCancellation = CancellationReason;
|
|
13
13
|
/**
|
|
14
14
|
* Why a run produced no answer. Every value is structurally distinguishable, so these are safe to branch on.
|
|
15
15
|
*
|
|
@@ -91,6 +91,11 @@ export interface GitRunOptions {
|
|
|
91
91
|
configs?: readonly string[];
|
|
92
92
|
readonly correlationKey?: string;
|
|
93
93
|
errors?: GitErrorHandling;
|
|
94
|
+
/**
|
|
95
|
+
* Non-zero exit codes that are answers rather than failures (e.g. `1` from `diff --quiet`, "has differences");
|
|
96
|
+
* a listed code resolves as `exited` with that `exitCode` in every `errors` mode.
|
|
97
|
+
*/
|
|
98
|
+
expectedExitCodes?: readonly number[];
|
|
94
99
|
/** Priority level for queue ordering. If not specified, will be inferred from the command type. */
|
|
95
100
|
priority?: GitCommandPriority;
|
|
96
101
|
/** Specifies that this command should always be executed locally if possible (for live share sessions) */
|
package/dist/git-cli/exec/git.js
CHANGED
|
@@ -5,7 +5,7 @@ import { Logger as _logger } from "../../utils/logger.js";
|
|
|
5
5
|
import { formatLoggableScopeBlock } from "../../utils/logger.scoped.js";
|
|
6
6
|
import { defer } from "../../utils/promise.js";
|
|
7
7
|
import { arePathsEqual, dirname as dirname$1, isAbsolute as isAbsolute$1, isDescendant, joinPaths, normalizePath } from "../../utils/path.js";
|
|
8
|
-
import { GitWarnings, WorkspaceUntrustedError } from "../../git/errors.js";
|
|
8
|
+
import { GitWarnings, WorkspaceUntrustedError, getGitWarning } from "../../git/errors.js";
|
|
9
9
|
import { gitFeaturesByVersion } from "../../git/features.js";
|
|
10
10
|
import { CancelledRunError, RunError, endStdin, fsExists, runSpawn } from "../../utils/env/node/exec.js";
|
|
11
11
|
import { compare, fromString } from "../../utils/version.js";
|
|
@@ -616,7 +616,7 @@ var Git = class {
|
|
|
616
616
|
const start = hrtime();
|
|
617
617
|
const startEpochMs = Date.now();
|
|
618
618
|
gitCommand = `[${options.cwd}] ${gitCommand}`;
|
|
619
|
-
const { cancellation, configs, correlationKey, errors: errorHandling, encoding, runLocally: _, selfMaintenance, slownessCategory, ...opts } = options;
|
|
619
|
+
const { cancellation, configs, correlationKey, errors: errorHandling, encoding, expectedExitCodes, runLocally: _, selfMaintenance, slownessCategory, ...opts } = options;
|
|
620
620
|
const defaultTimeout = this.options.gitTimeout ?? 6e4;
|
|
621
621
|
const runOpts = {
|
|
622
622
|
...opts,
|
|
@@ -660,7 +660,7 @@ var Git = class {
|
|
|
660
660
|
try {
|
|
661
661
|
result = await promise;
|
|
662
662
|
if (result.exitCode == null) {
|
|
663
|
-
if (result.signal === "SIGTERM") throw new CancelledRunError(gitCommand, true, void 0, result.signal);
|
|
663
|
+
if (result.signal === "SIGTERM") throw new CancelledRunError(gitCommand, true, void 0, result.signal, result.killed ? "timeout" : "unknown");
|
|
664
664
|
return {
|
|
665
665
|
stdout: result.stdout,
|
|
666
666
|
stderr: result.stderr,
|
|
@@ -681,12 +681,24 @@ var Git = class {
|
|
|
681
681
|
}
|
|
682
682
|
};
|
|
683
683
|
} catch (ex) {
|
|
684
|
+
if (expectedExitCodes?.length && ex instanceof RunError && !(ex instanceof CancelledRunError)) {
|
|
685
|
+
const code = toExitCode(ex.code);
|
|
686
|
+
if (code != null && expectedExitCodes.includes(code)) return {
|
|
687
|
+
stdout: ex.stdout,
|
|
688
|
+
stderr: ex.stderr,
|
|
689
|
+
exitCode: code,
|
|
690
|
+
completion: {
|
|
691
|
+
status: "exited",
|
|
692
|
+
code
|
|
693
|
+
}
|
|
694
|
+
};
|
|
695
|
+
}
|
|
684
696
|
let cancellationReason = "unknown";
|
|
685
697
|
if (ex instanceof CancelledRunError) {
|
|
686
698
|
const duration = getDurationMilliseconds(start);
|
|
687
699
|
const timeout = runOpts.timeout ?? 0;
|
|
688
|
-
|
|
689
|
-
|
|
700
|
+
cancellationReason = ex.reason !== "unknown" ? ex.reason : cancellation?.aborted ? "aborted" : "unknown";
|
|
701
|
+
const reason = cancellationReason === "aborted" ? "cancellation" : cancellationReason;
|
|
690
702
|
const loopDelayAnnotation = this.formatEventLoopDelayAnnotation(startEpochMs);
|
|
691
703
|
const loopDelayText = loopDelayAnnotation != null ? ` \u00b7 ${loopDelayAnnotation}` : "";
|
|
692
704
|
_logger.warn(`${formatLoggableScopeBlock("GIT")} ${gitCommand} \u00b7 ABORTED after ${duration}ms (${reason})${loopDelayText}`);
|
|
@@ -699,17 +711,16 @@ var Git = class {
|
|
|
699
711
|
}
|
|
700
712
|
if (errorHandling === "ignore") {
|
|
701
713
|
if (ex instanceof RunError) {
|
|
702
|
-
const code =
|
|
703
|
-
const exited = Number.isInteger(code);
|
|
714
|
+
const code = toExitCode(ex.code);
|
|
704
715
|
return {
|
|
705
716
|
stdout: ex.stdout,
|
|
706
717
|
stderr: ex.stderr,
|
|
707
|
-
...
|
|
718
|
+
...code != null ? { exitCode: code } : {},
|
|
708
719
|
completion: ex instanceof CancelledRunError ? {
|
|
709
720
|
status: "cancelled",
|
|
710
721
|
reason: cancellationReason,
|
|
711
722
|
error: ex
|
|
712
|
-
} :
|
|
723
|
+
} : code != null ? {
|
|
713
724
|
status: "exited",
|
|
714
725
|
code
|
|
715
726
|
} : {
|
|
@@ -729,17 +740,17 @@ var Git = class {
|
|
|
729
740
|
}
|
|
730
741
|
};
|
|
731
742
|
}
|
|
732
|
-
if (ex instanceof CancelledRunError
|
|
743
|
+
if (ex instanceof CancelledRunError) exception = new CancellationError(ex, cancellationReason);
|
|
744
|
+
else if (!(ex instanceof RunError) && cancellation?.aborted) exception = new CancellationError(ex instanceof Error ? ex : void 0, "aborted");
|
|
733
745
|
else exception = new GitError(ex);
|
|
734
746
|
if (errorHandling === "throw") throw exception;
|
|
735
747
|
const swallowed = exception;
|
|
736
748
|
const warning = defaultExceptionHandler(exception, options.cwd, start);
|
|
737
749
|
exception = void 0;
|
|
738
|
-
const
|
|
739
|
-
const code = typeof rawCode === "number" ? rawCode : rawCode != null ? parseInt(rawCode, 10) : NaN;
|
|
750
|
+
const code = toExitCode(swallowed instanceof GitError ? swallowed.exitCode : void 0);
|
|
740
751
|
return {
|
|
741
752
|
stdout: "",
|
|
742
|
-
...
|
|
753
|
+
...code != null ? { exitCode: code } : {},
|
|
743
754
|
completion: {
|
|
744
755
|
status: "warned",
|
|
745
756
|
warning,
|
|
@@ -792,7 +803,7 @@ var Git = class {
|
|
|
792
803
|
}
|
|
793
804
|
if (signal === "SIGTERM") {
|
|
794
805
|
if (cancellation?.aborted) resolve();
|
|
795
|
-
else reject(new CancelledRunError(proc.spawnargs.join(" "), true, code ?? void 0, signal));
|
|
806
|
+
else reject(new CancelledRunError(proc.spawnargs.join(" "), true, code ?? void 0, signal, "unknown"));
|
|
796
807
|
return;
|
|
797
808
|
}
|
|
798
809
|
if (signal === "SIGPIPE" || code === 141 || code === 128 && stderrChunks.some((c) => c.includes("Connection reset by peer"))) {
|
|
@@ -961,6 +972,14 @@ var Git = class {
|
|
|
961
972
|
}
|
|
962
973
|
};
|
|
963
974
|
/**
|
|
975
|
+
* The exit code in a run error's `code`, or `undefined` when the process never exited normally: a numeric string
|
|
976
|
+
* is a real exit code, but an errno (`'ENOENT'`) means the spawn itself failed, and `undefined` means it was killed.
|
|
977
|
+
*/
|
|
978
|
+
function toExitCode(code) {
|
|
979
|
+
const exitCode = typeof code === "number" ? code : code != null ? parseInt(code, 10) : NaN;
|
|
980
|
+
return Number.isInteger(exitCode) ? exitCode : void 0;
|
|
981
|
+
}
|
|
982
|
+
/**
|
|
964
983
|
* Swallows an error whose message matches a known-benign {@link GitWarnings} pattern, returning WHICH one
|
|
965
984
|
* matched so the caller can record it — the distinction matters, since `noCommits` is a real answer while
|
|
966
985
|
* `notARepository` is a failed read. Rethrows anything else.
|
|
@@ -969,10 +988,11 @@ function defaultExceptionHandler(ex, cwd, start) {
|
|
|
969
988
|
if (isCancellationError(ex)) throw ex;
|
|
970
989
|
const msg = ex.message || ex.toString();
|
|
971
990
|
if (msg) {
|
|
972
|
-
|
|
991
|
+
const warning = getGitWarning(ex);
|
|
992
|
+
if (warning != null) {
|
|
973
993
|
const duration = start !== void 0 ? ` [${getDurationMilliseconds(start)}ms]` : "";
|
|
974
994
|
_logger.warn(`[${cwd}] Git ${msg.trim().replace(/fatal:\s*/g, "").replace(/\r?\n|\r/g, " · ")}${duration}`);
|
|
975
|
-
return
|
|
995
|
+
return warning;
|
|
976
996
|
}
|
|
977
997
|
const match = GitErrors.badRevision.exec(msg);
|
|
978
998
|
if (match != null) {
|