Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git - Add "OK, Don't Ask Again" button to the publish branch prompt #165487

Merged
merged 1 commit into from Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 15 additions & 6 deletions extensions/git/src/commands.ts
Expand Up @@ -5,7 +5,7 @@

import * as os from 'os';
import * as path from 'path';
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';
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';
import TelemetryReporter from '@vscode/extension-telemetry';
import { uniqueNamesGenerator, adjectives, animals, colors, NumberDictionary } from '@joaomoreno/unique-names-generator';
import { Branch, ForcePushMode, GitErrorCodes, Ref, RefType, Status, CommitOptions, RemoteSourcePublisher, Remote } from './api/git';
Expand Down Expand Up @@ -351,6 +351,7 @@ export class CommandCenter {
constructor(
private git: Git,
private model: Model,
private globalState: Memento,
private logger: LogOutputChannel,
private telemetryReporter: TelemetryReporter
) {
Expand Down Expand Up @@ -2544,12 +2545,20 @@ export class CommandCenter {
return;
}

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

if (pick === yes) {
if (pick === yes || pick === neverAgain) {
if (pick === neverAgain) {
this.globalState.update('confirmBranchPublish', false);
}
await this.publish(repository);
}
} else {
await this.publish(repository);
}
}
Expand Down
2 changes: 1 addition & 1 deletion extensions/git/src/main.ts
Expand Up @@ -106,7 +106,7 @@ async function createModel(context: ExtensionContext, logger: LogOutputChannel,
git.onOutput.addListener('log', onOutput);
disposables.push(toDisposable(() => git.onOutput.removeListener('log', onOutput)));

const cc = new CommandCenter(git, model, logger, telemetryReporter);
const cc = new CommandCenter(git, model, context.globalState, logger, telemetryReporter);
disposables.push(
cc,
new GitFileSystemProvider(model),
Expand Down