Skip to content

Commit c90cf6c

Browse files
committed
tweak uncommitted changes message
1 parent f1747c2 commit c90cf6c

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

src/gitHelper.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,13 @@ export async function diffIndex(repo: Repository, ref: string, refreshIndex: boo
237237
return statuses;
238238
}
239239

240-
export async function hasUncommittedChanges(repo: Repository, path: string): Promise<boolean> {
241-
const result = await repo.exec(['status', '-z', path]);
240+
export async function hasUncommittedChanges(repo: Repository, path: string, ignoreUntracked: boolean = false): Promise<boolean> {
241+
const args = ['status', '-z'];
242+
if (ignoreUntracked) {
243+
args.push('-uno');
244+
}
245+
args.push(path);
246+
const result = await repo.exec(args);
242247
return result.stdout.trim() !== '';
243248
}
244249

src/treeProvider.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,18 +1183,14 @@ export class GitTreeCompareProvider implements TreeDataProvider<Element>, Dispos
11831183

11841184
const repository = this.repository;
11851185

1186-
// Check for uncommitted changes
1186+
// Check for uncommitted changes (ignoring untracked files)
11871187
try {
1188-
if (await hasUncommittedChanges(repository, repository.root)) {
1189-
const proceed = await window.showWarningMessage(
1190-
'You have uncommitted changes. Checking out the PR will discard them. Continue?',
1191-
{ modal: true },
1192-
'Continue',
1193-
'Cancel'
1188+
if (await hasUncommittedChanges(repository, repository.root, true)) {
1189+
window.showErrorMessage(
1190+
'Please commit your changes or stash them before continuing.',
1191+
{ modal: true }
11941192
);
1195-
if (proceed !== 'Continue') {
11961193
return;
1197-
}
11981194
}
11991195
} catch (e: any) {
12001196
this.log('Error checking for uncommitted changes', e);

0 commit comments

Comments
 (0)