Skip to content

Commit 6a5c158

Browse files
committed
Refactors git provider naming and args consistency
1 parent 3566927 commit 6a5c158

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+407
-427
lines changed

src/annotations/gutterChangesAnnotationProvider.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -102,25 +102,25 @@ export class GutterChangesAnnotationProvider extends AnnotationProviderBase<Chan
102102
override async onProvideAnnotation(context?: ChangesAnnotationContext, state?: AnnotationState): Promise<boolean> {
103103
const scope = getLogScope();
104104

105-
let ref1 = this.trackedDocument.uri.sha;
106-
let ref2 = context?.sha != null && context.sha !== ref1 ? `${context.sha}^` : undefined;
105+
let rev1 = this.trackedDocument.uri.sha;
106+
let rev2 = context?.sha != null && context.sha !== rev1 ? `${context.sha}^` : undefined;
107107

108108
let commit: GitCommit | undefined;
109109

110110
const commitsProvider = this.container.git.commits(this.trackedDocument.uri.repoPath!);
111111

112-
let localChanges = ref1 == null && ref2 == null;
112+
let localChanges = rev1 == null && rev2 == null;
113113
if (localChanges) {
114-
let ref = await commitsProvider.getOldestUnpushedRefForFile(this.trackedDocument.uri);
115-
if (ref != null) {
116-
ref = `${ref}^`;
117-
commit = await commitsProvider.getCommitForFile(this.trackedDocument.uri, { ref: ref });
114+
let rev = await commitsProvider.getOldestUnpushedShaForFile(this.trackedDocument.uri);
115+
if (rev != null) {
116+
rev = `${rev}^`;
117+
commit = await commitsProvider.getCommitForFile(this.trackedDocument.uri, rev);
118118
if (commit != null) {
119-
if (ref2 != null) {
120-
ref2 = ref;
119+
if (rev2 != null) {
120+
rev2 = rev;
121121
} else {
122-
ref1 = ref;
123-
ref2 = '';
122+
rev1 = rev;
123+
rev2 = '';
124124
}
125125
} else {
126126
localChanges = false;
@@ -135,40 +135,40 @@ export class GutterChangesAnnotationProvider extends AnnotationProviderBase<Chan
135135
);
136136
if (commits?.length) {
137137
commit = await commitsProvider.getCommitForFile(this.trackedDocument.uri);
138-
ref1 = 'HEAD';
138+
rev1 = 'HEAD';
139139
} else if (this.trackedDocument.dirty) {
140-
ref1 = 'HEAD';
140+
rev1 = 'HEAD';
141141
} else {
142142
localChanges = false;
143143
}
144144
}
145145
}
146146

147147
if (!localChanges) {
148-
commit = await commitsProvider.getCommitForFile(this.trackedDocument.uri, { ref: ref2 ?? ref1 });
148+
commit = await commitsProvider.getCommitForFile(this.trackedDocument.uri, rev2 ?? rev1);
149149

150150
if (commit != null) {
151-
if (ref2 != null) {
152-
ref2 = commit.ref;
151+
if (rev2 != null) {
152+
rev2 = commit.ref;
153153
} else {
154-
ref1 = `${commit.ref}^`;
155-
ref2 = commit.ref;
154+
rev1 = `${commit.ref}^`;
155+
rev2 = commit.ref;
156156
}
157157
}
158158
}
159159

160160
const diffs = (
161161
await Promise.allSettled(
162-
ref2 == null && this.editor.document.isDirty
162+
rev2 == null && this.editor.document.isDirty
163163
? [
164164
this.container.git.getDiffForFileContents(
165165
this.trackedDocument.uri,
166-
ref1!,
166+
rev1!,
167167
this.editor.document.getText(),
168168
),
169-
this.container.git.getDiffForFile(this.trackedDocument.uri, ref1, ref2),
169+
this.container.git.getDiffForFile(this.trackedDocument.uri, rev1, rev2),
170170
]
171-
: [this.container.git.getDiffForFile(this.trackedDocument.uri, ref1, ref2)],
171+
: [this.container.git.getDiffForFile(this.trackedDocument.uri, rev1, rev2)],
172172
)
173173
)
174174
.map(d => getSettledValue(d))

src/commands/copyMessageToClipboard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class CopyMessageToClipboardCommand extends ActiveEditorCommand {
7373
repoPath = this.container.git.getBestRepository(editor)?.path;
7474
if (!repoPath) return;
7575

76-
const log = await this.container.git.commits(repoPath).getLog({ limit: 1 });
76+
const log = await this.container.git.commits(repoPath).getLog(undefined, { limit: 1 });
7777
if (log == null) return;
7878

7979
const commit = first(log.commits.values());

src/commands/copyShaToClipboard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class CopyShaToClipboardCommand extends ActiveEditorCommand {
6161
const repoPath = this.container.git.getBestRepository(editor)?.path;
6262
if (!repoPath) return;
6363

64-
const log = await this.container.git.commits(repoPath).getLog({ limit: 1 });
64+
const log = await this.container.git.commits(repoPath).getLog(undefined, { limit: 1 });
6565
if (log == null) return;
6666

6767
args.sha = first(log.commits.values())?.sha;

src/commands/diffFolderWithRevision.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ export class DiffFolderWithRevisionCommand extends ActiveEditorCommand {
5252
const log = commitsProvider
5353
.getLogForFile(gitUri.fsPath)
5454
.then(
55-
log =>
56-
log ??
57-
(gitUri.sha ? commitsProvider.getLogForFile(gitUri.fsPath, { ref: gitUri.sha }) : undefined),
55+
log => log ?? (gitUri.sha ? commitsProvider.getLogForFile(gitUri.fsPath, gitUri.sha) : undefined),
5856
);
5957

6058
const relativePath = this.container.git.getRelativePath(uri, repoPath);

src/commands/diffWith.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export class DiffWithCommand extends GlCommandBase {
117117
// Ensure that the file still exists in this commit
118118
const status = await this.container.git
119119
.commits(args.repoPath)
120-
.getFileStatusForCommit(args.rhs.uri, args.rhs.sha);
120+
.getCommitFileStatus(args.rhs.uri, args.rhs.sha);
121121
if (status?.status === 'D') {
122122
args.rhs.sha = deletedOrMissing;
123123
} else {

src/commands/diffWithRevision.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ export class DiffWithRevisionCommand extends ActiveEditorCommand {
4545
const log = commitsProvider
4646
.getLogForFile(gitUri.fsPath)
4747
.then(
48-
log =>
49-
log ??
50-
(gitUri.sha ? commitsProvider.getLogForFile(gitUri.fsPath, { ref: gitUri.sha }) : undefined),
48+
log => log ?? (gitUri.sha ? commitsProvider.getLogForFile(gitUri.fsPath, gitUri.sha) : undefined),
5149
);
5250

5351
const title = `Open Changes with Revision${pad(GlyphChars.Dot, 2, 2)}`;

src/commands/git/cherry-pick.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,20 +187,20 @@ export class CherryPickGitCommand extends QuickCommand<State> {
187187
}
188188

189189
if (state.counter < 3 && context.selectedBranchOrTag != null) {
190-
const ref = createRevisionRange(context.destination.ref, context.selectedBranchOrTag.ref, '..');
190+
const rev = createRevisionRange(context.destination.ref, context.selectedBranchOrTag.ref, '..');
191191

192-
let log = context.cache.get(ref);
192+
let log = context.cache.get(rev);
193193
if (log == null) {
194-
log = state.repo.git.commits().getLog({ ref: ref, merges: 'first-parent' });
195-
context.cache.set(ref, log);
194+
log = state.repo.git.commits().getLog(rev, { merges: 'first-parent' });
195+
context.cache.set(rev, log);
196196
}
197197

198198
const result: StepResult<GitReference[]> = yield* pickCommitsStep(
199199
state as CherryPickStepState,
200200
context,
201201
{
202202
log: await log,
203-
onDidLoadMore: log => context.cache.set(ref, Promise.resolve(log)),
203+
onDidLoadMore: log => context.cache.set(rev, Promise.resolve(log)),
204204
picked: state.references?.map(r => r.ref),
205205
placeholder: (context, log) =>
206206
log == null

src/commands/git/log.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,21 +158,21 @@ export class LogGitCommand extends QuickCommand<State> {
158158
}
159159

160160
if (state.counter < 3 && context.selectedBranchOrTag != null) {
161-
const ref = context.selectedBranchOrTag.ref;
161+
const rev = context.selectedBranchOrTag.ref;
162162

163-
let log = context.cache.get(ref);
163+
let log = context.cache.get(rev);
164164
if (log == null) {
165165
log =
166166
state.fileName != null
167-
? state.repo.git.commits().getLogForFile(state.fileName, { ref: ref })
168-
: state.repo.git.commits().getLog({ ref: ref });
169-
context.cache.set(ref, log);
167+
? state.repo.git.commits().getLogForFile(state.fileName, rev)
168+
: state.repo.git.commits().getLog(rev);
169+
context.cache.set(rev, log);
170170
}
171171

172172
const result = yield* pickCommitStep(state, context, {
173173
ignoreFocusOut: true,
174174
log: await log,
175-
onDidLoadMore: log => context.cache.set(ref, Promise.resolve(log)),
175+
onDidLoadMore: log => context.cache.set(rev, Promise.resolve(log)),
176176
placeholder: (context, log) =>
177177
log == null
178178
? `No commits found in ${getReferenceLabel(context.selectedBranchOrTag, {

src/commands/git/merge.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,18 +171,18 @@ export class MergeGitCommand extends QuickCommand<State> {
171171
context.selectedBranchOrTag != null &&
172172
(context.pickCommit || context.pickCommitForItem || state.reference.ref === context.destination.ref)
173173
) {
174-
const ref = context.selectedBranchOrTag.ref;
174+
const rev = context.selectedBranchOrTag.ref;
175175

176-
let log = context.cache.get(ref);
176+
let log = context.cache.get(rev);
177177
if (log == null) {
178-
log = state.repo.git.commits().getLog({ ref: ref, merges: 'first-parent' });
179-
context.cache.set(ref, log);
178+
log = state.repo.git.commits().getLog(rev, { merges: 'first-parent' });
179+
context.cache.set(rev, log);
180180
}
181181

182182
const result: StepResult<GitReference> = yield* pickCommitStep(state as MergeStepState, context, {
183183
ignoreFocusOut: true,
184184
log: await log,
185-
onDidLoadMore: log => context.cache.set(ref, Promise.resolve(log)),
185+
onDidLoadMore: log => context.cache.set(rev, Promise.resolve(log)),
186186
placeholder: (context, log) =>
187187
log == null
188188
? `No commits found on ${getReferenceLabel(context.selectedBranchOrTag, {

src/commands/git/rebase.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,18 @@ export class RebaseGitCommand extends QuickCommand<State> {
181181
context.selectedBranchOrTag != null &&
182182
(context.pickCommit || context.pickCommitForItem || state.destination.ref === context.branch.ref)
183183
) {
184-
const ref = context.selectedBranchOrTag.ref;
184+
const rev = context.selectedBranchOrTag.ref;
185185

186-
let log = context.cache.get(ref);
186+
let log = context.cache.get(rev);
187187
if (log == null) {
188-
log = state.repo.git.commits().getLog({ ref: ref, merges: 'first-parent' });
189-
context.cache.set(ref, log);
188+
log = state.repo.git.commits().getLog(rev, { merges: 'first-parent' });
189+
context.cache.set(rev, log);
190190
}
191191

192192
const result: StepResult<GitReference> = yield* pickCommitStep(state as RebaseStepState, context, {
193193
ignoreFocusOut: true,
194194
log: await log,
195-
onDidLoadMore: log => context.cache.set(ref, Promise.resolve(log)),
195+
onDidLoadMore: log => context.cache.set(rev, Promise.resolve(log)),
196196
placeholder: (context, log) =>
197197
log == null
198198
? `No commits found on ${getReferenceLabel(context.selectedBranchOrTag, {

0 commit comments

Comments
 (0)