mirror of
https://github.com/ckaczor/vscode-gitlens.git
synced 2026-02-17 02:51:47 -05:00
Adds ability to suppress most warning messages
This commit is contained in:
@@ -872,6 +872,11 @@
|
|||||||
"command": "gitlens.stashSave",
|
"command": "gitlens.stashSave",
|
||||||
"title": "Stash Changes",
|
"title": "Stash Changes",
|
||||||
"category": "GitLens"
|
"category": "GitLens"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.resetSuppressedWarnings",
|
||||||
|
"title": "Reset Suppressed Warnings",
|
||||||
|
"category": "GitLens"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"menus": {
|
"menus": {
|
||||||
@@ -1003,6 +1008,10 @@
|
|||||||
{
|
{
|
||||||
"command": "gitlens.stashSave",
|
"command": "gitlens.stashSave",
|
||||||
"when": "gitlens:enabled"
|
"when": "gitlens:enabled"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "gitlens.resetSuppressedWarnings",
|
||||||
|
"when": "gitlens:enabled"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"editor/context": [
|
"editor/context": [
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ export * from './commands/openCommitInRemote';
|
|||||||
export * from './commands/openFileInRemote';
|
export * from './commands/openFileInRemote';
|
||||||
export * from './commands/openInRemote';
|
export * from './commands/openInRemote';
|
||||||
export * from './commands/openRepoInRemote';
|
export * from './commands/openRepoInRemote';
|
||||||
|
export * from './commands/resetSuppressedWarnings';
|
||||||
export * from './commands/showBlameHistory';
|
export * from './commands/showBlameHistory';
|
||||||
export * from './commands/showFileBlame';
|
export * from './commands/showFileBlame';
|
||||||
export * from './commands/showFileHistory';
|
export * from './commands/showFileHistory';
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { TextEditorComparer, UriComparer } from '../comparers';
|
|||||||
import { BuiltInCommands } from '../constants';
|
import { BuiltInCommands } from '../constants';
|
||||||
import { GitService } from '../gitService';
|
import { GitService } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
import { Messages } from '../messages';
|
||||||
|
|
||||||
export interface CloseUnchangedFilesCommandArgs {
|
export interface CloseUnchangedFilesCommandArgs {
|
||||||
uris?: Uri[];
|
uris?: Uri[];
|
||||||
@@ -23,7 +24,7 @@ export class CloseUnchangedFilesCommand extends ActiveEditorCommand {
|
|||||||
try {
|
try {
|
||||||
if (args.uris === undefined) {
|
if (args.uris === undefined) {
|
||||||
const repoPath = await this.git.getRepoPathFromUri(uri);
|
const repoPath = await this.git.getRepoPathFromUri(uri);
|
||||||
if (!repoPath) return window.showWarningMessage(`Unable to close unchanged files`);
|
if (!repoPath) return Messages.showNoRepositoryWarningMessage(`Unable to close unchanged files`);
|
||||||
|
|
||||||
const status = await this.git.getStatusForRepo(repoPath);
|
const status = await this.git.getStatusForRepo(repoPath);
|
||||||
if (status === undefined) return window.showWarningMessage(`Unable to close unchanged files`);
|
if (status === undefined) return window.showWarningMessage(`Unable to close unchanged files`);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export type Commands = 'gitlens.closeUnchangedFiles' |
|
|||||||
'gitlens.openFileInRemote' |
|
'gitlens.openFileInRemote' |
|
||||||
'gitlens.openInRemote' |
|
'gitlens.openInRemote' |
|
||||||
'gitlens.openRepoInRemote' |
|
'gitlens.openRepoInRemote' |
|
||||||
|
'gitlens.resetSuppressedWarnings' |
|
||||||
'gitlens.showBlameHistory' |
|
'gitlens.showBlameHistory' |
|
||||||
'gitlens.showCommitSearch' |
|
'gitlens.showCommitSearch' |
|
||||||
'gitlens.showFileBlame' |
|
'gitlens.showFileBlame' |
|
||||||
@@ -56,6 +57,7 @@ export const Commands = {
|
|||||||
OpenFileInRemote: 'gitlens.openFileInRemote' as Commands,
|
OpenFileInRemote: 'gitlens.openFileInRemote' as Commands,
|
||||||
OpenInRemote: 'gitlens.openInRemote' as Commands,
|
OpenInRemote: 'gitlens.openInRemote' as Commands,
|
||||||
OpenRepoInRemote: 'gitlens.openRepoInRemote' as Commands,
|
OpenRepoInRemote: 'gitlens.openRepoInRemote' as Commands,
|
||||||
|
ResetSuppressedWarnings: 'gitlens.resetSuppressedWarnings' as Commands,
|
||||||
ShowBlameHistory: 'gitlens.showBlameHistory' as Commands,
|
ShowBlameHistory: 'gitlens.showBlameHistory' as Commands,
|
||||||
ShowCommitSearch: 'gitlens.showCommitSearch' as Commands,
|
ShowCommitSearch: 'gitlens.showCommitSearch' as Commands,
|
||||||
ShowFileBlame: 'gitlens.showFileBlame' as Commands,
|
ShowFileBlame: 'gitlens.showFileBlame' as Commands,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
|||||||
import { BuiltInCommands } from '../constants';
|
import { BuiltInCommands } from '../constants';
|
||||||
import { GitService } from '../gitService';
|
import { GitService } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
import { Messages } from '../messages';
|
||||||
import { BranchesQuickPick, CommandQuickPickItem } from '../quickPicks';
|
import { BranchesQuickPick, CommandQuickPickItem } from '../quickPicks';
|
||||||
|
|
||||||
export interface DiffDirectoryCommandCommandArgs {
|
export interface DiffDirectoryCommandCommandArgs {
|
||||||
@@ -31,7 +32,7 @@ export class DiffDirectoryCommand extends ActiveEditorCommand {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const repoPath = await this.git.getRepoPathFromUri(uri);
|
const repoPath = await this.git.getRepoPathFromUri(uri);
|
||||||
if (!repoPath) return window.showWarningMessage(`Unable to open directory compare`);
|
if (!repoPath) return Messages.showNoRepositoryWarningMessage(`Unable to open directory compare`);
|
||||||
|
|
||||||
if (!args.shaOrBranch1) {
|
if (!args.shaOrBranch1) {
|
||||||
const branches = await this.git.getBranches(repoPath);
|
const branches = await this.git.getBranches(repoPath);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { DiffWithPreviousCommandArgs } from './diffWithPrevious';
|
|||||||
import { DiffWithWorkingCommandArgs } from './diffWithWorking';
|
import { DiffWithWorkingCommandArgs } from './diffWithWorking';
|
||||||
import { GitCommit, GitService, GitUri } from '../gitService';
|
import { GitCommit, GitService, GitUri } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
import { Messages } from '../messages';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export interface DiffLineWithPreviousCommandArgs {
|
export interface DiffLineWithPreviousCommandArgs {
|
||||||
@@ -35,7 +36,7 @@ export class DiffLineWithPreviousCommand extends ActiveEditorCommand {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const blame = await this.git.getBlameForLine(gitUri, blameline);
|
const blame = await this.git.getBlameForLine(gitUri, blameline);
|
||||||
if (blame === undefined) return window.showWarningMessage(`Unable to open compare. File is probably not under source control`);
|
if (blame === undefined) return Messages.showFileNotUnderSourceControlWarningMessage('Unable to open compare');
|
||||||
|
|
||||||
args.commit = blame.commit;
|
args.commit = blame.commit;
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { commands, TextDocumentShowOptions, TextEditor, Uri, window } from 'vsco
|
|||||||
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
||||||
import { DiffWithWorkingCommandArgs } from './diffWithWorking';
|
import { DiffWithWorkingCommandArgs } from './diffWithWorking';
|
||||||
import { GitCommit, GitService, GitUri } from '../gitService';
|
import { GitCommit, GitService, GitUri } from '../gitService';
|
||||||
|
import { Messages } from '../messages';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
|
||||||
export interface DiffLineWithWorkingCommandArgs {
|
export interface DiffLineWithWorkingCommandArgs {
|
||||||
@@ -32,7 +33,7 @@ export class DiffLineWithWorkingCommand extends ActiveEditorCommand {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const blame = await this.git.getBlameForLine(gitUri, blameline);
|
const blame = await this.git.getBlameForLine(gitUri, blameline);
|
||||||
if (blame === undefined) return window.showWarningMessage(`Unable to open compare. File is probably not under source control`);
|
if (blame === undefined) return Messages.showFileNotUnderSourceControlWarningMessage('Unable to open compare');
|
||||||
|
|
||||||
args.commit = blame.commit;
|
args.commit = blame.commit;
|
||||||
// If the line is uncommitted, find the previous commit
|
// If the line is uncommitted, find the previous commit
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
|||||||
import { BuiltInCommands } from '../constants';
|
import { BuiltInCommands } from '../constants';
|
||||||
import { GitService, GitUri } from '../gitService';
|
import { GitService, GitUri } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
import { Messages } from '../messages';
|
||||||
import { BranchesQuickPick, CommandQuickPickItem } from '../quickPicks';
|
import { BranchesQuickPick, CommandQuickPickItem } from '../quickPicks';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
@@ -27,7 +28,7 @@ export class DiffWithBranchCommand extends ActiveEditorCommand {
|
|||||||
args.line = args.line || (editor === undefined ? 0 : editor.selection.active.line);
|
args.line = args.line || (editor === undefined ? 0 : editor.selection.active.line);
|
||||||
|
|
||||||
const gitUri = await GitUri.fromUri(uri, this.git);
|
const gitUri = await GitUri.fromUri(uri, this.git);
|
||||||
if (!gitUri.repoPath) return window.showWarningMessage(`Unable to open branch compare`);
|
if (!gitUri.repoPath) return Messages.showNoRepositoryWarningMessage(`Unable to open branch compare`);
|
||||||
|
|
||||||
const branches = await this.git.getBranches(gitUri.repoPath);
|
const branches = await this.git.getBranches(gitUri.repoPath);
|
||||||
const pick = await BranchesQuickPick.show(branches, `Compare ${path.basename(gitUri.fsPath)} to \u2026`, args.goBackCommand);
|
const pick = await BranchesQuickPick.show(branches, `Compare ${path.basename(gitUri.fsPath)} to \u2026`, args.goBackCommand);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
|||||||
import { BuiltInCommands } from '../constants';
|
import { BuiltInCommands } from '../constants';
|
||||||
import { GitLogCommit, GitService, GitUri } from '../gitService';
|
import { GitLogCommit, GitService, GitUri } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
import { Messages } from '../messages';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export interface DiffWithNextCommandArgs {
|
export interface DiffWithNextCommandArgs {
|
||||||
@@ -38,7 +39,7 @@ export class DiffWithNextCommand extends ActiveEditorCommand {
|
|||||||
const sha = args.commit === undefined ? gitUri.sha : args.commit.sha;
|
const sha = args.commit === undefined ? gitUri.sha : args.commit.sha;
|
||||||
|
|
||||||
const log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, undefined, sha !== undefined ? undefined : 2, args.range!);
|
const log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, undefined, sha !== undefined ? undefined : 2, args.range!);
|
||||||
if (log === undefined) return window.showWarningMessage(`Unable to open compare. File is probably not under source control`);
|
if (log === undefined) return Messages.showFileNotUnderSourceControlWarningMessage('Unable to open compare');
|
||||||
|
|
||||||
args.commit = (sha && log.commits.get(sha)) || Iterables.first(log.commits.values());
|
args.commit = (sha && log.commits.get(sha)) || Iterables.first(log.commits.values());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { BuiltInCommands } from '../constants';
|
|||||||
import { DiffWithWorkingCommandArgs } from './diffWithWorking';
|
import { DiffWithWorkingCommandArgs } from './diffWithWorking';
|
||||||
import { GitCommit, GitService, GitUri } from '../gitService';
|
import { GitCommit, GitService, GitUri } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import * as moment from 'moment';
|
import { Messages } from '../messages';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export interface DiffWithPreviousCommandArgs {
|
export interface DiffWithPreviousCommandArgs {
|
||||||
@@ -35,7 +35,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
|
|||||||
const sha = args.commit === undefined ? gitUri.sha : args.commit.sha;
|
const sha = args.commit === undefined ? gitUri.sha : args.commit.sha;
|
||||||
|
|
||||||
const log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, undefined, sha !== undefined ? undefined : 2, args.range!);
|
const log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, undefined, sha !== undefined ? undefined : 2, args.range!);
|
||||||
if (log === undefined) return window.showWarningMessage(`Unable to open compare. File is probably not under source control`);
|
if (log === undefined) return Messages.showFileNotUnderSourceControlWarningMessage('Unable to open compare');
|
||||||
|
|
||||||
args.commit = (sha && log.commits.get(sha)) || Iterables.first(log.commits.values());
|
args.commit = (sha && log.commits.get(sha)) || Iterables.first(log.commits.values());
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ export class DiffWithPreviousCommand extends ActiveEditorCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.commit.previousSha === undefined) return window.showInformationMessage(`Commit ${args.commit.shortSha} (${args.commit.author}, ${moment(args.commit.date).fromNow()}) has no previous commit`);
|
if (args.commit.previousSha === undefined) return Messages.showCommitHasNoPreviousCommitWarningMessage(args.commit);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const [rhs, lhs] = await Promise.all([
|
const [rhs, lhs] = await Promise.all([
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
|||||||
import { BuiltInCommands } from '../constants';
|
import { BuiltInCommands } from '../constants';
|
||||||
import { GitCommit, GitService, GitUri } from '../gitService';
|
import { GitCommit, GitService, GitUri } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
import { Messages } from '../messages';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export interface DiffWithWorkingCommandArgs {
|
export interface DiffWithWorkingCommandArgs {
|
||||||
@@ -31,7 +32,7 @@ export class DiffWithWorkingCommand extends ActiveEditorCommand {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
args.commit = await this.git.getLogCommit(gitUri.repoPath, gitUri.fsPath, gitUri.sha, { firstIfMissing: true });
|
args.commit = await this.git.getLogCommit(gitUri.repoPath, gitUri.fsPath, gitUri.sha, { firstIfMissing: true });
|
||||||
if (args.commit === undefined) return window.showWarningMessage(`Unable to open compare. File is probably not under source control`);
|
if (args.commit === undefined) return Messages.showFileNotUnderSourceControlWarningMessage('Unable to open compare');
|
||||||
}
|
}
|
||||||
catch (ex) {
|
catch (ex) {
|
||||||
Logger.error(ex, 'DiffWithWorkingCommand', `getLogCommit(${gitUri.repoPath}, ${gitUri.fsPath}, ${gitUri.sha})`);
|
Logger.error(ex, 'DiffWithWorkingCommand', `getLogCommit(${gitUri.repoPath}, ${gitUri.fsPath}, ${gitUri.sha})`);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { TextDocumentShowOptions, TextEditor, Uri, window } from 'vscode';
|
|||||||
import { ActiveEditorCommand, Commands, getCommandUri, openEditor } from './common';
|
import { ActiveEditorCommand, Commands, getCommandUri, openEditor } from './common';
|
||||||
import { GitService } from '../gitService';
|
import { GitService } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
import { Messages } from '../messages';
|
||||||
|
|
||||||
export interface OpenChangedFilesCommandArgs {
|
export interface OpenChangedFilesCommandArgs {
|
||||||
uris?: Uri[];
|
uris?: Uri[];
|
||||||
@@ -20,7 +21,7 @@ export class OpenChangedFilesCommand extends ActiveEditorCommand {
|
|||||||
try {
|
try {
|
||||||
if (args.uris === undefined) {
|
if (args.uris === undefined) {
|
||||||
const repoPath = await this.git.getRepoPathFromUri(uri);
|
const repoPath = await this.git.getRepoPathFromUri(uri);
|
||||||
if (!repoPath) return window.showWarningMessage(`Unable to open changed files`);
|
if (!repoPath) return Messages.showNoRepositoryWarningMessage(`Unable to open changed files`);
|
||||||
|
|
||||||
const status = await this.git.getStatusForRepo(repoPath);
|
const status = await this.git.getStatusForRepo(repoPath);
|
||||||
if (status === undefined) return window.showWarningMessage(`Unable to open changed files`);
|
if (status === undefined) return window.showWarningMessage(`Unable to open changed files`);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { commands, TextEditor, TextEditorEdit, Uri, window } from 'vscode';
|
|||||||
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
import { ActiveEditorCommand, Commands, getCommandUri } from './common';
|
||||||
import { GitCommit, GitService, GitUri } from '../gitService';
|
import { GitCommit, GitService, GitUri } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
import { Messages } from '../messages';
|
||||||
import { OpenInRemoteCommandArgs } from './openInRemote';
|
import { OpenInRemoteCommandArgs } from './openInRemote';
|
||||||
|
|
||||||
export class OpenCommitInRemoteCommand extends ActiveEditorCommand {
|
export class OpenCommitInRemoteCommand extends ActiveEditorCommand {
|
||||||
@@ -27,7 +28,7 @@ export class OpenCommitInRemoteCommand extends ActiveEditorCommand {
|
|||||||
if (blameline < 0) return undefined;
|
if (blameline < 0) return undefined;
|
||||||
|
|
||||||
const blame = await this.git.getBlameForLine(gitUri, blameline);
|
const blame = await this.git.getBlameForLine(gitUri, blameline);
|
||||||
if (blame === undefined) return window.showWarningMessage(`Unable to open commit in remote provider. File is probably not under source control`);
|
if (blame === undefined) return Messages.showFileNotUnderSourceControlWarningMessage('Unable to open commit in remote provider');
|
||||||
|
|
||||||
let commit = blame.commit;
|
let commit = blame.commit;
|
||||||
// If the line is uncommitted, find the previous commit
|
// If the line is uncommitted, find the previous commit
|
||||||
|
|||||||
18
src/commands/resetSuppressedWarnings.ts
Normal file
18
src/commands/resetSuppressedWarnings.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
'use strict';
|
||||||
|
import { Objects } from '../system';
|
||||||
|
import { ExtensionContext } from 'vscode';
|
||||||
|
import { Command, Commands } from './common';
|
||||||
|
import { SuppressedKeys } from '../messages';
|
||||||
|
|
||||||
|
export class ResetSuppressedWarningsCommand extends Command {
|
||||||
|
|
||||||
|
constructor(private context: ExtensionContext) {
|
||||||
|
super(Commands.ResetSuppressedWarnings);
|
||||||
|
}
|
||||||
|
|
||||||
|
async execute() {
|
||||||
|
for (const key of Objects.values<string>(SuppressedKeys)) {
|
||||||
|
await this.context.globalState.update(key, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import { commands, Position, Range, TextEditor, TextEditorEdit, Uri, window } fr
|
|||||||
import { Commands, EditorCommand, getCommandUri } from './common';
|
import { Commands, EditorCommand, getCommandUri } from './common';
|
||||||
import { BuiltInCommands } from '../constants';
|
import { BuiltInCommands } from '../constants';
|
||||||
import { GitService, GitUri } from '../gitService';
|
import { GitService, GitUri } from '../gitService';
|
||||||
|
import { Messages } from '../messages';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
|
||||||
export interface ShowBlameHistoryCommandArgs {
|
export interface ShowBlameHistoryCommandArgs {
|
||||||
@@ -32,7 +33,7 @@ export class ShowBlameHistoryCommand extends EditorCommand {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const locations = await this.git.getBlameLocations(gitUri, args.range, args.sha, args.line);
|
const locations = await this.git.getBlameLocations(gitUri, args.range, args.sha, args.line);
|
||||||
if (locations === undefined) return window.showWarningMessage(`Unable to show blame history. File is probably not under source control`);
|
if (locations === undefined) return Messages.showFileNotUnderSourceControlWarningMessage('Unable to show blame history');
|
||||||
|
|
||||||
return commands.executeCommand(BuiltInCommands.ShowReferences, uri, args.position, locations);
|
return commands.executeCommand(BuiltInCommands.ShowReferences, uri, args.position, locations);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { commands, InputBoxOptions, TextEditor, Uri, window } from 'vscode';
|
|||||||
import { ActiveEditorCachedCommand, Commands, getCommandUri } from './common';
|
import { ActiveEditorCachedCommand, Commands, getCommandUri } from './common';
|
||||||
import { GitRepoSearchBy, GitService, GitUri } from '../gitService';
|
import { GitRepoSearchBy, GitService, GitUri } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
import { Messages } from '../messages';
|
||||||
import { CommandQuickPickItem, CommitsQuickPick } from '../quickPicks';
|
import { CommandQuickPickItem, CommitsQuickPick } from '../quickPicks';
|
||||||
import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails';
|
import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails';
|
||||||
import { paste } from 'copy-paste';
|
import { paste } from 'copy-paste';
|
||||||
@@ -33,7 +34,7 @@ export class ShowCommitSearchCommand extends ActiveEditorCachedCommand {
|
|||||||
const gitUri = uri === undefined ? undefined : await GitUri.fromUri(uri, this.git);
|
const gitUri = uri === undefined ? undefined : await GitUri.fromUri(uri, this.git);
|
||||||
|
|
||||||
const repoPath = gitUri === undefined ? this.git.repoPath : gitUri.repoPath;
|
const repoPath = gitUri === undefined ? this.git.repoPath : gitUri.repoPath;
|
||||||
if (!repoPath) return window.showWarningMessage(`Unable to show commit search`);
|
if (!repoPath) return Messages.showNoRepositoryWarningMessage(`Unable to show commit search`);
|
||||||
|
|
||||||
if (!args.search || args.searchBy == null) {
|
if (!args.search || args.searchBy == null) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { commands, Position, Range, TextEditor, TextEditorEdit, Uri, window } fr
|
|||||||
import { Commands, EditorCommand, getCommandUri } from './common';
|
import { Commands, EditorCommand, getCommandUri } from './common';
|
||||||
import { BuiltInCommands } from '../constants';
|
import { BuiltInCommands } from '../constants';
|
||||||
import { GitService, GitUri } from '../gitService';
|
import { GitService, GitUri } from '../gitService';
|
||||||
|
import { Messages } from '../messages';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
|
||||||
export interface ShowFileHistoryCommandArgs {
|
export interface ShowFileHistoryCommandArgs {
|
||||||
@@ -30,7 +31,7 @@ export class ShowFileHistoryCommand extends EditorCommand {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const locations = await this.git.getLogLocations(gitUri, args.sha, args.line);
|
const locations = await this.git.getLogLocations(gitUri, args.sha, args.line);
|
||||||
if (locations === undefined) return window.showWarningMessage(`Unable to show file history. File is probably not under source control`);
|
if (locations === undefined) return Messages.showFileNotUnderSourceControlWarningMessage('Unable to show file history');
|
||||||
|
|
||||||
return commands.executeCommand(BuiltInCommands.ShowReferences, uri, args.position, locations);
|
return commands.executeCommand(BuiltInCommands.ShowReferences, uri, args.position, locations);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { commands, TextEditor, Uri, window } from 'vscode';
|
|||||||
import { ActiveEditorCachedCommand, Commands, getCommandUri } from './common';
|
import { ActiveEditorCachedCommand, Commands, getCommandUri } from './common';
|
||||||
import { GitService, GitUri, IGitLog } from '../gitService';
|
import { GitService, GitUri, IGitLog } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
import { Messages } from '../messages';
|
||||||
import { BranchesQuickPick, BranchHistoryQuickPick, CommandQuickPickItem } from '../quickPicks';
|
import { BranchesQuickPick, BranchHistoryQuickPick, CommandQuickPickItem } from '../quickPicks';
|
||||||
import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails';
|
import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails';
|
||||||
|
|
||||||
@@ -33,7 +34,7 @@ export class ShowQuickBranchHistoryCommand extends ActiveEditorCachedCommand {
|
|||||||
let progressCancellation = args.branch === undefined ? undefined : BranchHistoryQuickPick.showProgress(args.branch);
|
let progressCancellation = args.branch === undefined ? undefined : BranchHistoryQuickPick.showProgress(args.branch);
|
||||||
try {
|
try {
|
||||||
const repoPath = gitUri === undefined ? this.git.repoPath : gitUri.repoPath;
|
const repoPath = gitUri === undefined ? this.git.repoPath : gitUri.repoPath;
|
||||||
if (!repoPath) return window.showWarningMessage(`Unable to show branch history`);
|
if (!repoPath) return Messages.showNoRepositoryWarningMessage(`Unable to show branch history`);
|
||||||
|
|
||||||
if (args.branch === undefined) {
|
if (args.branch === undefined) {
|
||||||
const branches = await this.git.getBranches(repoPath);
|
const branches = await this.git.getBranches(repoPath);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { GitCommit, GitLogCommit, GitService, GitUri, IGitLog } from '../gitServ
|
|||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { CommandQuickPickItem, CommitDetailsQuickPick, CommitWithFileStatusQuickPickItem } from '../quickPicks';
|
import { CommandQuickPickItem, CommitDetailsQuickPick, CommitWithFileStatusQuickPickItem } from '../quickPicks';
|
||||||
import { ShowQuickCommitFileDetailsCommandArgs } from './showQuickCommitFileDetails';
|
import { ShowQuickCommitFileDetailsCommandArgs } from './showQuickCommitFileDetails';
|
||||||
|
import { Messages } from '../messages';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export interface ShowQuickCommitDetailsCommandArgs {
|
export interface ShowQuickCommitDetailsCommandArgs {
|
||||||
@@ -38,9 +39,12 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const blame = await this.git.getBlameForLine(gitUri, blameline);
|
const blame = await this.git.getBlameForLine(gitUri, blameline);
|
||||||
if (blame === undefined) return window.showWarningMessage(`Unable to show commit details. File is probably not under source control`);
|
if (blame === undefined) return Messages.showFileNotUnderSourceControlWarningMessage('Unable to show commit details');
|
||||||
|
|
||||||
args.sha = blame.commit.isUncommitted ? blame.commit.previousSha : blame.commit.sha;
|
// Because the previous sha of an uncommitted file isn't trust worthy we just have to kick out
|
||||||
|
if (blame.commit.isUncommitted) return Messages.showLineUncommittedWarningMessage('Unable to show commit details');
|
||||||
|
|
||||||
|
args.sha = blame.commit.sha;
|
||||||
repoPath = blame.commit.repoPath;
|
repoPath = blame.commit.repoPath;
|
||||||
workingFileName = blame.commit.fileName;
|
workingFileName = blame.commit.fileName;
|
||||||
|
|
||||||
@@ -64,13 +68,13 @@ export class ShowQuickCommitDetailsCommand extends ActiveEditorCachedCommand {
|
|||||||
|
|
||||||
if (args.repoLog === undefined) {
|
if (args.repoLog === undefined) {
|
||||||
const log = await this.git.getLogForRepo(repoPath!, args.sha, 2);
|
const log = await this.git.getLogForRepo(repoPath!, args.sha, 2);
|
||||||
if (log === undefined) return window.showWarningMessage(`Unable to show commit details`);
|
if (log === undefined) return Messages.showCommitNotFoundWarningMessage(`Unable to show commit details`);
|
||||||
|
|
||||||
args.commit = log.commits.get(args.sha!);
|
args.commit = log.commits.get(args.sha!);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.commit === undefined) return window.showWarningMessage(`Unable to show commit details`);
|
if (args.commit === undefined) return Messages.showCommitNotFoundWarningMessage(`Unable to show commit details`);
|
||||||
|
|
||||||
if (args.commit.workingFileName === undefined) {
|
if (args.commit.workingFileName === undefined) {
|
||||||
args.commit.workingFileName = workingFileName;
|
args.commit.workingFileName = workingFileName;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { GitCommit, GitLogCommit, GitService, GitUri, IGitLog } from '../gitServ
|
|||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { CommandQuickPickItem, CommitFileDetailsQuickPick } from '../quickPicks';
|
import { CommandQuickPickItem, CommitFileDetailsQuickPick } from '../quickPicks';
|
||||||
import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails';
|
import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails';
|
||||||
|
import { Messages } from '../messages';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export interface ShowQuickCommitFileDetailsCommandArgs {
|
export interface ShowQuickCommitFileDetailsCommandArgs {
|
||||||
@@ -37,9 +38,12 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const blame = await this.git.getBlameForLine(gitUri, blameline);
|
const blame = await this.git.getBlameForLine(gitUri, blameline);
|
||||||
if (blame === undefined) return window.showWarningMessage(`Unable to show commit file details. File is probably not under source control`);
|
if (blame === undefined) return Messages.showFileNotUnderSourceControlWarningMessage('Unable to show commit file details');
|
||||||
|
|
||||||
args.sha = blame.commit.isUncommitted ? blame.commit.previousSha : blame.commit.sha;
|
// Because the previous sha of an uncommitted file isn't trust worthy we just have to kick out
|
||||||
|
if (blame.commit.isUncommitted) return Messages.showLineUncommittedWarningMessage('Unable to show commit file details');
|
||||||
|
|
||||||
|
args.sha = blame.commit.sha;
|
||||||
|
|
||||||
args.commit = blame.commit;
|
args.commit = blame.commit;
|
||||||
workingFileName = path.relative(args.commit.repoPath, gitUri.fsPath);
|
workingFileName = path.relative(args.commit.repoPath, gitUri.fsPath);
|
||||||
@@ -65,12 +69,12 @@ export class ShowQuickCommitFileDetailsCommand extends ActiveEditorCachedCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args.fileLog === undefined) {
|
if (args.fileLog === undefined) {
|
||||||
args.commit = await this.git.getLogCommit(args.commit ? args.commit.repoPath : gitUri.repoPath, gitUri.fsPath, args.sha, { previous: true });
|
args.commit = await this.git.getLogCommit(args.commit === undefined ? gitUri.repoPath : args.commit.repoPath, gitUri.fsPath, args.sha, { previous: true });
|
||||||
if (args.commit === undefined) return window.showWarningMessage(`Unable to show commit file details`);
|
if (args.commit === undefined) return Messages.showCommitNotFoundWarningMessage(`Unable to show commit file details`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.commit === undefined) return window.showWarningMessage(`Unable to show commit file details`);
|
if (args.commit === undefined) return Messages.showCommitNotFoundWarningMessage(`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
|
// Attempt to the most recent commit -- so that we can find the real working filename if there was a rename
|
||||||
args.commit.workingFileName = workingFileName;
|
args.commit.workingFileName = workingFileName;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { ActiveEditorCachedCommand, Commands, getCommandUri } from './common';
|
|||||||
import { ShowQuickBranchHistoryCommandArgs } from './showQuickBranchHistory';
|
import { ShowQuickBranchHistoryCommandArgs } from './showQuickBranchHistory';
|
||||||
import { GitService } from '../gitService';
|
import { GitService } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
import { Messages } from '../messages';
|
||||||
import { CommandQuickPickItem } from '../quickPicks';
|
import { CommandQuickPickItem } from '../quickPicks';
|
||||||
|
|
||||||
export interface ShowQuickCurrentBranchHistoryCommandArgs {
|
export interface ShowQuickCurrentBranchHistoryCommandArgs {
|
||||||
@@ -21,7 +22,7 @@ export class ShowQuickCurrentBranchHistoryCommand extends ActiveEditorCachedComm
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const repoPath = await this.git.getRepoPathFromUri(uri);
|
const repoPath = await this.git.getRepoPathFromUri(uri);
|
||||||
if (!repoPath) return window.showWarningMessage(`Unable to show branch history`);
|
if (!repoPath) return Messages.showNoRepositoryWarningMessage(`Unable to show branch history`);
|
||||||
|
|
||||||
const branch = await this.git.getBranch(repoPath);
|
const branch = await this.git.getBranch(repoPath);
|
||||||
if (branch === undefined) return undefined;
|
if (branch === undefined) return undefined;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { GitService, GitUri, IGitLog } from '../gitService';
|
|||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
import { CommandQuickPickItem, FileHistoryQuickPick } from '../quickPicks';
|
import { CommandQuickPickItem, FileHistoryQuickPick } from '../quickPicks';
|
||||||
import { ShowQuickCommitFileDetailsCommandArgs } from './showQuickCommitFileDetails';
|
import { ShowQuickCommitFileDetailsCommandArgs } from './showQuickCommitFileDetails';
|
||||||
|
import { Messages } from '../messages';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
export interface ShowQuickFileHistoryCommandArgs {
|
export interface ShowQuickFileHistoryCommandArgs {
|
||||||
@@ -36,7 +37,7 @@ export class ShowQuickFileHistoryCommand extends ActiveEditorCachedCommand {
|
|||||||
try {
|
try {
|
||||||
if (args.log === undefined) {
|
if (args.log === undefined) {
|
||||||
args.log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, gitUri.sha, args.maxCount, args.range);
|
args.log = await this.git.getLogForFile(gitUri.repoPath, gitUri.fsPath, gitUri.sha, args.maxCount, args.range);
|
||||||
if (args.log === undefined) return window.showWarningMessage(`Unable to show file history. File is probably not under source control`);
|
if (args.log === undefined) return Messages.showFileNotUnderSourceControlWarningMessage('Unable to show file history');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (progressCancellation.token.isCancellationRequested) return undefined;
|
if (progressCancellation.token.isCancellationRequested) return undefined;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { TextEditor, Uri, window } from 'vscode';
|
|||||||
import { ActiveEditorCachedCommand, Commands, getCommandUri } from './common';
|
import { ActiveEditorCachedCommand, Commands, getCommandUri } from './common';
|
||||||
import { GitService } from '../gitService';
|
import { GitService } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
import { Messages } from '../messages';
|
||||||
import { CommandQuickPickItem, RepoStatusQuickPick } from '../quickPicks';
|
import { CommandQuickPickItem, RepoStatusQuickPick } from '../quickPicks';
|
||||||
|
|
||||||
export interface ShowQuickRepoStatusCommandArgs {
|
export interface ShowQuickRepoStatusCommandArgs {
|
||||||
@@ -20,7 +21,7 @@ export class ShowQuickRepoStatusCommand extends ActiveEditorCachedCommand {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const repoPath = await this.git.getRepoPathFromUri(uri);
|
const repoPath = await this.git.getRepoPathFromUri(uri);
|
||||||
if (!repoPath) return window.showWarningMessage(`Unable to show repository status`);
|
if (!repoPath) return Messages.showNoRepositoryWarningMessage(`Unable to show repository status`);
|
||||||
|
|
||||||
const status = await this.git.getStatusForRepo(repoPath);
|
const status = await this.git.getStatusForRepo(repoPath);
|
||||||
if (status === undefined) return window.showWarningMessage(`Unable to show repository status`);
|
if (status === undefined) return window.showWarningMessage(`Unable to show repository status`);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import { commands, TextEditor, Uri, window } from 'vscode';
|
|||||||
import { ActiveEditorCachedCommand, Commands, getCommandUri } from './common';
|
import { ActiveEditorCachedCommand, Commands, getCommandUri } from './common';
|
||||||
import { GitService, GitUri } from '../gitService';
|
import { GitService, GitUri } from '../gitService';
|
||||||
import { Logger } from '../logger';
|
import { Logger } from '../logger';
|
||||||
|
import { Messages } from '../messages';
|
||||||
import { CommandQuickPickItem, StashListQuickPick } from '../quickPicks';
|
import { CommandQuickPickItem, StashListQuickPick } from '../quickPicks';
|
||||||
import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails';
|
import { ShowQuickCommitDetailsCommandArgs } from './showQuickCommitDetails';
|
||||||
|
|
||||||
@@ -21,7 +22,7 @@ export class ShowQuickStashListCommand extends ActiveEditorCachedCommand {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const repoPath = await this.git.getRepoPathFromUri(uri);
|
const repoPath = await this.git.getRepoPathFromUri(uri);
|
||||||
if (!repoPath) return window.showWarningMessage(`Unable to show stashed changes`);
|
if (!repoPath) return Messages.showNoRepositoryWarningMessage(`Unable to show stashed changes`);
|
||||||
|
|
||||||
const stash = await this.git.getStashList(repoPath);
|
const stash = await this.git.getStashList(repoPath);
|
||||||
if (stash === undefined) return window.showWarningMessage(`Unable to show stashed changes`);
|
if (stash === undefined) return window.showWarningMessage(`Unable to show stashed changes`);
|
||||||
|
|||||||
@@ -45,10 +45,7 @@ export const DocumentSchemes = {
|
|||||||
GitLensGit: 'gitlens-git' as DocumentSchemes
|
GitLensGit: 'gitlens-git' as DocumentSchemes
|
||||||
};
|
};
|
||||||
|
|
||||||
export type WorkspaceState = 'repoPath' | 'suppressGitVersionWarning' | 'suppressUpdateNotice' | 'suppressWelcomeNotice';
|
export type WorkspaceState = 'gitlensVersion';
|
||||||
export const WorkspaceState = {
|
export const WorkspaceState = {
|
||||||
GitLensVersion: 'gitlensVersion' as WorkspaceState,
|
GitLensVersion: 'gitlensVersion' as WorkspaceState
|
||||||
SuppressGitVersionWarning: 'suppressGitVersionWarning' as WorkspaceState,
|
|
||||||
SuppressUpdateNotice: 'suppressUpdateNotice' as WorkspaceState,
|
|
||||||
SuppressWelcomeNotice: 'suppressWelcomeNotice' as WorkspaceState
|
|
||||||
};
|
};
|
||||||
@@ -1,12 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
// import { Objects } from './system';
|
// import { Objects } from './system';
|
||||||
import { commands, ExtensionContext, extensions, languages, Uri, window, workspace } from 'vscode';
|
import { ExtensionContext, extensions, languages, window, workspace } from 'vscode';
|
||||||
import { AnnotationController } from './annotations/annotationController';
|
import { AnnotationController } from './annotations/annotationController';
|
||||||
import { CommandContext, setCommandContext } from './commands';
|
import { CommandContext, setCommandContext } from './commands';
|
||||||
import { CloseUnchangedFilesCommand, OpenChangedFilesCommand } from './commands';
|
import { CloseUnchangedFilesCommand, OpenChangedFilesCommand } from './commands';
|
||||||
import { OpenBranchInRemoteCommand, OpenCommitInRemoteCommand, OpenFileInRemoteCommand, OpenInRemoteCommand, OpenRepoInRemoteCommand } from './commands';
|
import { OpenBranchInRemoteCommand, OpenCommitInRemoteCommand, OpenFileInRemoteCommand, OpenInRemoteCommand, OpenRepoInRemoteCommand } from './commands';
|
||||||
import { CopyMessageToClipboardCommand, CopyShaToClipboardCommand } from './commands';
|
import { CopyMessageToClipboardCommand, CopyShaToClipboardCommand } from './commands';
|
||||||
import { DiffDirectoryCommand, DiffLineWithPreviousCommand, DiffLineWithWorkingCommand, DiffWithBranchCommand, DiffWithNextCommand, DiffWithPreviousCommand, DiffWithWorkingCommand} from './commands';
|
import { DiffDirectoryCommand, DiffLineWithPreviousCommand, DiffLineWithWorkingCommand, DiffWithBranchCommand, DiffWithNextCommand, DiffWithPreviousCommand, DiffWithWorkingCommand} from './commands';
|
||||||
|
import { ResetSuppressedWarningsCommand } from './commands';
|
||||||
import { ShowFileBlameCommand, ShowLineBlameCommand, ToggleFileBlameCommand, ToggleLineBlameCommand } from './commands';
|
import { ShowFileBlameCommand, ShowLineBlameCommand, ToggleFileBlameCommand, ToggleLineBlameCommand } from './commands';
|
||||||
import { ShowBlameHistoryCommand, ShowFileHistoryCommand } from './commands';
|
import { ShowBlameHistoryCommand, ShowFileHistoryCommand } from './commands';
|
||||||
import { ShowLastQuickPickCommand } from './commands';
|
import { ShowLastQuickPickCommand } from './commands';
|
||||||
@@ -17,17 +18,19 @@ import { StashApplyCommand, StashDeleteCommand, StashSaveCommand } from './comma
|
|||||||
import { ToggleCodeLensCommand } from './commands';
|
import { ToggleCodeLensCommand } from './commands';
|
||||||
import { Keyboard } from './commands';
|
import { Keyboard } from './commands';
|
||||||
import { BlameLineHighlightLocations, CodeLensLocations, IConfig, LineAnnotationType } from './configuration';
|
import { BlameLineHighlightLocations, CodeLensLocations, IConfig, LineAnnotationType } from './configuration';
|
||||||
import { ApplicationInsightsKey, BuiltInCommands, ExtensionKey, QualifiedExtensionId, WorkspaceState } from './constants';
|
import { ApplicationInsightsKey, ExtensionKey, QualifiedExtensionId, WorkspaceState } from './constants';
|
||||||
import { CurrentLineController } from './currentLineController';
|
import { CurrentLineController } from './currentLineController';
|
||||||
import { GitContentProvider } from './gitContentProvider';
|
import { GitContentProvider } from './gitContentProvider';
|
||||||
import { GitContextTracker, GitService } from './gitService';
|
import { GitContextTracker, GitService } from './gitService';
|
||||||
import { GitRevisionCodeLensProvider } from './gitRevisionCodeLensProvider';
|
import { GitRevisionCodeLensProvider } from './gitRevisionCodeLensProvider';
|
||||||
import { Logger } from './logger';
|
import { Logger } from './logger';
|
||||||
|
import { Messages, SuppressedKeys } from './messages';
|
||||||
import { Telemetry } from './telemetry';
|
import { Telemetry } from './telemetry';
|
||||||
|
|
||||||
// this method is called when your extension is activated
|
// this method is called when your extension is activated
|
||||||
export async function activate(context: ExtensionContext) {
|
export async function activate(context: ExtensionContext) {
|
||||||
Logger.configure(context);
|
Logger.configure(context);
|
||||||
|
Messages.configure(context);
|
||||||
Telemetry.configure(ApplicationInsightsKey);
|
Telemetry.configure(ApplicationInsightsKey);
|
||||||
|
|
||||||
const gitlens = extensions.getExtension(QualifiedExtensionId)!;
|
const gitlens = extensions.getExtension(QualifiedExtensionId)!;
|
||||||
@@ -105,6 +108,7 @@ export async function activate(context: ExtensionContext) {
|
|||||||
context.subscriptions.push(new ShowLineBlameCommand(currentLineController));
|
context.subscriptions.push(new ShowLineBlameCommand(currentLineController));
|
||||||
context.subscriptions.push(new ToggleFileBlameCommand(annotationController));
|
context.subscriptions.push(new ToggleFileBlameCommand(annotationController));
|
||||||
context.subscriptions.push(new ToggleLineBlameCommand(currentLineController));
|
context.subscriptions.push(new ToggleLineBlameCommand(currentLineController));
|
||||||
|
context.subscriptions.push(new ResetSuppressedWarningsCommand(context));
|
||||||
context.subscriptions.push(new ShowBlameHistoryCommand(git));
|
context.subscriptions.push(new ShowBlameHistoryCommand(git));
|
||||||
context.subscriptions.push(new ShowFileHistoryCommand(git));
|
context.subscriptions.push(new ShowFileHistoryCommand(git));
|
||||||
context.subscriptions.push(new ShowLastQuickPickCommand());
|
context.subscriptions.push(new ShowLastQuickPickCommand());
|
||||||
@@ -253,49 +257,25 @@ async function migrateSettings(context: ExtensionContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function notifyOnNewGitLensVersion(context: ExtensionContext, version: string) {
|
async function notifyOnNewGitLensVersion(context: ExtensionContext, version: string) {
|
||||||
if (context.globalState.get(WorkspaceState.SuppressUpdateNotice, false)) return;
|
if (context.globalState.get(SuppressedKeys.UpdateNotice, false)) return;
|
||||||
|
|
||||||
const previousVersion = context.globalState.get<string>(WorkspaceState.GitLensVersion);
|
const previousVersion = context.globalState.get<string>(WorkspaceState.GitLensVersion);
|
||||||
|
|
||||||
if (!context.globalState.get(WorkspaceState.SuppressWelcomeNotice, false)) {
|
if (previousVersion === undefined) {
|
||||||
await context.globalState.update(WorkspaceState.SuppressWelcomeNotice, true);
|
await Messages.showWelcomeMessage();
|
||||||
|
return;
|
||||||
if (previousVersion === undefined) {
|
|
||||||
const result = await window.showInformationMessage(`Thank you for choosing GitLens! GitLens is powerful, feature rich, and highly configurable, so please be sure to view the docs and tailor it to suit your needs.`, 'View Docs');
|
|
||||||
if (result === 'View Docs') {
|
|
||||||
// TODO: Reset before release
|
|
||||||
// commands.executeCommand(BuiltInCommands.Open, Uri.parse('https://marketplace.visualstudio.com/items/eamodio.gitlens'));
|
|
||||||
commands.executeCommand(BuiltInCommands.Open, Uri.parse('https://github.com/eamodio/vscode-gitlens/blob/develop/README.md'));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (previousVersion) {
|
const [major, minor] = version.split('.');
|
||||||
const [major, minor] = version.split('.');
|
const [prevMajor, prevMinor] = previousVersion.split('.');
|
||||||
const [prevMajor, prevMinor] = previousVersion.split('.');
|
if (major === prevMajor && minor === prevMinor) return;
|
||||||
if (major === prevMajor && minor === prevMinor) return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = await window.showInformationMessage(`GitLens has been updated to v${version}`, 'View Release Notes', `Don't Show Again`);
|
await Messages.showUpdateMessage(version);
|
||||||
if (result === 'View Release Notes') {
|
|
||||||
// TODO: Reset before release
|
|
||||||
// commands.executeCommand(BuiltInCommands.Open, Uri.parse('https://marketplace.visualstudio.com/items/eamodio.gitlens/changelog'));
|
|
||||||
commands.executeCommand(BuiltInCommands.Open, Uri.parse('https://github.com/eamodio/vscode-gitlens/blob/develop/CHANGELOG.md'));
|
|
||||||
}
|
|
||||||
else if (result === `Don't Show Again`) {
|
|
||||||
context.globalState.update(WorkspaceState.SuppressUpdateNotice, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function notifyOnUnsupportedGitVersion(context: ExtensionContext, version: string) {
|
async function notifyOnUnsupportedGitVersion(context: ExtensionContext, version: string) {
|
||||||
if (context.globalState.get(WorkspaceState.SuppressGitVersionWarning, false)) return;
|
if (GitService.validateGitVersion(2, 2)) return;
|
||||||
|
|
||||||
// If git is less than v2.2.0
|
// If git is less than v2.2.0
|
||||||
if (!GitService.validateGitVersion(2, 2)) {
|
await Messages.showUnsupportedGitVersionErrorMessage(version);
|
||||||
const result = await window.showErrorMessage(`GitLens requires a newer version of Git (>= 2.2.0) than is currently installed (${version}). Please install a more recent version of Git.`, `Don't Show Again`);
|
|
||||||
if (result === `Don't Show Again`) {
|
|
||||||
context.globalState.update(WorkspaceState.SuppressGitVersionWarning, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
103
src/messages.ts
Normal file
103
src/messages.ts
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
'use strict';
|
||||||
|
import { commands, ExtensionContext, Uri, window } from 'vscode';
|
||||||
|
import { BuiltInCommands } from './constants';
|
||||||
|
import { GitCommit } from './gitService';
|
||||||
|
import * as moment from 'moment';
|
||||||
|
|
||||||
|
export type SuppressedKeys = 'suppressCommitHasNoPreviousCommitWarning' |
|
||||||
|
'suppressCommitNotFoundWarning' |
|
||||||
|
'suppressFileNotUnderSourceControlWarning' |
|
||||||
|
'suppressGitVersionWarning' |
|
||||||
|
'suppressLineUncommittedWarning' |
|
||||||
|
'suppressNoRepositoryWarning' |
|
||||||
|
'suppressUpdateNotice';
|
||||||
|
export const SuppressedKeys = {
|
||||||
|
CommitHasNoPreviousCommitWarning: 'suppressCommitHasNoPreviousCommitWarning' as SuppressedKeys,
|
||||||
|
CommitNotFoundWarning: 'suppressCommitNotFoundWarning' as SuppressedKeys,
|
||||||
|
FileNotUnderSourceControlWarning: 'suppressFileNotUnderSourceControlWarning' as SuppressedKeys,
|
||||||
|
GitVersionWarning: 'suppressGitVersionWarning' as SuppressedKeys,
|
||||||
|
LineUncommittedWarning: 'suppressLineUncommittedWarning' as SuppressedKeys,
|
||||||
|
NoRepositoryWarning: 'suppressNoRepositoryWarning' as SuppressedKeys,
|
||||||
|
UpdateNotice: 'suppressUpdateNotice' as SuppressedKeys
|
||||||
|
};
|
||||||
|
|
||||||
|
export class Messages {
|
||||||
|
|
||||||
|
static context: ExtensionContext;
|
||||||
|
|
||||||
|
static configure(context: ExtensionContext) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
static showCommitHasNoPreviousCommitWarningMessage(commit: GitCommit): Promise<string | undefined> {
|
||||||
|
return Messages._showMessage('info', `Commit ${commit.shortSha} (${commit.author}, ${moment(commit.date).fromNow()}) has no previous commit`, SuppressedKeys.CommitHasNoPreviousCommitWarning);
|
||||||
|
}
|
||||||
|
|
||||||
|
static showCommitNotFoundWarningMessage(message: string): Promise<string | undefined> {
|
||||||
|
return Messages._showMessage('warn', `${message}. The commit could not be found`, SuppressedKeys.CommitNotFoundWarning);
|
||||||
|
}
|
||||||
|
|
||||||
|
static showFileNotUnderSourceControlWarningMessage(message: string): Promise<string | undefined> {
|
||||||
|
return Messages._showMessage('warn', `${message}. The file is probably not under source control`, SuppressedKeys.FileNotUnderSourceControlWarning);
|
||||||
|
}
|
||||||
|
|
||||||
|
static showLineUncommittedWarningMessage(message: string): Promise<string | undefined> {
|
||||||
|
return Messages._showMessage('warn', `${message}. The line has uncommitted changes`, SuppressedKeys.LineUncommittedWarning);
|
||||||
|
}
|
||||||
|
|
||||||
|
static showNoRepositoryWarningMessage(message: string): Promise<string | undefined> {
|
||||||
|
return Messages._showMessage('warn', `${message}. No repository could be found`, SuppressedKeys.NoRepositoryWarning);
|
||||||
|
}
|
||||||
|
|
||||||
|
static showUnsupportedGitVersionErrorMessage(version: string): Promise<string | undefined> {
|
||||||
|
return Messages._showMessage('error', `GitLens requires a newer version of Git (>= 2.2.0) than is currently installed (${version}). Please install a more recent version of Git.`, SuppressedKeys.GitVersionWarning);
|
||||||
|
}
|
||||||
|
|
||||||
|
static async showUpdateMessage(version: string): Promise<string | undefined> {
|
||||||
|
const viewReleaseNotes = 'View Release Notes';
|
||||||
|
const result = await Messages._showMessage('info', `GitLens has been updated to v${version}`, SuppressedKeys.UpdateNotice, undefined, viewReleaseNotes);
|
||||||
|
if (result === viewReleaseNotes) {
|
||||||
|
commands.executeCommand(BuiltInCommands.Open, Uri.parse('https://marketplace.visualstudio.com/items/eamodio.gitlens/changelog'));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static async showWelcomeMessage(): Promise<string | undefined> {
|
||||||
|
const viewDocs = 'View Docs';
|
||||||
|
const result = await window.showInformationMessage(`Thank you for choosing GitLens! GitLens is powerful, feature rich, and highly configurable, so please be sure to view the docs and tailor it to suit your needs.`, viewDocs);
|
||||||
|
if (result === viewDocs) {
|
||||||
|
commands.executeCommand(BuiltInCommands.Open, Uri.parse('https://marketplace.visualstudio.com/items/eamodio.gitlens'));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static async _showMessage(type: 'info' | 'warn' | 'error', message: string, suppressionKey: SuppressedKeys, dontShowAgain: string | null = 'Don\'t Show Again', ...actions: any[]): Promise<string | undefined> {
|
||||||
|
if (Messages.context.globalState.get(suppressionKey, false)) return undefined;
|
||||||
|
|
||||||
|
if (dontShowAgain !== null) {
|
||||||
|
actions.push(dontShowAgain);
|
||||||
|
}
|
||||||
|
|
||||||
|
let result: string | undefined = undefined;
|
||||||
|
switch (type) {
|
||||||
|
case 'info':
|
||||||
|
result = await window.showInformationMessage(message, ...actions);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'warn':
|
||||||
|
result = await window.showWarningMessage(message, ...actions);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'error':
|
||||||
|
result = await window.showErrorMessage(message, ...actions);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dontShowAgain === null || result === dontShowAgain) {
|
||||||
|
await Messages.context.globalState.update(suppressionKey, true);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -56,9 +56,9 @@ export namespace Objects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function* values(o: any): IterableIterator<[any]> {
|
export function* values<T>(o: any): IterableIterator<T> {
|
||||||
for (const key in o) {
|
for (const key in o) {
|
||||||
yield [o[key]];
|
yield o[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user