diff --git a/src/gitManager/gitManager.ts b/src/gitManager/gitManager.ts index 4fc0536f..89be2a20 100644 --- a/src/gitManager/gitManager.ts +++ b/src/gitManager/gitManager.ts @@ -268,21 +268,27 @@ export abstract class GitManager { status = status ?? (await this.status()); const changeset: { [key: string]: string[] } = {}; - status.staged.forEach((value: FileStatusResult) => { - if (value.index in changeset) { - changeset[value.index].push(value.path); - } else { - changeset[value.index] = [value.path]; + let files = ""; + // If there are more than 100 files, we don't list them all + if (status.staged.length < 100) { + status.staged.forEach((value: FileStatusResult) => { + if (value.index in changeset) { + changeset[value.index].push(value.path); + } else { + changeset[value.index] = [value.path]; + } + }); + + const chunks = []; + for (const [action, files] of Object.entries(changeset)) { + chunks.push(action + " " + files.join(" ")); } - }); - const chunks = []; - for (const [action, files] of Object.entries(changeset)) { - chunks.push(action + " " + files.join(" ")); + files = chunks.join(", "); + } else { + files = "Too many files to list"; } - const files = chunks.join(", "); - template = template.replace("{{files}}", files); } @@ -292,14 +298,15 @@ export abstract class GitManager { moment().format(this.plugin.settings.commitDateFormat) ); if (this.plugin.settings.listChangedFilesInMessageBody) { - template = - template + - "\n\n" + - "Affected files:" + - "\n" + - (status ?? (await this.status())).staged - .map((e) => e.path) - .join("\n"); + const status2 = status ?? (await this.status()); + let files = ""; + // If there are more than 100 files, we don't list them all + if (status2.staged.length < 100) { + files = status2.staged.map((e) => e.path).join("\n"); + } else { + files = "Too many files to list"; + } + template = template + "\n\n" + "Affected files:" + "\n" + files; } return template; }