Skip to content

Commit 719ff9e

Browse files
committed
Renames stash usages
1 parent ba5dfbb commit 719ff9e

File tree

10 files changed

+80
-81
lines changed

10 files changed

+80
-81
lines changed

src/commands/git/stash.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ export class StashGitCommand extends QuickCommand<State> {
322322
while (this.canStepsContinue(state)) {
323323
if (state.counter < 3 || state.reference == null) {
324324
const result: StepResult<GitStashReference> = yield* pickStashStep(state, context, {
325-
stash: await this.container.git.getStash(state.repo.path),
325+
gitStash: await this.container.git.getStash(state.repo.path),
326326
placeholder: (_context, stash) =>
327327
stash == null
328328
? `No stashes found in ${state.repo.formattedName}`
@@ -427,7 +427,7 @@ export class StashGitCommand extends QuickCommand<State> {
427427
while (this.canStepsContinue(state)) {
428428
if (state.counter < 3 || !state.references?.length) {
429429
const result: StepResult<GitStashReference[]> = yield* pickStashesStep(state, context, {
430-
stash: await this.container.git.getStash(state.repo.path),
430+
gitStash: await this.container.git.getStash(state.repo.path),
431431
placeholder: (_context, stash) =>
432432
stash == null ? `No stashes found in ${state.repo.formattedName}` : 'Choose stashes to delete',
433433
picked: state.references?.map(r => r.ref),
@@ -481,7 +481,7 @@ export class StashGitCommand extends QuickCommand<State> {
481481
while (this.canStepsContinue(state)) {
482482
if (state.counter < 3 || state.reference == null) {
483483
const result: StepResult<GitStashCommit> = yield* pickStashStep(state, context, {
484-
stash: await this.container.git.getStash(state.repo.path),
484+
gitStash: await this.container.git.getStash(state.repo.path),
485485
placeholder: (_context, stash) =>
486486
stash == null ? `No stashes found in ${state.repo.formattedName}` : 'Choose a stash',
487487
picked: state.reference?.ref,
@@ -719,7 +719,7 @@ export class StashGitCommand extends QuickCommand<State> {
719719
while (this.canStepsContinue(state)) {
720720
if (state.counter < 3 || state.reference == null) {
721721
const result: StepResult<GitStashReference> = yield* pickStashStep(state, context, {
722-
stash: await this.container.git.getStash(state.repo.path),
722+
gitStash: await this.container.git.getStash(state.repo.path),
723723
placeholder: (_context, stash) =>
724724
stash == null ? `No stashes found in ${state.repo.formattedName}` : 'Choose a stash to rename',
725725
picked: state.reference?.ref,

src/commands/quickCommand.steps.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,33 +1665,33 @@ export function* pickStashStep<
16651665
context: Context,
16661666
{
16671667
ignoreFocusOut,
1668-
stash,
1668+
gitStash,
16691669
picked,
16701670
placeholder,
16711671
titleContext,
16721672
}: {
16731673
ignoreFocusOut?: boolean;
1674-
stash: GitStash | undefined;
1674+
gitStash: GitStash | undefined;
16751675
picked: string | string[] | undefined;
16761676
placeholder: string | ((context: Context, stash: GitStash | undefined) => string);
16771677
titleContext?: string;
16781678
},
16791679
): StepResultGenerator<GitStashCommit> {
16801680
const step = createPickStep<CommitQuickPickItem<GitStashCommit>>({
16811681
title: appendReposToTitle(`${context.title}${titleContext ?? ''}`, state, context),
1682-
placeholder: typeof placeholder === 'string' ? placeholder : placeholder(context, stash),
1682+
placeholder: typeof placeholder === 'string' ? placeholder : placeholder(context, gitStash),
16831683
ignoreFocusOut: ignoreFocusOut,
16841684
matchOnDescription: true,
16851685
matchOnDetail: true,
16861686
items:
1687-
stash == null
1687+
gitStash == null
16881688
? [createDirectiveQuickPickItem(Directive.Back, true), createDirectiveQuickPickItem(Directive.Cancel)]
16891689
: [
1690-
...map(stash.commits.values(), commit =>
1690+
...map(gitStash.stashes.values(), stash =>
16911691
createStashQuickPickItem(
1692-
commit,
1692+
stash,
16931693
picked != null &&
1694-
(typeof picked === 'string' ? commit.ref === picked : picked.includes(commit.ref)),
1694+
(typeof picked === 'string' ? stash.ref === picked : picked.includes(stash.ref)),
16951695
{
16961696
buttons: [ShowDetailsViewQuickInputButton],
16971697
compact: true,
@@ -1723,13 +1723,13 @@ export function* pickStashesStep<
17231723
context: Context,
17241724
{
17251725
ignoreFocusOut,
1726-
stash,
1726+
gitStash,
17271727
picked,
17281728
placeholder,
17291729
titleContext,
17301730
}: {
17311731
ignoreFocusOut?: boolean;
1732-
stash: GitStash | undefined;
1732+
gitStash: GitStash | undefined;
17331733
picked: string | string[] | undefined;
17341734
placeholder: string | ((context: Context, stash: GitStash | undefined) => string);
17351735
titleContext?: string;
@@ -1738,19 +1738,19 @@ export function* pickStashesStep<
17381738
const step = createPickStep<CommitQuickPickItem<GitStashCommit>>({
17391739
title: appendReposToTitle(`${context.title}${titleContext ?? ''}`, state, context),
17401740
multiselect: true,
1741-
placeholder: typeof placeholder === 'string' ? placeholder : placeholder(context, stash),
1741+
placeholder: typeof placeholder === 'string' ? placeholder : placeholder(context, gitStash),
17421742
ignoreFocusOut: ignoreFocusOut,
17431743
matchOnDescription: true,
17441744
matchOnDetail: true,
17451745
items:
1746-
stash == null
1746+
gitStash == null
17471747
? [createDirectiveQuickPickItem(Directive.Back, true), createDirectiveQuickPickItem(Directive.Cancel)]
17481748
: [
1749-
...map(stash.commits.values(), commit =>
1749+
...map(gitStash.stashes.values(), stash =>
17501750
createStashQuickPickItem(
1751-
commit,
1751+
stash,
17521752
picked != null &&
1753-
(typeof picked === 'string' ? commit.ref === picked : picked.includes(commit.ref)),
1753+
(typeof picked === 'string' ? stash.ref === picked : picked.includes(stash.ref)),
17541754
{
17551755
buttons: [ShowDetailsViewQuickInputButton],
17561756
compact: true,

src/env/node/git/localGitProvider.ts

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,9 +2435,9 @@ export class LocalGitProvider implements GitProvider, Disposable {
24352435
let stdin: string | undefined;
24362436

24372437
// TODO@eamodio this is insanity -- there *HAS* to be a better way to get git log to return stashes
2438-
const stash = getSettledValue(stashResult);
2439-
if (stash?.commits.size) {
2440-
stashes = new Map(stash.commits);
2438+
const gitStash = getSettledValue(stashResult);
2439+
if (gitStash?.stashes.size) {
2440+
stashes = new Map(gitStash.stashes);
24412441
stdin = join(
24422442
map(stashes.values(), c => c.sha.substring(0, 9)),
24432443
'\n',
@@ -2574,7 +2574,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
25742574
let remote: GitRemote | undefined;
25752575
let remoteBranchId: string;
25762576
let remoteName: string;
2577-
let stashCommit: GitStashCommit | undefined;
2577+
let stash: GitStashCommit | undefined;
25782578
let stats: GitGraphRowsStats | undefined;
25792579
let tagId: string;
25802580
let tagName: string;
@@ -2778,7 +2778,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
27782778
}
27792779
}
27802780

2781-
stashCommit = stash?.commits.get(commit.sha);
2781+
stash = gitStash?.stashes.get(commit.sha);
27822782

27832783
parents = commit.parents ? commit.parents.split(' ') : [];
27842784
if (reachableFromHEAD.has(commit.sha)) {
@@ -2788,15 +2788,15 @@ export class LocalGitProvider implements GitProvider, Disposable {
27882788
}
27892789

27902790
// Remove the second & third parent, if exists, from each stash commit as it is a Git implementation for the index and untracked files
2791-
if (stashCommit != null && parents.length > 1) {
2791+
if (stash != null && parents.length > 1) {
27922792
// Remap the "index commit" (e.g. contains staged files) of the stash
27932793
remappedIds.set(parents[1], commit.sha);
27942794
// Remap the "untracked commit" (e.g. contains untracked files) of the stash
27952795
remappedIds.set(parents[2], commit.sha);
27962796
parents.splice(1, 2);
27972797
}
27982798

2799-
if (stashCommit == null && !avatars.has(commit.authorEmail)) {
2799+
if (stash == null && !avatars.has(commit.authorEmail)) {
28002800
avatarUri = getCachedAvatarUri(commit.authorEmail);
28012801
if (avatarUri != null) {
28022802
avatars.set(commit.authorEmail, avatarUri.toString(true));
@@ -2805,16 +2805,16 @@ export class LocalGitProvider implements GitProvider, Disposable {
28052805

28062806
isCurrentUser = isUserMatch(currentUser, commit.author, commit.authorEmail);
28072807

2808-
if (stashCommit != null) {
2808+
if (stash != null) {
28092809
contexts.row = serializeWebviewItemContext<GraphItemRefContext>({
28102810
webviewItem: 'gitlens:stash',
28112811
webviewItemValue: {
28122812
type: 'stash',
28132813
ref: createReference(commit.sha, repoPath, {
28142814
refType: 'stash',
2815-
name: stashCommit.name,
2816-
message: stashCommit.message,
2817-
number: stashCommit.number,
2815+
name: stash.name,
2816+
message: stash.message,
2817+
number: stash.number,
28182818
}),
28192819
},
28202820
});
@@ -2852,7 +2852,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
28522852
date: Number(ordering === 'author-date' ? commit.authorDate : commit.committerDate) * 1000,
28532853
message: emojify(commit.message.trim()),
28542854
// TODO: review logic for stash, wip, etc
2855-
type: stashCommit != null ? 'stash-node' : parents.length > 1 ? 'merge-node' : 'commit-node',
2855+
type: stash != null ? 'stash-node' : parents.length > 1 ? 'merge-node' : 'commit-node',
28562856
heads: refHeads,
28572857
remotes: refRemoteHeads,
28582858
tags: refTags,
@@ -4996,8 +4996,8 @@ export class LocalGitProvider implements GitProvider, Disposable {
49964996
async getStash(repoPath: string | undefined): Promise<GitStash | undefined> {
49974997
if (repoPath == null) return undefined;
49984998

4999-
let stash = this.useCaching ? this._stashesCache.get(repoPath) : undefined;
5000-
if (stash === undefined) {
4999+
let gitStash = this.useCaching ? this._stashesCache.get(repoPath) : undefined;
5000+
if (gitStash === undefined) {
50015001
const parser = createLogParserWithFiles<{
50025002
sha: string;
50035003
date: string;
@@ -5018,10 +5018,9 @@ export class LocalGitProvider implements GitProvider, Disposable {
50185018
similarityThreshold: configuration.get('advanced.similarityThreshold'),
50195019
});
50205020

5021-
const commits = new Map<string, GitStashCommit>();
5021+
const stashes = new Map<string, GitStashCommit>();
50225022

5023-
const stashes = parser.parse(data);
5024-
for (const s of stashes) {
5023+
for (const s of parser.parse(data)) {
50255024
let onRef;
50265025
let summary;
50275026
let message;
@@ -5042,7 +5041,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
50425041
message = s.summary.trim();
50435042
}
50445043

5045-
commits.set(
5044+
stashes.set(
50465045
s.sha,
50475046
new GitCommit(
50485047
this.container,
@@ -5065,14 +5064,14 @@ export class LocalGitProvider implements GitProvider, Disposable {
50655064
);
50665065
}
50675066

5068-
stash = { repoPath: repoPath, commits: commits };
5067+
gitStash = { repoPath: repoPath, stashes: stashes };
50695068

50705069
if (this.useCaching) {
5071-
this._stashesCache.set(repoPath, stash ?? null);
5070+
this._stashesCache.set(repoPath, gitStash ?? null);
50725071
}
50735072
}
50745073

5075-
return stash ?? undefined;
5074+
return gitStash ?? undefined;
50765075
}
50775076

50785077
@log()
@@ -5558,15 +5557,15 @@ export class LocalGitProvider implements GitProvider, Disposable {
55585557

55595558
if (shas == null) {
55605559
// TODO@eamodio this is insanity -- there *HAS* to be a better way to get git log to return stashes
5561-
const stash = await this.getStash(repoPath);
5562-
if (stash?.commits.size) {
5560+
const gitStash = await this.getStash(repoPath);
5561+
if (gitStash?.stashes.size) {
55635562
stdin = '';
5564-
stashes = new Map(stash.commits);
5565-
for (const commit of stash.commits.values()) {
5566-
stdin += `${commit.sha.substring(0, 9)}\n`;
5563+
stashes = new Map(gitStash.stashes);
5564+
for (const stash of gitStash.stashes.values()) {
5565+
stdin += `${stash.sha.substring(0, 9)}\n`;
55675566
// Include the stash's 2nd (index files) and 3rd (untracked files) parents
5568-
for (const p of skip(commit.parents, 1)) {
5569-
stashes.set(p, commit);
5567+
for (const p of skip(stash.parents, 1)) {
5568+
stashes.set(p, stash);
55705569
stdin += `${p.substring(0, 9)}\n`;
55715570
}
55725571
}
@@ -5702,15 +5701,15 @@ export class LocalGitProvider implements GitProvider, Disposable {
57025701
let stdin: string | undefined;
57035702

57045703
// TODO@eamodio this is insanity -- there *HAS* to be a better way to get git log to return stashes
5705-
const stash = await this.getStash(repoPath);
5706-
if (stash?.commits.size) {
5704+
const gitStash = await this.getStash(repoPath);
5705+
if (gitStash?.stashes.size) {
57075706
stdin = '';
5708-
stashes = new Map(stash.commits);
5709-
for (const commit of stash.commits.values()) {
5710-
stdin += `${commit.sha.substring(0, 9)}\n`;
5707+
stashes = new Map(gitStash.stashes);
5708+
for (const stash of gitStash.stashes.values()) {
5709+
stdin += `${stash.sha.substring(0, 9)}\n`;
57115710
// Include the stash's 2nd (index files) and 3rd (untracked files) parents
5712-
for (const p of skip(commit.parents, 1)) {
5713-
stashes.set(p, commit);
5711+
for (const p of skip(stash.parents, 1)) {
5712+
stashes.set(p, stash);
57145713
stdin += `${p.substring(0, 9)}\n`;
57155714
}
57165715
}

src/git/models/stash.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import type { GitStashCommit } from './commit';
22

33
export interface GitStash {
44
readonly repoPath: string;
5-
readonly commits: Map<string, GitStashCommit>;
5+
readonly stashes: Map<string, GitStashCommit>;
66
}

src/plus/webviews/graph/graphWebview.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,8 +1093,8 @@ export class GraphWebviewProvider implements WebviewProvider<State, State, Graph
10931093
commit = await this.container.git.getCommit(this._graph.repoPath, uncommitted);
10941094
break;
10951095
case 'stash-node': {
1096-
const stash = await this.container.git.getStash(this._graph.repoPath);
1097-
commit = stash?.commits.get(msg.params.id);
1096+
const gitStash = await this.container.git.getStash(this._graph.repoPath);
1097+
commit = gitStash?.stashes.get(msg.params.id);
10981098
break;
10991099
}
11001100
default: {

src/quickpicks/commitPicker.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ export async function showCommitPicker(
233233
}
234234

235235
export async function showStashPicker(
236-
stash: GitStash | undefined | Promise<GitStash | undefined>,
236+
gitStash: GitStash | undefined | Promise<GitStash | undefined>,
237237
title: string,
238238
placeholder: string,
239239
options?: {
@@ -257,29 +257,29 @@ export async function showStashPicker(
257257
quickpick.matchOnDescription = true;
258258
quickpick.matchOnDetail = true;
259259

260-
if (isPromise(stash)) {
260+
if (isPromise(gitStash)) {
261261
quickpick.busy = true;
262262
quickpick.show();
263263

264-
stash = await stash;
264+
gitStash = await gitStash;
265265
}
266266

267-
if (stash != null) {
267+
if (gitStash != null) {
268268
quickpick.items = [
269269
...(options?.showOtherReferences ?? []),
270270
...map(
271-
options?.filter != null ? filter(stash.commits.values(), options.filter) : stash.commits.values(),
272-
commit =>
273-
createStashQuickPickItem(commit, options?.picked === commit.ref, {
271+
options?.filter != null ? filter(gitStash.stashes.values(), options.filter) : gitStash.stashes.values(),
272+
stash =>
273+
createStashQuickPickItem(stash, options?.picked === stash.ref, {
274274
compact: true,
275275
icon: true,
276276
}),
277277
),
278278
];
279279
}
280280

281-
if (stash == null || quickpick.items.length <= (options?.showOtherReferences?.length ?? 0)) {
282-
quickpick.placeholder = stash == null ? 'No stashes found' : options?.empty ?? `No matching stashes found`;
281+
if (gitStash == null || quickpick.items.length <= (options?.showOtherReferences?.length ?? 0)) {
282+
quickpick.placeholder = gitStash == null ? 'No stashes found' : options?.empty ?? `No matching stashes found`;
283283
quickpick.items = [createDirectiveQuickPickItem(Directive.Cancel)];
284284
}
285285

0 commit comments

Comments
 (0)