mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-01-22 17:26:10 -05:00
Enables typescript strict mode
Fixes all the compile/lint issues
This commit is contained in:
@@ -33,11 +33,11 @@ export class CloseUnchangedFilesCommand extends ActiveEditorCommand {
|
||||
let active = window.activeTextEditor;
|
||||
let editor = active;
|
||||
do {
|
||||
if (editor) {
|
||||
if ((editor.document && editor.document.isDirty) ||
|
||||
uris.some(_ => UriComparer.equals(_, editor.document && editor.document.uri))) {
|
||||
if (editor !== undefined) {
|
||||
if ((editor.document !== undefined && editor.document.isDirty) ||
|
||||
uris.some(_ => UriComparer.equals(_, editor!.document && editor!.document.uri))) {
|
||||
// If we didn't start with a valid editor, set one once we find it
|
||||
if (!active) {
|
||||
if (active === undefined) {
|
||||
active = editor;
|
||||
}
|
||||
editor = await editorTracker.awaitNext(500);
|
||||
@@ -55,7 +55,7 @@ export class CloseUnchangedFilesCommand extends ActiveEditorCommand {
|
||||
}
|
||||
editor = await editorTracker.awaitClose(500);
|
||||
}
|
||||
} while ((!active && !editor) || !TextEditorComparer.equals(active, editor, { useId: true, usePosition: true }));
|
||||
} while ((active === undefined && editor === undefined) || !TextEditorComparer.equals(active, editor, { useId: true, usePosition: true }));
|
||||
|
||||
editorTracker.dispose();
|
||||
|
||||
|
||||
@@ -59,7 +59,6 @@ export const CommandContext = {
|
||||
Key: 'gitlens:key' as CommandContext
|
||||
};
|
||||
|
||||
|
||||
export function setCommandContext(key: CommandContext | string, value: any) {
|
||||
return commands.executeCommand(BuiltInCommands.SetContext, key, value);
|
||||
}
|
||||
@@ -119,7 +118,7 @@ export abstract class ActiveEditorCommand extends Command {
|
||||
abstract execute(editor: TextEditor, ...args: any[]): any;
|
||||
}
|
||||
|
||||
let lastCommand: { command: string, args: any[] } = undefined;
|
||||
let lastCommand: { command: string, args: any[] } | undefined = undefined;
|
||||
export function getLastCommand() {
|
||||
return lastCommand;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ export class DiffDirectoryCommand extends ActiveEditorCommand {
|
||||
if (!shaOrBranch1) {
|
||||
const branches = await this.git.getBranches(repoPath);
|
||||
const current = Iterables.find(branches, _ => _.current);
|
||||
if (current == null) return window.showWarningMessage(`Unable to open directory compare`);
|
||||
|
||||
const pick = await BranchesQuickPick.show(branches, `Compare ${current.name} to \u2026`);
|
||||
if (!pick) return undefined;
|
||||
|
||||
@@ -43,7 +43,7 @@ export class DiffLineWithPreviousCommand extends ActiveEditorCommand {
|
||||
// If the line is uncommitted, find the previous commit and treat it as a DiffWithWorking
|
||||
if (commit.isUncommitted) {
|
||||
uri = commit.uri;
|
||||
commit = new GitCommit(commit.type, commit.repoPath, commit.previousSha, commit.previousFileName, commit.author, commit.date, commit.message);
|
||||
commit = new GitCommit(commit.type, commit.repoPath, commit.previousSha!, commit.previousFileName!, commit.author, commit.date, commit.message);
|
||||
line = (blame.line.line + 1) + gitUri.offset;
|
||||
return commands.executeCommand(Commands.DiffWithWorking, uri, commit, line);
|
||||
}
|
||||
@@ -56,10 +56,10 @@ export class DiffLineWithPreviousCommand extends ActiveEditorCommand {
|
||||
|
||||
try {
|
||||
const [rhs, lhs] = await Promise.all([
|
||||
this.git.getVersionedFile(gitUri.repoPath, gitUri.fsPath, gitUri.sha),
|
||||
this.git.getVersionedFile(gitUri.repoPath, gitUri.fsPath, gitUri.sha!),
|
||||
this.git.getVersionedFile(commit.repoPath, commit.uri.fsPath, commit.sha)
|
||||
]);
|
||||
await commands.executeCommand(BuiltInCommands.Diff, Uri.file(lhs), Uri.file(rhs), `${path.basename(commit.uri.fsPath)} (${commit.shortSha}) ↔ ${path.basename(gitUri.fsPath)} (${gitUri.shortSha})`);
|
||||
await commands.executeCommand(BuiltInCommands.Diff, Uri.file(lhs), Uri.file(rhs), `${path.basename(commit.uri.fsPath)} (${commit.shortSha}) \u2194 ${path.basename(gitUri.fsPath)} (${gitUri.shortSha})`);
|
||||
// TODO: Figure out how to focus the left pane
|
||||
return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' });
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ export class DiffLineWithWorkingCommand extends ActiveEditorCommand {
|
||||
commit = blame.commit;
|
||||
// If the line is uncommitted, find the previous commit
|
||||
if (commit.isUncommitted) {
|
||||
commit = new GitCommit(commit.type, commit.repoPath, commit.previousSha, commit.previousFileName, commit.author, commit.date, commit.message);
|
||||
commit = new GitCommit(commit.type, commit.repoPath, commit.previousSha!, commit.previousFileName!, commit.author, commit.date, commit.message);
|
||||
line = blame.line.line + 1 + gitUri.offset;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ export class DiffWithBranchCommand extends ActiveEditorCommand {
|
||||
const line = (editor && editor.selection.active.line) || 0;
|
||||
|
||||
const gitUri = await GitUri.fromUri(uri, this.git);
|
||||
if (gitUri.repoPath === undefined) return undefined;
|
||||
|
||||
const branches = await this.git.getBranches(gitUri.repoPath);
|
||||
const pick = await BranchesQuickPick.show(branches, `Compare ${path.basename(gitUri.fsPath)} to \u2026`, goBackCommand);
|
||||
@@ -36,7 +37,7 @@ export class DiffWithBranchCommand extends ActiveEditorCommand {
|
||||
|
||||
try {
|
||||
const compare = await this.git.getVersionedFile(gitUri.repoPath, gitUri.fsPath, branch);
|
||||
await commands.executeCommand(BuiltInCommands.Diff, Uri.file(compare), gitUri.fileUri(), `${path.basename(gitUri.fsPath)} (${branch}) ↔ ${path.basename(gitUri.fsPath)}`);
|
||||
await commands.executeCommand(BuiltInCommands.Diff, Uri.file(compare), gitUri.fileUri(), `${path.basename(gitUri.fsPath)} (${branch}) \u2194 ${path.basename(gitUri.fsPath)}`);
|
||||
return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' });
|
||||
}
|
||||
catch (ex) {
|
||||
|
||||
@@ -42,7 +42,7 @@ export class DiffWithNextCommand extends ActiveEditorCommand {
|
||||
|
||||
const sha = (commit && commit.sha) || gitUri.sha;
|
||||
|
||||
const log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, undefined, sha ? undefined : 2, rangeOrLine as Range);
|
||||
const log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, undefined, sha ? undefined : 2, rangeOrLine!);
|
||||
if (!log) return window.showWarningMessage(`Unable to open compare. File is probably not under source control`);
|
||||
|
||||
commit = (sha && log.commits.get(sha)) || Iterables.first(log.commits.values());
|
||||
@@ -62,7 +62,7 @@ export class DiffWithNextCommand extends ActiveEditorCommand {
|
||||
this.git.getVersionedFile(commit.repoPath, commit.nextUri.fsPath, commit.nextSha),
|
||||
this.git.getVersionedFile(commit.repoPath, commit.uri.fsPath, commit.sha)
|
||||
]);
|
||||
await commands.executeCommand(BuiltInCommands.Diff, Uri.file(lhs), Uri.file(rhs), `${path.basename(commit.uri.fsPath)} (${commit.shortSha}) ↔ ${path.basename(commit.nextUri.fsPath)} (${commit.nextShortSha})`);
|
||||
await commands.executeCommand(BuiltInCommands.Diff, Uri.file(lhs), Uri.file(rhs), `${path.basename(commit.uri.fsPath)} (${commit.shortSha}) \u2194 ${path.basename(commit.nextUri.fsPath)} (${commit.nextShortSha})`);
|
||||
return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' });
|
||||
}
|
||||
catch (ex) {
|
||||
|
||||
@@ -43,7 +43,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
|
||||
|
||||
const sha = (commit && commit.sha) || gitUri.sha;
|
||||
|
||||
const log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, undefined, sha ? undefined : 2, rangeOrLine as Range);
|
||||
const log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, undefined, sha ? undefined : 2, rangeOrLine!);
|
||||
if (!log) return window.showWarningMessage(`Unable to open compare. File is probably not under source control`);
|
||||
|
||||
commit = (sha && log.commits.get(sha)) || Iterables.first(log.commits.values());
|
||||
@@ -63,7 +63,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
|
||||
this.git.getVersionedFile(commit.repoPath, commit.uri.fsPath, commit.sha),
|
||||
this.git.getVersionedFile(commit.repoPath, commit.previousUri.fsPath, commit.previousSha)
|
||||
]);
|
||||
await commands.executeCommand(BuiltInCommands.Diff, Uri.file(lhs), Uri.file(rhs), `${path.basename(commit.previousUri.fsPath)} (${commit.previousShortSha}) ↔ ${path.basename(commit.uri.fsPath)} (${commit.shortSha})`);
|
||||
await commands.executeCommand(BuiltInCommands.Diff, Uri.file(lhs), Uri.file(rhs), `${path.basename(commit.previousUri.fsPath)} (${commit.previousShortSha}) \u2194 ${path.basename(commit.uri.fsPath)} (${commit.shortSha})`);
|
||||
// TODO: Figure out how to focus the left pane
|
||||
return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' });
|
||||
}
|
||||
|
||||
@@ -39,10 +39,11 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
|
||||
const gitUri = await GitUri.fromUri(uri, this.git);
|
||||
|
||||
const workingFileName = await this.git.findWorkingFileName(gitUri.repoPath, gitUri.fsPath);
|
||||
if (workingFileName === undefined) return undefined;
|
||||
|
||||
try {
|
||||
const compare = await this.git.getVersionedFile(commit.repoPath, commit.uri.fsPath, commit.sha);
|
||||
await commands.executeCommand(BuiltInCommands.Diff, Uri.file(compare), Uri.file(path.resolve(gitUri.repoPath, workingFileName)), `${path.basename(commit.uri.fsPath)} (${commit.shortSha}) ↔ ${path.basename(workingFileName)}`);
|
||||
await commands.executeCommand(BuiltInCommands.Diff, Uri.file(compare), Uri.file(path.resolve(gitUri.repoPath, workingFileName)), `${path.basename(commit.uri.fsPath)} (${commit.shortSha}) \u2194 ${path.basename(workingFileName)}`);
|
||||
return await commands.executeCommand(BuiltInCommands.RevealLine, { lineNumber: line, at: 'center' });
|
||||
}
|
||||
catch (ex) {
|
||||
|
||||
@@ -16,7 +16,7 @@ export const keys: Keys[] = [
|
||||
'.'
|
||||
];
|
||||
|
||||
export declare type KeyMapping = { [id: string]: (QuickPickItem | (() => Promise<QuickPickItem>)) };
|
||||
export declare type KeyMapping = { [id: string]: (QuickPickItem | (() => Promise<QuickPickItem>) | undefined) };
|
||||
let mappings: KeyMapping[] = [];
|
||||
|
||||
let _instance: Keyboard;
|
||||
@@ -113,7 +113,7 @@ export class Keyboard extends Disposable {
|
||||
return await new KeyboardScope(mapping ? Object.assign(Object.create(null), mapping) : Object.create(null)).begin();
|
||||
}
|
||||
|
||||
async execute(key: Keys): Promise<{}> {
|
||||
async execute(key: Keys): Promise<{} | undefined> {
|
||||
if (!mappings.length) return undefined;
|
||||
|
||||
try {
|
||||
|
||||
@@ -34,7 +34,7 @@ export class OpenCommitInRemoteCommand extends ActiveEditorCommand {
|
||||
let commit = blame.commit;
|
||||
// If the line is uncommitted, find the previous commit
|
||||
if (commit.isUncommitted) {
|
||||
commit = new GitCommit(commit.type, commit.repoPath, commit.previousSha, commit.previousFileName, commit.author, commit.date, commit.message);
|
||||
commit = new GitCommit(commit.type, commit.repoPath, commit.previousSha!, commit.previousFileName!, commit.author, commit.date, commit.message);
|
||||
}
|
||||
|
||||
const remotes = Arrays.uniqueBy(await this.git.getRemotes(gitUri.repoPath), _ => _.url, _ => !!_.provider);
|
||||
|
||||
@@ -27,7 +27,7 @@ export class OpenFileInRemoteCommand extends ActiveEditorCommand {
|
||||
try {
|
||||
const remotes = Arrays.uniqueBy(await this.git.getRemotes(gitUri.repoPath), _ => _.url, _ => !!_.provider);
|
||||
const range = editor && new Range(editor.selection.start.with({ line: editor.selection.start.line + 1 }), editor.selection.end.with({ line: editor.selection.end.line + 1 }));
|
||||
return commands.executeCommand(Commands.OpenInRemote, uri, remotes, 'file', [gitUri.getRelativePath(), branch.name, gitUri.sha, range]);
|
||||
return commands.executeCommand(Commands.OpenInRemote, uri, remotes, 'file', [gitUri.getRelativePath(), branch === undefined ? 'Current' : branch.name, gitUri.sha, range]);
|
||||
}
|
||||
catch (ex) {
|
||||
Logger.error(ex, 'OpenFileInRemoteCommand');
|
||||
|
||||
@@ -11,20 +11,21 @@ export class OpenInRemoteCommand extends ActiveEditorCommand {
|
||||
super(Commands.OpenInRemote);
|
||||
}
|
||||
|
||||
async execute(editor: TextEditor, uri?: Uri, remotes?: GitRemote[], type?: RemoteOpenType, args?: string[], goBackCommand?: CommandQuickPickItem) {
|
||||
async execute(editor: TextEditor, uri?: Uri, remotes?: GitRemote[], type?: RemoteOpenType, args: string[] = [], goBackCommand?: CommandQuickPickItem) {
|
||||
if (!(uri instanceof Uri)) {
|
||||
uri = editor && editor.document && editor.document.uri;
|
||||
}
|
||||
|
||||
try {
|
||||
if (!remotes) return undefined;
|
||||
if (remotes === undefined) return undefined;
|
||||
if (type === undefined) throw new Error(`Invalid type ${type}`);
|
||||
|
||||
if (remotes.length === 1) {
|
||||
const command = new OpenRemoteCommandQuickPickItem(remotes[0], type, ...args);
|
||||
return command.execute();
|
||||
}
|
||||
|
||||
let placeHolder: string;
|
||||
let placeHolder: string = '';
|
||||
switch (type) {
|
||||
case 'branch':
|
||||
placeHolder = `open ${args[0]} branch in\u2026`;
|
||||
|
||||
@@ -25,6 +25,7 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand {
|
||||
}
|
||||
|
||||
const gitUri = await GitUri.fromUri(uri, this.git);
|
||||
if (gitUri.repoPath === undefined) return undefined;
|
||||
|
||||
if (!search || searchBy == null) {
|
||||
search = await window.showInputBox({
|
||||
@@ -48,10 +49,15 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand {
|
||||
}
|
||||
|
||||
try {
|
||||
const log = await this.git.getLogForRepoSearch(gitUri.repoPath, search, searchBy);
|
||||
if (searchBy === undefined) {
|
||||
searchBy = GitRepoSearchBy.Message;
|
||||
}
|
||||
|
||||
let originalSearch: string;
|
||||
let placeHolder: string;
|
||||
const log = await this.git.getLogForRepoSearch(gitUri.repoPath, search, searchBy);
|
||||
if (log === undefined) return undefined;
|
||||
|
||||
let originalSearch: string | undefined = undefined;
|
||||
let placeHolder: string | undefined = undefined;
|
||||
switch (searchBy) {
|
||||
case GitRepoSearchBy.Author:
|
||||
originalSearch = `@${search}`;
|
||||
@@ -77,7 +83,7 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand {
|
||||
description: `\u00a0 \u2014 \u00a0\u00a0 to commit search`
|
||||
}, Commands.ShowCommitSearch, [gitUri, originalSearch, undefined, goBackCommand]);
|
||||
|
||||
const pick = await CommitsQuickPick.show(this.git, log, placeHolder, currentCommand);
|
||||
const pick = await CommitsQuickPick.show(this.git, log, placeHolder!, currentCommand);
|
||||
if (!pick) return undefined;
|
||||
|
||||
if (pick instanceof CommandQuickPickItem) {
|
||||
|
||||
@@ -22,12 +22,12 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand {
|
||||
maxCount = this.git.config.advanced.maxQuickHistory;
|
||||
}
|
||||
|
||||
let progressCancellation = branch && BranchHistoryQuickPick.showProgress(branch);
|
||||
let progressCancellation = branch === undefined ? undefined : BranchHistoryQuickPick.showProgress(branch);
|
||||
try {
|
||||
const repoPath = (gitUri && gitUri.repoPath) || this.git.repoPath;
|
||||
if (!repoPath) return window.showWarningMessage(`Unable to show branch history`);
|
||||
if (repoPath === undefined) return window.showWarningMessage(`Unable to show branch history`);
|
||||
|
||||
if (!branch) {
|
||||
if (branch === undefined) {
|
||||
const branches = await this.git.getBranches(repoPath);
|
||||
|
||||
const pick = await BranchesQuickPick.show(branches, `Show history for branch\u2026`);
|
||||
@@ -38,7 +38,7 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand {
|
||||
}
|
||||
|
||||
branch = pick.branch.name;
|
||||
if (!branch) return undefined;
|
||||
if (branch === undefined) return undefined;
|
||||
|
||||
progressCancellation = BranchHistoryQuickPick.showProgress(branch);
|
||||
}
|
||||
@@ -48,9 +48,9 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand {
|
||||
if (!log) return window.showWarningMessage(`Unable to show branch history`);
|
||||
}
|
||||
|
||||
if (progressCancellation.token.isCancellationRequested) return undefined;
|
||||
if (progressCancellation !== undefined && progressCancellation.token.isCancellationRequested) return undefined;
|
||||
|
||||
const pick = await BranchHistoryQuickPick.show(this.git, log, gitUri, branch, progressCancellation, goBackCommand, nextPageCommand);
|
||||
const pick = await BranchHistoryQuickPick.show(this.git, log, gitUri, branch, progressCancellation!, goBackCommand, nextPageCommand);
|
||||
if (!pick) return undefined;
|
||||
|
||||
if (pick instanceof CommandQuickPickItem) {
|
||||
|
||||
@@ -21,7 +21,7 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
|
||||
const gitUri = await GitUri.fromUri(uri, this.git);
|
||||
|
||||
let repoPath = gitUri.repoPath;
|
||||
let workingFileName = path.relative(repoPath, gitUri.fsPath);
|
||||
let workingFileName = path.relative(repoPath || '', gitUri.fsPath);
|
||||
|
||||
if (!sha) {
|
||||
if (!editor) return undefined;
|
||||
@@ -48,21 +48,23 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
|
||||
try {
|
||||
if (!commit || (commit.type !== 'branch' && commit.type !== 'stash')) {
|
||||
if (repoLog) {
|
||||
commit = repoLog.commits.get(sha);
|
||||
commit = repoLog.commits.get(sha!);
|
||||
// If we can't find the commit, kill the repoLog
|
||||
if (!commit) {
|
||||
if (commit === undefined) {
|
||||
repoLog = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
if (!repoLog) {
|
||||
const log = await this.git.getLogForRepo(repoPath, sha, 2);
|
||||
if (!log) return window.showWarningMessage(`Unable to show commit details`);
|
||||
if (repoLog === undefined) {
|
||||
const log = await this.git.getLogForRepo(repoPath!, sha, 2);
|
||||
if (log === undefined) return window.showWarningMessage(`Unable to show commit details`);
|
||||
|
||||
commit = log.commits.get(sha);
|
||||
commit = log.commits.get(sha!);
|
||||
}
|
||||
}
|
||||
|
||||
if (commit === undefined) return window.showWarningMessage(`Unable to show commit details`);
|
||||
|
||||
if (!commit.workingFileName) {
|
||||
commit.workingFileName = workingFileName;
|
||||
}
|
||||
|
||||
@@ -46,24 +46,26 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand
|
||||
try {
|
||||
if (!commit || (commit.type !== 'file' && commit.type !== 'stash')) {
|
||||
if (fileLog) {
|
||||
commit = fileLog.commits.get(sha);
|
||||
commit = fileLog.commits.get(sha!);
|
||||
// If we can't find the commit, kill the fileLog
|
||||
if (!commit) {
|
||||
if (commit === undefined) {
|
||||
fileLog = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fileLog) {
|
||||
if (fileLog === undefined) {
|
||||
commit = await this.git.getLogCommit(commit ? commit.repoPath : gitUri.repoPath, gitUri.fsPath, sha, { previous: true });
|
||||
if (!commit) return window.showWarningMessage(`Unable to show commit file details`);
|
||||
if (commit === undefined) return window.showWarningMessage(`Unable to show commit file details`);
|
||||
}
|
||||
}
|
||||
|
||||
if (commit === undefined) return window.showWarningMessage(`Unable to show commit file details`);
|
||||
|
||||
// Attempt to the most recent commit -- so that we can find the real working filename if there was a rename
|
||||
commit.workingFileName = workingFileName;
|
||||
commit.workingFileName = await this.git.findWorkingFileName(commit);
|
||||
|
||||
const shortSha = sha.substring(0, 8);
|
||||
const shortSha = sha!.substring(0, 8);
|
||||
|
||||
if (!goBackCommand) {
|
||||
// Create a command to get back to the commit details
|
||||
|
||||
@@ -18,9 +18,10 @@ export class ShowQuickStashListCommand extends ActiveEditorCachedCommand {
|
||||
|
||||
try {
|
||||
const repoPath = await this.git.getRepoPathFromUri(uri);
|
||||
if (!repoPath) return window.showWarningMessage(`Unable to show stashed changes`);
|
||||
if (repoPath === undefined) return window.showWarningMessage(`Unable to show stashed changes`);
|
||||
|
||||
const stash = await this.git.getStashList(repoPath);
|
||||
if (stash === undefined) return window.showWarningMessage(`Unable to show stashed changes`);
|
||||
|
||||
// Create a command to get back to here
|
||||
const currentCommand = new CommandQuickPickItem({
|
||||
|
||||
Reference in New Issue
Block a user