Skip to content

Commit 5561d52

Browse files
Copilotalexr00
andcommitted
Address review feedback: Remove test and add "never show again" option
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent c9e7711 commit 5561d52

5 files changed

Lines changed: 22 additions & 152 deletions

File tree

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,11 @@
398398
"type": "boolean",
399399
"description": "%githubPullRequests.neverIgnoreDefaultBranch.description%"
400400
},
401+
"githubPullRequests.neverShowUncommittedChangesWarning": {
402+
"type": "boolean",
403+
"default": false,
404+
"description": "%githubPullRequests.neverShowUncommittedChangesWarning.description%"
405+
},
401406
"githubPullRequests.overrideDefaultBranch": {
402407
"type": "string",
403408
"description": "%githubPullRequests.overrideDefaultBranch.description%"

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"githubPullRequests.ignoredPullRequestBranches.description": "Prevents branches that are associated with a pull request from being automatically detected. This will prevent review mode from being entered on these branches.",
6868
"githubPullRequests.ignoredPullRequestBranches.items": "Branch name",
6969
"githubPullRequests.neverIgnoreDefaultBranch.description": "Never offer to ignore a pull request associated with the default branch of a repository.",
70+
"githubPullRequests.neverShowUncommittedChangesWarning.description": "Never show the warning dialog for uncommitted changes when checking out a pull request.",
7071
"githubPullRequests.overrideDefaultBranch.description": "The default branch for a repository is set on github.com. With this setting, you can override that default with another branch.",
7172
"githubPullRequests.postCreate.description": "The action to take after creating a pull request.",
7273
"githubPullRequests.postCreate.none": "No action",

src/commands.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { CommentReply, findActiveHandler, resolveCommentHandler } from './commen
1212
import { COPILOT_LOGINS } from './common/copilot';
1313
import { commands } from './common/executeCommands';
1414
import Logger from './common/logger';
15-
import { FILE_LIST_LAYOUT, PR_SETTINGS_NAMESPACE } from './common/settingKeys';
15+
import { FILE_LIST_LAYOUT, NEVER_SHOW_UNCOMMITTED_CHANGES_WARNING, PR_SETTINGS_NAMESPACE } from './common/settingKeys';
1616
import { editQuery } from './common/settingsUtils';
1717
import { ITelemetry } from './common/telemetry';
1818
import { asTempStorageURI, fromPRUri, fromReviewUri, Schemes, toPRUri } from './common/uri';
@@ -50,13 +50,20 @@ import { RepositoryChangesNode } from './view/treeNodes/repositoryChangesNode';
5050
// Modal dialog options for handling uncommitted changes during PR checkout
5151
const STASH_CHANGES = vscode.l10n.t('Stash changes');
5252
const DISCARD_CHANGES = vscode.l10n.t('Discard changes');
53+
const DONT_SHOW_AGAIN = vscode.l10n.t('Don\'t show again');
5354

5455
/**
5556
* Shows a modal dialog when there are uncommitted changes during PR checkout
5657
* @param repository The git repository with uncommitted changes
5758
* @returns Promise<boolean> true if user chose to proceed (after staging/discarding), false if cancelled
5859
*/
5960
async function handleUncommittedChanges(repository: Repository): Promise<boolean> {
61+
// Check if user has disabled the warning
62+
const neverShowWarning = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<boolean>(NEVER_SHOW_UNCOMMITTED_CHANGES_WARNING, false);
63+
if (neverShowWarning) {
64+
return true; // Setting is enabled, proceed without showing dialog
65+
}
66+
6067
// Filter out untracked files as they typically don't conflict with PR checkout
6168
const trackedWorkingTreeChanges = repository.state.workingTreeChanges.filter(change => change.status !== Status.UNTRACKED);
6269
const hasTrackedWorkingTreeChanges = trackedWorkingTreeChanges.length > 0;
@@ -74,12 +81,19 @@ async function handleUncommittedChanges(repository: Repository): Promise<boolean
7481
},
7582
STASH_CHANGES,
7683
DISCARD_CHANGES,
84+
DONT_SHOW_AGAIN,
7785
);
7886

7987
if (!modalResult) {
8088
return false; // User cancelled
8189
}
8290

91+
if (modalResult === DONT_SHOW_AGAIN) {
92+
// Update the setting to never show this dialog again
93+
await vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).update(NEVER_SHOW_UNCOMMITTED_CHANGES_WARNING, true, vscode.ConfigurationTarget.Global);
94+
return true; // Proceed with checkout
95+
}
96+
8397
try {
8498
if (modalResult === STASH_CHANGES) {
8599
// Stash all changes (working tree changes + any unstaged changes)

src/common/settingKeys.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const REMOTES = 'remotes';
3232
export const PULL_PR_BRANCH_BEFORE_CHECKOUT = 'pullPullRequestBranchBeforeCheckout';
3333
export type PullPRBranchVariants = 'never' | 'pull' | 'pullAndMergeBase' | 'pullAndUpdateBase' | true | false;
3434
export const UPSTREAM_REMOTE = 'upstreamRemote';
35+
export const NEVER_SHOW_UNCOMMITTED_CHANGES_WARNING = 'neverShowUncommittedChangesWarning';
3536
export const DEFAULT_CREATE_OPTION = 'defaultCreateOption';
3637
export const CREATE_BASE_BRANCH = 'createDefaultBaseBranch';
3738

src/test/commands/handleUncommittedChanges.test.ts

Lines changed: 0 additions & 151 deletions
This file was deleted.

0 commit comments

Comments
 (0)