Skip to content

Commit 990d636

Browse files
committed
Merge main into feat/config-diff-threshold
2 parents 48975ce + e07a539 commit 990d636

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
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?.getDiff(repo, false).catch((_) => null);
631+
const diff = await this.gitService?.getDiffAndWarnUser(repo, false, undefined, true);
632632
if (!diff) {
633633
return;
634634
}

src/service/GitService.ts

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

99-
async getDiff(repo: Repository, cached = true, nameOnly?: boolean): Promise<string> {
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-
throw new Error("Warning: please stage your git changes");
105+
if (!silent) {
106+
this.showInformationMessage("warning: please stage your git changes");
107+
}
106108
} else {
107-
throw new Error("No Changes");
109+
if (!silent) {
110+
this.showInformationMessage("No Changes");
111+
}
108112
}
109113
}
110-
throw new Error("No changes");
114+
if (!silent) {
115+
this.showInformationMessage("No changes");
116+
}
111117
}
112118
return diff;
113119
}
114-
async getDiffAndWarnUser(repo: Repository, cached = true, nameOnly?: boolean) {
115-
return this.getDiff(repo, cached, nameOnly).catch((error) => {
116-
this.showInformationMessage(error.message);
117-
return null;
118-
});
119-
}
120120
/**
121121
* Check if a file path matches any of the exclusion patterns
122122
* @param filePath - The file path to check
@@ -128,7 +128,11 @@ class GitService {
128128
// Simple glob pattern matching
129129
if (pattern.includes("*")) {
130130
const regex = new RegExp(
131-
`^${pattern.replace(/\\/g, "\\\\").replace(/\./g, "\\.").replace(/\*/g, ".*").replace(/\?/g, ".")}$`,
131+
`^${pattern
132+
.replace(/\\/g, "\\\\")
133+
.replace(/\./g, "\\.")
134+
.replace(/\*/g, ".*")
135+
.replace(/\?/g, ".")}$`,
132136
);
133137
if (regex.test(filePath)) {
134138
return true;

0 commit comments

Comments
 (0)