@gitkraken/core-gitlens 0.37.0 → 0.38.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 +67 -1
- package/dist/git/cache.d.ts +128 -8
- package/dist/git/cache.js +425 -46
- package/dist/git/cache.js.map +1 -1
- package/dist/git/features.d.ts +1 -1
- package/dist/git/features.js +3 -0
- package/dist/git/features.js.map +1 -1
- package/dist/git/providers/branches.d.ts +42 -1
- package/dist/git/providers/diff.d.ts +17 -0
- package/dist/git/providers/provider.d.ts +7 -0
- package/dist/git/providers/shared/remotes.js +8 -4
- package/dist/git/providers/shared/remotes.js.map +1 -1
- package/dist/git/remotes/matcher.js +2 -2
- package/dist/git/remotes/matcher.js.map +1 -1
- package/dist/git/repositoryService.d.ts +16 -1
- package/dist/git/repositoryService.js +51 -3
- package/dist/git/repositoryService.js.map +1 -1
- package/dist/git/run.types.d.ts +1 -0
- package/dist/git/service.js +6 -2
- package/dist/git/service.js.map +1 -1
- package/dist/git/utils/fileStatus.utils.d.ts +5 -0
- package/dist/git/utils/fileStatus.utils.js +18 -1
- package/dist/git/utils/fileStatus.utils.js.map +1 -1
- package/dist/git/watching/changeEvent.d.ts +13 -3
- package/dist/git/watching/changeEvent.js +15 -4
- package/dist/git/watching/changeEvent.js.map +1 -1
- package/dist/git/watching/changeOrdinal.d.ts +9 -0
- package/dist/git/watching/changeOrdinal.js +14 -0
- package/dist/git/watching/changeOrdinal.js.map +1 -0
- package/dist/git/watching/unwatchedCacheValidator.d.ts +38 -5
- package/dist/git/watching/unwatchedCacheValidator.js +180 -36
- package/dist/git/watching/unwatchedCacheValidator.js.map +1 -1
- package/dist/git/watching/watchGroup.d.ts +63 -14
- package/dist/git/watching/watchGroup.js +213 -74
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git/watching/watchService.js +4 -3
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git/watching/watchSession.d.ts +10 -2
- package/dist/git/watching/watchSession.js +18 -4
- package/dist/git/watching/watchSession.js.map +1 -1
- package/dist/git/watching/watcherPatterns.d.ts +18 -4
- package/dist/git/watching/watcherPatterns.js +39 -8
- package/dist/git/watching/watcherPatterns.js.map +1 -1
- package/dist/git/watching/worktreeSummary.d.ts +23 -12
- package/dist/git/watching/worktreeSummary.js +164 -41
- package/dist/git/watching/worktreeSummary.js.map +1 -1
- package/dist/git-cli/cliGitProvider.d.ts +1 -0
- package/dist/git-cli/cliGitProvider.js +11 -2
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/exec/git.d.ts +7 -2
- package/dist/git-cli/exec/git.js +46 -10
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/exec/headState.d.ts +24 -0
- package/dist/git-cli/exec/headState.js +46 -6
- package/dist/git-cli/exec/headState.js.map +1 -1
- package/dist/git-cli/parsers/logParser.js +6 -3
- package/dist/git-cli/parsers/logParser.js.map +1 -1
- package/dist/git-cli/providers/branches.d.ts +135 -10
- package/dist/git-cli/providers/branches.js +622 -80
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/commits.d.ts +16 -0
- package/dist/git-cli/providers/commits.js +80 -28
- package/dist/git-cli/providers/commits.js.map +1 -1
- package/dist/git-cli/providers/config.d.ts +10 -0
- package/dist/git-cli/providers/config.js +50 -12
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/contributors.js +11 -7
- package/dist/git-cli/providers/contributors.js.map +1 -1
- package/dist/git-cli/providers/diff.d.ts +12 -0
- package/dist/git-cli/providers/diff.js +107 -15
- package/dist/git-cli/providers/diff.js.map +1 -1
- package/dist/git-cli/providers/graph.js +32 -25
- package/dist/git-cli/providers/graph.js.map +1 -1
- package/dist/git-cli/providers/operations.d.ts +37 -3
- package/dist/git-cli/providers/operations.js +124 -46
- package/dist/git-cli/providers/operations.js.map +1 -1
- package/dist/git-cli/providers/patch.js +1 -1
- package/dist/git-cli/providers/patch.js.map +1 -1
- package/dist/git-cli/providers/refs.d.ts +1 -1
- package/dist/git-cli/providers/refs.js +10 -11
- package/dist/git-cli/providers/refs.js.map +1 -1
- package/dist/git-cli/providers/status.d.ts +4 -5
- package/dist/git-cli/providers/status.js +36 -33
- package/dist/git-cli/providers/status.js.map +1 -1
- package/dist/git-cli/providers/tags.d.ts +8 -0
- package/dist/git-cli/providers/tags.js +53 -34
- package/dist/git-cli/providers/tags.js.map +1 -1
- package/dist/git-cli/service.d.ts +15 -0
- package/dist/git-cli/service.js +19 -1
- package/dist/git-cli/service.js.map +1 -1
- package/dist/plus/git-github/api/github.d.ts +4 -0
- package/dist/plus/git-github/api/github.js +11 -1
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/providers/github/diff.d.ts +1 -0
- package/dist/plus/git-github/providers/github/diff.js +6 -1
- package/dist/plus/git-github/providers/github/diff.js.map +1 -1
- package/dist/plus/integrations/integrationService.js +9 -0
- package/dist/plus/integrations/integrationService.js.map +1 -1
- package/dist/plus/integrations/providers/jira-server.js +1 -1
- package/dist/plus/integrations/providers/jira-server.js.map +1 -1
- package/dist/plus/integrations/providers/jira.d.ts +38 -6
- package/dist/plus/integrations/providers/jira.js +111 -69
- package/dist/plus/integrations/providers/jira.js.map +1 -1
- package/dist/plus/integrations/providers/linear.d.ts +31 -3
- package/dist/plus/integrations/providers/linear.js +77 -18
- package/dist/plus/integrations/providers/linear.js.map +1 -1
- package/dist/plus/integrations/providers/utils/discoveryCache.d.ts +41 -4
- package/dist/plus/integrations/providers/utils/discoveryCache.js +50 -11
- package/dist/plus/integrations/providers/utils/discoveryCache.js.map +1 -1
- package/dist/utils/env/node/exec.d.ts +5 -4
- package/dist/utils/env/node/exec.js +52 -9
- package/dist/utils/env/node/exec.js.map +1 -1
- package/dist/utils/holdOffMap.d.ts +23 -0
- package/dist/utils/holdOffMap.js +43 -0
- package/dist/utils/holdOffMap.js.map +1 -0
- package/dist/utils/promiseCache.d.ts +15 -2
- package/dist/utils/promiseCache.js +34 -4
- package/dist/utils/promiseCache.js.map +1 -1
- package/package.json +1 -1
|
@@ -55,7 +55,8 @@ export declare class OperationsGitSubProvider implements GitOperationsSubProvide
|
|
|
55
55
|
* Writes the missing `refs/remotes/<remote>/HEAD` (the default branch the base reads) of each remote a fetch just
|
|
56
56
|
* read with its configured refspecs, once per remote, on git < 2.48 — newer git's fetch creates it itself. A bare
|
|
57
57
|
* fetch/pull reads every remote when `fetch.all` is set (git 2.44+), else its default remote. Right after the
|
|
58
|
-
* fetch, so the credentials it used are still cached. Never awaited; never rejects
|
|
58
|
+
* fetch, so the credentials it used are still cached. Never awaited; never rejects. A write that fails is not
|
|
59
|
+
* retried, but a config read that fails marks nothing, so a later fetch tries again.
|
|
59
60
|
*/
|
|
60
61
|
private followRemoteHeads;
|
|
61
62
|
/**
|
|
@@ -69,7 +70,8 @@ export declare class OperationsGitSubProvider implements GitOperationsSubProvide
|
|
|
69
70
|
* explicit refspecs still updates opportunistically, and which may store into local branches, as a mirror's do),
|
|
70
71
|
* and tags. A `remote` with no refspecs of its own may be a remote group (`remotes.<group>`), which fetches each of
|
|
71
72
|
* its remotes, so every remote's destinations stand for it. When the configuration can't be read, all local and
|
|
72
|
-
* remote-tracking branches stand for the configured destinations.
|
|
73
|
+
* remote-tracking branches stand for the configured destinations. `alsoMoves` are the refs the write may move
|
|
74
|
+
* besides what its fetch stores (a pull's merge or rebase moves local branches).
|
|
73
75
|
*/
|
|
74
76
|
private getFetchSnapshotPatterns;
|
|
75
77
|
/**
|
|
@@ -80,10 +82,17 @@ export declare class OperationsGitSubProvider implements GitOperationsSubProvide
|
|
|
80
82
|
* announcement can name (`refs/notes/*`), the kinds it did see, together with `fallback()`'s, unnamed.
|
|
81
83
|
*/
|
|
82
84
|
private announceFetch;
|
|
85
|
+
/**
|
|
86
|
+
* What moved since `snapshot` was taken, read again now, or `undefined` when either read is missing, so any ref it
|
|
87
|
+
* covers may have moved. Never rejects.
|
|
88
|
+
*/
|
|
89
|
+
private getMovedRefsSince;
|
|
83
90
|
/**
|
|
84
91
|
* Each ref under `patterns` (for-each-ref patterns) with its object and, for a symbolic ref, its target (a remote's
|
|
85
92
|
* `HEAD` can move to another branch at the same commit), or `undefined` when git couldn't answer. A read, so it
|
|
86
|
-
* announces nothing.
|
|
93
|
+
* announces nothing. `correlationKey` keeps it from joining an identical listing already in flight.
|
|
94
|
+
* `cancellation` is for a read before a write, which a cancelled caller no longer waits for; the one after it is
|
|
95
|
+
* never cancelled, since the write still announces.
|
|
87
96
|
*/
|
|
88
97
|
private snapshotRefs;
|
|
89
98
|
/** `remotes`, plus `heads`/`tags` for any local branch or tag the fetch writes — a `pull` fetch writes `<upstream>:<branch>` */
|
|
@@ -102,6 +111,31 @@ export declare class OperationsGitSubProvider implements GitOperationsSubProvide
|
|
|
102
111
|
tags?: boolean;
|
|
103
112
|
source?: unknown;
|
|
104
113
|
}, runOptions?: GitOperationRunOptions): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* A snapshot of every ref a `git pull` run in `repoPath` may move: what its fetch may store, from whichever remote a
|
|
116
|
+
* bare fetch reads (see {@link getFetchSnapshotPatterns}), every local branch, as its merge or rebase moves HEAD's
|
|
117
|
+
* branch, and a rebase that updates refs (`rebase.updateRefs`) moves others, and the stash, which keeps the
|
|
118
|
+
* autostashed changes when restoring them conflicts. Taken together with `repoPath`'s HEAD, which a pull may detach
|
|
119
|
+
* or rewrite (see {@link getPullMoved}), the two reads concurrently.
|
|
120
|
+
*/
|
|
121
|
+
private snapshotPullState;
|
|
122
|
+
/**
|
|
123
|
+
* What a pull run in `repoPath` moved, and how it left HEAD, read again now: its refs against `snapshot`, its HEAD
|
|
124
|
+
* against `headBefore` (see {@link getHeadWrite}). Never rejects.
|
|
125
|
+
*/
|
|
126
|
+
private getPullMoved;
|
|
127
|
+
/**
|
|
128
|
+
* Announces a pull's HEAD and index, and the refs it moved (see {@link getMovedRefsSince}): each ref kind only when a
|
|
129
|
+
* ref of it moved, named, so a sibling worktree that follows none of them skips its refresh. When `moved` is
|
|
130
|
+
* missing, or holds a ref no announcement can name, local and remote-tracking branches are announced unnamed, as if
|
|
131
|
+
* any of them may have moved, with tags and the stash beside them when one moved. `detached` says the pull left
|
|
132
|
+
* `repoPath`'s HEAD off the branch it was on (a rebase stopped partway), which every worktree's list of where each
|
|
133
|
+
* branch is checked out shows, so `worktrees` and `worktreeHead` are announced with it, as for a checkout. `rewrote`
|
|
134
|
+
* says the pull rewrote the HEAD file and put it back on its branch (a rebase that replayed commits detaches it,
|
|
135
|
+
* then points it back), which every other worktree's watcher reports as `worktreeHead`, so the kinds are announced
|
|
136
|
+
* for them to take the report for the pull's own. The list's placement of the branch is unchanged, so it is not
|
|
137
|
+
* reset.
|
|
138
|
+
*/
|
|
105
139
|
private announcePull;
|
|
106
140
|
private pullCore;
|
|
107
141
|
push(repoPath: string, options?: {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { chunkByStringLength } from "../../utils/iterable.js";
|
|
2
|
+
import { getScopedCounter } from "../../utils/counter.js";
|
|
2
3
|
import { Logger as _logger } from "../../utils/logger.js";
|
|
3
4
|
import { getScopedLogger } from "../../utils/logger.scoped.js";
|
|
4
5
|
import { debug } from "../../utils/decorators/log.js";
|
|
@@ -8,7 +9,7 @@ import __decorate from "../../_virtual/@oxc-project+runtime/helpers/esm/decorate
|
|
|
8
9
|
import { CheckoutError, CherryPickError, CommitError, FetchError, MergeError, PullError, PushError, RebaseError, ResetError, RevertError, SigningError } from "../../git/errors.js";
|
|
9
10
|
import { getRefChangeKind } from "../../git/watching/changeEvent.js";
|
|
10
11
|
import { mayWriteTracking } from "../exec/commandClassifier.js";
|
|
11
|
-
import { getMovedHead, readHeadState } from "../exec/headState.js";
|
|
12
|
+
import { getHeadWrite, getMovedHead, readHeadSnapshot, readHeadState } from "../exec/headState.js";
|
|
12
13
|
import { GitErrors, classifySigningError, getGitCommandError, gitConfigsPull, inferSigningFormatFromError, isRunHookFailure, maxGitCliLength } from "../exec/git.js";
|
|
13
14
|
import { refreshIndexAfter } from "../exec/indexRefresh.js";
|
|
14
15
|
import { resolveBranchRemote } from "./branchRemote.js";
|
|
@@ -23,6 +24,19 @@ const fetchRefChangeKinds = [
|
|
|
23
24
|
"tags",
|
|
24
25
|
"stash"
|
|
25
26
|
];
|
|
27
|
+
/** The kinds a pull announces, in order: `head` and `index` always, each ref kind when a ref of it may have moved */
|
|
28
|
+
const pullChanges = [
|
|
29
|
+
"head",
|
|
30
|
+
"heads",
|
|
31
|
+
"remotes",
|
|
32
|
+
"tags",
|
|
33
|
+
"stash",
|
|
34
|
+
"index"
|
|
35
|
+
];
|
|
36
|
+
/** The kinds a write that detaches or rewrites a worktree's HEAD file announces for every other worktree's watcher to take */
|
|
37
|
+
const worktreeHeadChanges = ["worktrees", "worktreeHead"];
|
|
38
|
+
/** Keys each listing taken after a write apart, so it never joins an identical listing started before the write */
|
|
39
|
+
const afterWriteListingCounter = getScopedCounter();
|
|
26
40
|
/** The destinations a fetch's snapshot covers when the remotes' configured refspecs can't be read */
|
|
27
41
|
const broadFetchDestinations = ["refs/heads", "refs/remotes"];
|
|
28
42
|
/**
|
|
@@ -233,7 +247,8 @@ var OperationsGitSubProvider = class {
|
|
|
233
247
|
* Writes the missing `refs/remotes/<remote>/HEAD` (the default branch the base reads) of each remote a fetch just
|
|
234
248
|
* read with its configured refspecs, once per remote, on git < 2.48 — newer git's fetch creates it itself. A bare
|
|
235
249
|
* fetch/pull reads every remote when `fetch.all` is set (git 2.44+), else its default remote. Right after the
|
|
236
|
-
* fetch, so the credentials it used are still cached. Never awaited; never rejects
|
|
250
|
+
* fetch, so the credentials it used are still cached. Never awaited; never rejects. A write that fails is not
|
|
251
|
+
* retried, but a config read that fails marks nothing, so a later fetch tries again.
|
|
237
252
|
*/
|
|
238
253
|
async followRemoteHeads(repoPath, fetched) {
|
|
239
254
|
try {
|
|
@@ -272,10 +287,11 @@ var OperationsGitSubProvider = class {
|
|
|
272
287
|
* explicit refspecs still updates opportunistically, and which may store into local branches, as a mirror's do),
|
|
273
288
|
* and tags. A `remote` with no refspecs of its own may be a remote group (`remotes.<group>`), which fetches each of
|
|
274
289
|
* its remotes, so every remote's destinations stand for it. When the configuration can't be read, all local and
|
|
275
|
-
* remote-tracking branches stand for the configured destinations.
|
|
290
|
+
* remote-tracking branches stand for the configured destinations. `alsoMoves` are the refs the write may move
|
|
291
|
+
* besides what its fetch stores (a pull's merge or rebase moves local branches).
|
|
276
292
|
*/
|
|
277
|
-
async getFetchSnapshotPatterns(repoPath, remote, refspecs) {
|
|
278
|
-
const destinations = [];
|
|
293
|
+
async getFetchSnapshotPatterns(repoPath, remote, refspecs, alsoMoves) {
|
|
294
|
+
const destinations = alsoMoves != null ? [...alsoMoves] : [];
|
|
279
295
|
const add = (refspec) => {
|
|
280
296
|
const destination = getRefspecDestination(refspec);
|
|
281
297
|
if (destination != null) destinations.push(destination);
|
|
@@ -303,39 +319,53 @@ var OperationsGitSubProvider = class {
|
|
|
303
319
|
* announcement can name (`refs/notes/*`), the kinds it did see, together with `fallback()`'s, unnamed.
|
|
304
320
|
*/
|
|
305
321
|
async announceFetch(repoPath, snapshot, fallback) {
|
|
306
|
-
const
|
|
322
|
+
const moved = await this.getMovedRefsSince(repoPath, snapshot);
|
|
323
|
+
if (moved?.refs?.length === 0) return;
|
|
307
324
|
let changes;
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
moved
|
|
311
|
-
if (!moved.length) return;
|
|
312
|
-
const kinds = /* @__PURE__ */ new Set();
|
|
313
|
-
let unnameable = false;
|
|
314
|
-
for (const ref of moved) {
|
|
315
|
-
const kind = ref.startsWith("refs/") ? getRefChangeKind(ref) : void 0;
|
|
316
|
-
if (kind != null) kinds.add(kind);
|
|
317
|
-
else unnameable = true;
|
|
318
|
-
}
|
|
319
|
-
if (unnameable) {
|
|
320
|
-
for (const kind of fallback()) kinds.add(kind);
|
|
321
|
-
moved = void 0;
|
|
322
|
-
}
|
|
325
|
+
if (moved != null) {
|
|
326
|
+
const kinds = new Set(moved.kinds);
|
|
327
|
+
if (moved.refs == null) for (const kind of fallback()) kinds.add(kind);
|
|
323
328
|
changes = fetchRefChangeKinds.filter((k) => kinds.has(k));
|
|
324
|
-
}
|
|
329
|
+
} else changes = fallback();
|
|
325
330
|
this.context.hooks?.cache?.onReset?.(repoPath, "branches", "tags");
|
|
326
|
-
if (
|
|
327
|
-
else this.context.hooks?.repository?.onChanged?.(repoPath, changes
|
|
331
|
+
if (moved?.refs != null) this.context.hooks?.repository?.onChanged?.(repoPath, changes, moved.refs);
|
|
332
|
+
else this.context.hooks?.repository?.onChanged?.(repoPath, changes);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* What moved since `snapshot` was taken, read again now, or `undefined` when either read is missing, so any ref it
|
|
336
|
+
* covers may have moved. Never rejects.
|
|
337
|
+
*/
|
|
338
|
+
async getMovedRefsSince(repoPath, snapshot) {
|
|
339
|
+
if (snapshot?.before == null) return void 0;
|
|
340
|
+
const after = await this.snapshotRefs(repoPath, snapshot.patterns, `after-write-${afterWriteListingCounter.next()}`);
|
|
341
|
+
if (after == null) return void 0;
|
|
342
|
+
const moved = getMovedRefs(snapshot.before, after);
|
|
343
|
+
const kinds = /* @__PURE__ */ new Set();
|
|
344
|
+
let unnameable = false;
|
|
345
|
+
for (const ref of moved) {
|
|
346
|
+
const kind = ref.startsWith("refs/") ? getRefChangeKind(ref) : void 0;
|
|
347
|
+
if (kind != null) kinds.add(kind);
|
|
348
|
+
else unnameable = true;
|
|
349
|
+
}
|
|
350
|
+
return {
|
|
351
|
+
kinds,
|
|
352
|
+
refs: unnameable ? void 0 : moved
|
|
353
|
+
};
|
|
328
354
|
}
|
|
329
355
|
/**
|
|
330
356
|
* Each ref under `patterns` (for-each-ref patterns) with its object and, for a symbolic ref, its target (a remote's
|
|
331
357
|
* `HEAD` can move to another branch at the same commit), or `undefined` when git couldn't answer. A read, so it
|
|
332
|
-
* announces nothing.
|
|
358
|
+
* announces nothing. `correlationKey` keeps it from joining an identical listing already in flight.
|
|
359
|
+
* `cancellation` is for a read before a write, which a cancelled caller no longer waits for; the one after it is
|
|
360
|
+
* never cancelled, since the write still announces.
|
|
333
361
|
*/
|
|
334
|
-
async snapshotRefs(repoPath, patterns) {
|
|
362
|
+
async snapshotRefs(repoPath, patterns, correlationKey, cancellation) {
|
|
335
363
|
try {
|
|
336
364
|
const result = await this.git.run({
|
|
337
365
|
cwd: repoPath,
|
|
338
|
-
errors: "ignore"
|
|
366
|
+
errors: "ignore",
|
|
367
|
+
correlationKey,
|
|
368
|
+
cancellation
|
|
339
369
|
}, "for-each-ref", "--format=%(refname)%00%(objectname)%00%(symref)", ...patterns);
|
|
340
370
|
if (result.completion.status !== "exited" || result.exitCode !== 0) return void 0;
|
|
341
371
|
const refs = /* @__PURE__ */ new Map();
|
|
@@ -439,9 +469,16 @@ var OperationsGitSubProvider = class {
|
|
|
439
469
|
const worktree = await this.provider.worktrees?.getWorktree(repoPath, (wt) => wt.branchName === branch.name);
|
|
440
470
|
if (worktree != null) {
|
|
441
471
|
const worktreePath = normalizePath(worktree.uri.fsPath);
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
472
|
+
const [snapshot, headBefore] = await this.snapshotPullState(worktreePath, runOptions);
|
|
473
|
+
announce = async () => {
|
|
474
|
+
const [moved, headWrite] = await this.getPullMoved(worktreePath, snapshot, headBefore);
|
|
475
|
+
if (worktreePath !== normalizePath(repoPath)) {
|
|
476
|
+
this.announcePull(repoPath, moved, {
|
|
477
|
+
detached: false,
|
|
478
|
+
rewrote: false
|
|
479
|
+
});
|
|
480
|
+
this.announcePull(worktreePath, moved, headWrite);
|
|
481
|
+
} else this.announcePull(repoPath, moved, headWrite);
|
|
445
482
|
};
|
|
446
483
|
this.context.hooks?.operations?.onRebaseCapableOperation?.(worktreePath, "pull", "started");
|
|
447
484
|
try {
|
|
@@ -471,10 +508,12 @@ var OperationsGitSubProvider = class {
|
|
|
471
508
|
]
|
|
472
509
|
}
|
|
473
510
|
});
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
511
|
+
const patterns = await this.getFetchSnapshotPatterns(repoPath, remoteName, [`${upstream}:${branchName}`]);
|
|
512
|
+
const snapshot = {
|
|
513
|
+
patterns,
|
|
514
|
+
before: await this.snapshotRefs(repoPath, patterns)
|
|
477
515
|
};
|
|
516
|
+
announce = () => this.announceFetch(repoPath, snapshot, () => ["heads", "remotes"]);
|
|
478
517
|
try {
|
|
479
518
|
await this.fetchCore(repoPath, {
|
|
480
519
|
branch: branchName,
|
|
@@ -493,7 +532,11 @@ var OperationsGitSubProvider = class {
|
|
|
493
532
|
} else await this.fetch(repoPath, { branch }, runOptions);
|
|
494
533
|
return;
|
|
495
534
|
}
|
|
496
|
-
|
|
535
|
+
const [snapshot, headBefore] = await this.snapshotPullState(repoPath, runOptions);
|
|
536
|
+
announce = async () => {
|
|
537
|
+
const [moved, headWrite] = await this.getPullMoved(repoPath, snapshot, headBefore);
|
|
538
|
+
this.announcePull(repoPath, moved, headWrite);
|
|
539
|
+
};
|
|
497
540
|
this.context.hooks?.operations?.onRebaseCapableOperation?.(repoPath, "pull", "started");
|
|
498
541
|
try {
|
|
499
542
|
await this.pullCore(repoPath, {
|
|
@@ -513,18 +556,54 @@ var OperationsGitSubProvider = class {
|
|
|
513
556
|
scope?.error(ex);
|
|
514
557
|
throw ex;
|
|
515
558
|
} finally {
|
|
516
|
-
announce?.();
|
|
559
|
+
await announce?.();
|
|
517
560
|
if (fetched != null) this.followRemoteHeads(fetched.repoPath, fetched.remotes);
|
|
518
561
|
}
|
|
519
562
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
563
|
+
/**
|
|
564
|
+
* A snapshot of every ref a `git pull` run in `repoPath` may move: what its fetch may store, from whichever remote a
|
|
565
|
+
* bare fetch reads (see {@link getFetchSnapshotPatterns}), every local branch, as its merge or rebase moves HEAD's
|
|
566
|
+
* branch, and a rebase that updates refs (`rebase.updateRefs`) moves others, and the stash, which keeps the
|
|
567
|
+
* autostashed changes when restoring them conflicts. Taken together with `repoPath`'s HEAD, which a pull may detach
|
|
568
|
+
* or rewrite (see {@link getPullMoved}), the two reads concurrently.
|
|
569
|
+
*/
|
|
570
|
+
async snapshotPullState(repoPath, runOptions) {
|
|
571
|
+
return Promise.all([(async () => {
|
|
572
|
+
const patterns = await this.getFetchSnapshotPatterns(repoPath, void 0, void 0, ["refs/heads", "refs/stash"]);
|
|
573
|
+
return {
|
|
574
|
+
patterns,
|
|
575
|
+
before: await this.snapshotRefs(repoPath, patterns, void 0, runOptions?.cancellation)
|
|
576
|
+
};
|
|
577
|
+
})(), readHeadSnapshot(repoPath, this.context.fs, this.cache)]);
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* What a pull run in `repoPath` moved, and how it left HEAD, read again now: its refs against `snapshot`, its HEAD
|
|
581
|
+
* against `headBefore` (see {@link getHeadWrite}). Never rejects.
|
|
582
|
+
*/
|
|
583
|
+
async getPullMoved(repoPath, snapshot, headBefore) {
|
|
584
|
+
const [moved, headAfter] = await Promise.all([this.getMovedRefsSince(repoPath, snapshot), readHeadSnapshot(repoPath, this.context.fs, this.cache)]);
|
|
585
|
+
return [moved, getHeadWrite(headBefore, headAfter)];
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Announces a pull's HEAD and index, and the refs it moved (see {@link getMovedRefsSince}): each ref kind only when a
|
|
589
|
+
* ref of it moved, named, so a sibling worktree that follows none of them skips its refresh. When `moved` is
|
|
590
|
+
* missing, or holds a ref no announcement can name, local and remote-tracking branches are announced unnamed, as if
|
|
591
|
+
* any of them may have moved, with tags and the stash beside them when one moved. `detached` says the pull left
|
|
592
|
+
* `repoPath`'s HEAD off the branch it was on (a rebase stopped partway), which every worktree's list of where each
|
|
593
|
+
* branch is checked out shows, so `worktrees` and `worktreeHead` are announced with it, as for a checkout. `rewrote`
|
|
594
|
+
* says the pull rewrote the HEAD file and put it back on its branch (a rebase that replayed commits detaches it,
|
|
595
|
+
* then points it back), which every other worktree's watcher reports as `worktreeHead`, so the kinds are announced
|
|
596
|
+
* for them to take the report for the pull's own. The list's placement of the branch is unchanged, so it is not
|
|
597
|
+
* reset.
|
|
598
|
+
*/
|
|
599
|
+
announcePull(repoPath, moved, { detached, rewrote }) {
|
|
600
|
+
if (detached) this.context.hooks?.cache?.onReset?.(repoPath, "branches", "status", "tags", "worktrees");
|
|
601
|
+
else this.context.hooks?.cache?.onReset?.(repoPath, "branches", "status", "tags");
|
|
602
|
+
const refs = moved?.refs;
|
|
603
|
+
const changes = pullChanges.filter((k) => k === "head" || k === "index" || moved?.kinds.has(k) === true || refs == null && (k === "heads" || k === "remotes"));
|
|
604
|
+
if (detached || rewrote) changes.push(...worktreeHeadChanges);
|
|
605
|
+
if (refs?.length) this.context.hooks?.repository?.onChanged?.(repoPath, changes, refs);
|
|
606
|
+
else this.context.hooks?.repository?.onChanged?.(repoPath, changes);
|
|
528
607
|
}
|
|
529
608
|
async pullCore(repoPath, options, runOptions) {
|
|
530
609
|
const params = ["pull"];
|
|
@@ -910,8 +989,7 @@ var OperationsGitSubProvider = class {
|
|
|
910
989
|
this.context.hooks?.repository?.onChanged?.(repoPath, [
|
|
911
990
|
"head",
|
|
912
991
|
"index",
|
|
913
|
-
|
|
914
|
-
"worktreeHead"
|
|
992
|
+
...worktreeHeadChanges
|
|
915
993
|
]);
|
|
916
994
|
return;
|
|
917
995
|
}
|
|
@@ -926,7 +1004,7 @@ var OperationsGitSubProvider = class {
|
|
|
926
1004
|
"heads",
|
|
927
1005
|
"index"
|
|
928
1006
|
];
|
|
929
|
-
if (rewroteHead) changes.push(
|
|
1007
|
+
if (rewroteHead) changes.push(...worktreeHeadChanges);
|
|
930
1008
|
if (moved == null) this.context.hooks?.repository?.onChanged?.(repoPath, changes);
|
|
931
1009
|
else if (wroteTracking) this.context.hooks?.repository?.onChanged?.(repoPath, changes, [moved.branch], { configConfinedToRefs: true });
|
|
932
1010
|
else this.context.hooks?.repository?.onChanged?.(repoPath, changes, [moved.branch]);
|