Skip to content

Commit f60ff40

Browse files
authored
Git - Add "OK, Don't Ask Again" button to the publish branch prompt (microsoft#165487)
Add "OK, Don't Ask Again" button to the publish branch prompt
1 parent 0bd1531 commit f60ff40

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

extensions/git/src/commands.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import * as os from 'os';
77
import * as path from 'path';
8-
import { Command, commands, Disposable, LineChange, MessageOptions, Position, ProgressLocation, QuickPickItem, Range, SourceControlResourceState, TextDocumentShowOptions, TextEditor, Uri, ViewColumn, window, workspace, WorkspaceEdit, WorkspaceFolder, TimelineItem, env, Selection, TextDocumentContentProvider, InputBoxValidationSeverity, TabInputText, TabInputTextMerge, QuickPickItemKind, TextDocument, LogOutputChannel, l10n } from 'vscode';
8+
import { Command, commands, Disposable, LineChange, MessageOptions, Position, ProgressLocation, QuickPickItem, Range, SourceControlResourceState, TextDocumentShowOptions, TextEditor, Uri, ViewColumn, window, workspace, WorkspaceEdit, WorkspaceFolder, TimelineItem, env, Selection, TextDocumentContentProvider, InputBoxValidationSeverity, TabInputText, TabInputTextMerge, QuickPickItemKind, TextDocument, LogOutputChannel, l10n, Memento } from 'vscode';
99
import TelemetryReporter from '@vscode/extension-telemetry';
1010
import { uniqueNamesGenerator, adjectives, animals, colors, NumberDictionary } from '@joaomoreno/unique-names-generator';
1111
import { Branch, ForcePushMode, GitErrorCodes, Ref, RefType, Status, CommitOptions, RemoteSourcePublisher, Remote } from './api/git';
@@ -351,6 +351,7 @@ export class CommandCenter {
351351
constructor(
352352
private git: Git,
353353
private model: Model,
354+
private globalState: Memento,
354355
private logger: LogOutputChannel,
355356
private telemetryReporter: TelemetryReporter
356357
) {
@@ -2544,12 +2545,20 @@ export class CommandCenter {
25442545
return;
25452546
}
25462547

2547-
const branchName = repository.HEAD.name;
2548-
const message = l10n.t('The branch "{0}" has no remote branch. Would you like to publish this branch?', branchName);
2549-
const yes = l10n.t('OK');
2550-
const pick = await window.showWarningMessage(message, { modal: true }, yes);
2548+
if (this.globalState.get<boolean>('confirmBranchPublish', true)) {
2549+
const branchName = repository.HEAD.name;
2550+
const message = l10n.t('The branch "{0}" has no remote branch. Would you like to publish this branch?', branchName);
2551+
const yes = l10n.t('OK');
2552+
const neverAgain = l10n.t('OK, Don\'t Ask Again');
2553+
const pick = await window.showWarningMessage(message, { modal: true }, yes, neverAgain);
25512554

2552-
if (pick === yes) {
2555+
if (pick === yes || pick === neverAgain) {
2556+
if (pick === neverAgain) {
2557+
this.globalState.update('confirmBranchPublish', false);
2558+
}
2559+
await this.publish(repository);
2560+
}
2561+
} else {
25532562
await this.publish(repository);
25542563
}
25552564
}

extensions/git/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async function createModel(context: ExtensionContext, logger: LogOutputChannel,
106106
git.onOutput.addListener('log', onOutput);
107107
disposables.push(toDisposable(() => git.onOutput.removeListener('log', onOutput)));
108108

109-
const cc = new CommandCenter(git, model, logger, telemetryReporter);
109+
const cc = new CommandCenter(git, model, context.globalState, logger, telemetryReporter);
110110
disposables.push(
111111
cc,
112112
new GitFileSystemProvider(model),

0 commit comments

Comments
 (0)