From 394038fea57caeb65d6d52977acdb08e77d2653b Mon Sep 17 00:00:00 2001 From: Mrigank Krishan Date: Tue, 27 Feb 2018 17:20:50 +0530 Subject: [PATCH 1/4] fixes #44304 --- extensions/git/src/repository.ts | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index 3e1f75d4fda..d1b970ec22b 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -954,12 +954,37 @@ export class Repository implements Disposable { this.isRepositoryHuge = didHitLimit; if (didHitLimit && !shouldIgnore && !this.didWarnAboutLimit) { - const neverAgain = { title: localize('neveragain', "Don't Show Again") }; + //check for known large folders that should be in .gitignore + let knownHugeFolders = ['node_modules', 'pp']; //maybe get from config + let knownHugeFolderUris: Uri[] = knownHugeFolders.map(folder => { + return Uri.file(`${this.repository.root}${path.sep}${folder}`); + }); + knownHugeFolderUris = knownHugeFolderUris.filter((folder) => { + return fs.existsSync(folder.fsPath); + }); - window.showWarningMessage(localize('huge', "The git repository at '{0}' has too many active changes, only a subset of Git features will be enabled.", this.repository.root), neverAgain).then(result => { + //text + const addKnown = localize('add known', 'Would you like to add known large folders to .gitignore?'); + const gitWarn = localize('huge', 'The git repository at {0} has too many active changes, only a subset of Git features will be enabled.', this.repository.root); + + //options + const neverAgain = { title: localize('neveragain', "Don't Show Again") }; + const yes = { title: localize('yes', "Yes") }; + + let warningPromise; + if (knownHugeFolders.length) { + warningPromise = window.showWarningMessage(`${gitWarn} ${addKnown}`, yes, neverAgain); + } else { + warningPromise = window.showWarningMessage(gitWarn, neverAgain); + } + + warningPromise.then(result => { if (result === neverAgain) { config.update('ignoreLimitWarning', true, false); } + else if (result === yes) { + this.ignore(knownHugeFolderUris); + } }); this.didWarnAboutLimit = true; From 26be84df73a5d7a06bbf14f9e3b4de1c7a1cf932 Mon Sep 17 00:00:00 2001 From: Mrigank Krishan Date: Tue, 27 Feb 2018 17:23:27 +0530 Subject: [PATCH 2/4] patch --- extensions/git/src/repository.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index d1b970ec22b..bfcabb1953e 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -955,7 +955,7 @@ export class Repository implements Disposable { if (didHitLimit && !shouldIgnore && !this.didWarnAboutLimit) { //check for known large folders that should be in .gitignore - let knownHugeFolders = ['node_modules', 'pp']; //maybe get from config + let knownHugeFolders = ['node_modules']; //maybe get from config let knownHugeFolderUris: Uri[] = knownHugeFolders.map(folder => { return Uri.file(`${this.repository.root}${path.sep}${folder}`); }); From ed777cc53402f5c80be60c42ba732170f2e31808 Mon Sep 17 00:00:00 2001 From: Mrigank Krishan Date: Tue, 27 Feb 2018 19:56:07 +0530 Subject: [PATCH 3/4] style according to wiki --- extensions/git/src/repository.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index bfcabb1953e..82d34d23dc1 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -959,13 +959,13 @@ export class Repository implements Disposable { let knownHugeFolderUris: Uri[] = knownHugeFolders.map(folder => { return Uri.file(`${this.repository.root}${path.sep}${folder}`); }); - knownHugeFolderUris = knownHugeFolderUris.filter((folder) => { + knownHugeFolderUris = knownHugeFolderUris.filter(folder => { return fs.existsSync(folder.fsPath); }); //text - const addKnown = localize('add known', 'Would you like to add known large folders to .gitignore?'); - const gitWarn = localize('huge', 'The git repository at {0} has too many active changes, only a subset of Git features will be enabled.', this.repository.root); + const addKnown = localize('add known', "Would you like to add known large folders to .gitignore?"); + const gitWarn = localize('huge', "The git repository at {0} has too many active changes, only a subset of Git features will be enabled.", this.repository.root); //options const neverAgain = { title: localize('neveragain', "Don't Show Again") }; From d1ba7ad76153cb147bb782cf5bf53379c231b1ec Mon Sep 17 00:00:00 2001 From: Mrigank Krishan Date: Tue, 5 Jun 2018 00:43:22 +0530 Subject: [PATCH 4/4] minor improvements --- extensions/git/src/repository.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index 82d34d23dc1..0d8248120d6 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -840,7 +840,7 @@ export class Repository implements Disposable { const text = lastLine.isEmptyOrWhitespace ? `${textToAppend}\n` : `\n${textToAppend}\n`; edit.insert(document.uri, lastLine.range.end, text); - workspace.applyEdit(edit); + await workspace.applyEdit(edit).then(document.save); }); } @@ -963,8 +963,15 @@ export class Repository implements Disposable { return fs.existsSync(folder.fsPath); }); + let alreadyIgnored = await this.checkIgnore(knownHugeFolderUris.map(uri => uri.path)); + + //filter already ignored + knownHugeFolderUris = knownHugeFolderUris.filter(folder => { + return !alreadyIgnored.has(folder.path); + }); + //text - const addKnown = localize('add known', "Would you like to add known large folders to .gitignore?"); + const addKnown = localize('add known', "Would you like to add {0} to .gitignore?", knownHugeFolderUris.map(uri => path.basename(uri.fsPath)).join(', ')); const gitWarn = localize('huge', "The git repository at {0} has too many active changes, only a subset of Git features will be enabled.", this.repository.root); //options @@ -972,7 +979,7 @@ export class Repository implements Disposable { const yes = { title: localize('yes', "Yes") }; let warningPromise; - if (knownHugeFolders.length) { + if (knownHugeFolderUris.length) { warningPromise = window.showWarningMessage(`${gitWarn} ${addKnown}`, yes, neverAgain); } else { warningPromise = window.showWarningMessage(gitWarn, neverAgain);