Skip to content

Commit 4edc49a

Browse files
committed
feat(git): add silent option to getDiffAndWarnUser method
1 parent 57880a0 commit 4edc49a

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/Diffy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ class Diffy extends BaseDiffy {
625625
}
626626

627627
// Get current staged diff in background
628-
const diff = await this.gitService?.getDiffAndWarnUser(repo, false);
628+
const diff = await this.gitService?.getDiffAndWarnUser(repo, false, undefined, true);
629629
if (!diff) {
630630
return;
631631
}

src/service/GitService.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,25 @@ class GitService {
9696
window.showInformationMessage(`${CONSTANTS.extensionShortName}: ${msg}`);
9797
}
9898

99-
async getDiffAndWarnUser(repo: Repository, cached = true, nameOnly?: boolean) {
99+
async getDiffAndWarnUser(repo: Repository, cached = true, nameOnly?: boolean, silent = false) {
100100
const diff = await this.getGitDiff(repo, cached, nameOnly);
101101
if (!diff) {
102102
if (cached) {
103103
const diffUncached = await repo.diff(false);
104104
if (diffUncached) {
105-
this.showInformationMessage("warning: please stage your git changes");
105+
if (!silent) {
106+
this.showInformationMessage("warning: please stage your git changes");
107+
}
106108
} else {
107-
this.showInformationMessage("No Changes");
109+
if (!silent) {
110+
this.showInformationMessage("No Changes");
111+
}
108112
}
109113
return null;
110114
}
111-
this.showInformationMessage("No changes");
115+
if (!silent) {
116+
this.showInformationMessage("No changes");
117+
}
112118
}
113119
return diff;
114120
}
@@ -124,7 +130,11 @@ class GitService {
124130
// Simple glob pattern matching
125131
if (pattern.includes("*")) {
126132
const regex = new RegExp(
127-
`^${pattern.replace(/\\/g, "\\\\").replace(/\./g, "\\.").replace(/\*/g, ".*").replace(/\?/g, ".")}$`,
133+
`^${pattern
134+
.replace(/\\/g, "\\\\")
135+
.replace(/\./g, "\\.")
136+
.replace(/\*/g, ".*")
137+
.replace(/\?/g, ".")}$`,
128138
);
129139
if (regex.test(filePath)) {
130140
return true;

0 commit comments

Comments
 (0)