Skip to content

Commit 6f3813d

Browse files
committed
fix(git): do not warn message on updateStagedChanges
1 parent 324d811 commit 6f3813d

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/Diffy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ class Diffy extends BaseDiffy {
628628
}
629629

630630
// Get current staged diff in background
631-
const diff = await this.gitService?.getDiffAndWarnUser(repo, false);
631+
const diff = await this.gitService?.getDiff(repo, false).catch((_) => null);
632632
if (!diff) {
633633
return;
634634
}

src/service/GitService.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { type Extension, extensions, window } from "vscode";
33
import type { API as GitApi, GitExtension, Repository } from "../@types/git";
44
import { CONSTANTS } from "../Constants";
55
import WorkspaceService from "./WorkspaceService";
6+
import { logger } from "../utils/log";
67

78
class GitService {
89
static _instance: GitService;
@@ -96,23 +97,27 @@ class GitService {
9697
window.showInformationMessage(`${CONSTANTS.extensionShortName}: ${msg}`);
9798
}
9899

99-
async getDiffAndWarnUser(repo: Repository, cached = true, nameOnly?: boolean) {
100+
async getDiff(repo: Repository, cached = true, nameOnly?: boolean): Promise<string> {
100101
const diff = await this.getGitDiff(repo, cached, nameOnly);
101102
if (!diff) {
102103
if (cached) {
103104
const diffUncached = await repo.diff(false);
104105
if (diffUncached) {
105-
this.showInformationMessage("warning: please stage your git changes");
106+
throw new Error("Warning: please stage your git changes");
106107
} else {
107-
this.showInformationMessage("No Changes");
108+
throw new Error("No Changes");
108109
}
109-
return null;
110110
}
111-
this.showInformationMessage("No changes");
111+
throw new Error("No changes");
112112
}
113113
return diff;
114114
}
115-
115+
async getDiffAndWarnUser(repo: Repository, cached = true, nameOnly?: boolean) {
116+
return this.getDiff(repo, cached, nameOnly).catch((error) => {
117+
this.showInformationMessage(error.message);
118+
return null;
119+
});
120+
}
116121
/**
117122
* Check if a file path matches any of the exclusion patterns
118123
* @param filePath - The file path to check
@@ -252,7 +257,7 @@ class GitService {
252257

253258
return gitExtension.getAPI(1);
254259
}
255-
} catch {}
260+
} catch { }
256261

257262
return undefined;
258263
}

0 commit comments

Comments
 (0)