From 8123a2b3b1ac30782400704cce5bec7bde1b2681 Mon Sep 17 00:00:00 2001 From: Carlos Rivera Date: Thu, 23 Mar 2023 18:51:53 -0600 Subject: [PATCH 1/3] Fixed crash on large binary files --- src/utils/limitTokens.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils/limitTokens.js b/src/utils/limitTokens.js index 61771cd..66db3b6 100644 --- a/src/utils/limitTokens.js +++ b/src/utils/limitTokens.js @@ -9,7 +9,9 @@ const sliceChars = (file, maxTokens) => { }; module.exports = (str, maxTokens) => { - const files = str.split(new RegExp(`\n${FILES_SPLIT}`, 'g')); + // Remove binary patches as they are not needed and can be very large. + const formated = str.replace(/(?:GIT binary patch\s*)(delta.*\s*)(?:[diff --git]|$)/gmus, ''); + const files = formated.split(new RegExp(`\n${FILES_SPLIT}`, 'g')); files.sort((a, b) => a.length - b.length); let tokens = 0; From 2a25356817aae451b7363a5c24262a879d825113 Mon Sep 17 00:00:00 2001 From: Carlos Date: Sat, 25 Mar 2023 05:23:39 +0000 Subject: [PATCH 2/3] Resolve issue with encoded line break --- src/utils/limitTokens.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/limitTokens.js b/src/utils/limitTokens.js index 66db3b6..6ff3576 100644 --- a/src/utils/limitTokens.js +++ b/src/utils/limitTokens.js @@ -10,7 +10,7 @@ const sliceChars = (file, maxTokens) => { module.exports = (str, maxTokens) => { // Remove binary patches as they are not needed and can be very large. - const formated = str.replace(/(?:GIT binary patch\s*)(delta.*\s*)(?:[diff --git]|$)/gmus, ''); + const formated = str.replace(/(?:GIT binary patch)(\ndelta.*\s*)(?:[diff --git]|$)/gmsu, 'GIT binary patch'); const files = formated.split(new RegExp(`\n${FILES_SPLIT}`, 'g')); files.sort((a, b) => a.length - b.length); From 8b74e5efefecac9c62533e6d0c0a9f5df55f0657 Mon Sep 17 00:00:00 2001 From: Carlos Rivera Date: Fri, 24 Mar 2023 23:27:23 -0600 Subject: [PATCH 3/3] build dist/index.js --- dist/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index c17e985..ffecb62 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8487,7 +8487,9 @@ const sliceChars = (file, maxTokens) => { }; module.exports = (str, maxTokens) => { - const files = str.split(new RegExp(`\n${FILES_SPLIT}`, 'g')); + // Remove binary patches as they are not needed and can be very large. + const formated = str.replace(/(?:GIT binary patch)(\ndelta.*\s*)(?:[diff --git]|$)/gmsu, 'GIT binary patch'); + const files = formated.split(new RegExp(`\n${FILES_SPLIT}`, 'g')); files.sort((a, b) => a.length - b.length); let tokens = 0; @@ -12608,7 +12610,7 @@ module.exports = function bind(fn, thisArg) { /***/ 731: /***/ (function(module) { -module.exports = {"name":"recap","version":"1.0.0","description":"Github action to summarize the most important changes in a pull request","main":"dist/index.js","scripts":{"build":"eslint src && ncc build src/entrypoint.js","test":"jest","lint":"eslint ./"},"keywords":[],"author":"Manuel de la Torre","license":"MIT","jest":{"testEnvironment":"node","setupFilesAfterEnv":["./tests/setup.js"],"testMatch":["**/?(*.)+(spec|test).[jt]s?(x)"]},"dependencies":{"@actions/core":"^1.5.0","@actions/github":"^5.0.0","axios":"^0.26.1","i18n-js":"^3.9.2","lodash.get":"^4.4.2","mixpanel":"^0.13.0"},"devDependencies":{"@zeit/ncc":"^0.22.3","eslint":"^7.32.0","eslint-config-airbnb-base":"^14.2.1","eslint-plugin-import":"^2.24.1","eslint-plugin-jest":"^24.4.0","jest":"^27.0.6","jest-extended":"^3.2.4","nock":"^13.3.0"},"funding":"https://github.com/sponsors/manuelmhtr"}; +module.exports = {"name":"recap","version":"1.0.1","description":"Github action to summarize the most important changes in a pull request","main":"dist/index.js","scripts":{"build":"eslint src && ncc build src/entrypoint.js","test":"jest","lint":"eslint ./"},"keywords":[],"author":"Manuel de la Torre","license":"MIT","jest":{"testEnvironment":"node","setupFilesAfterEnv":["./tests/setup.js"],"testMatch":["**/?(*.)+(spec|test).[jt]s?(x)"]},"dependencies":{"@actions/core":"^1.5.0","@actions/github":"^5.0.0","axios":"^0.26.1","i18n-js":"^3.9.2","lodash.get":"^4.4.2","mixpanel":"^0.13.0"},"devDependencies":{"@zeit/ncc":"^0.22.3","eslint":"^7.32.0","eslint-config-airbnb-base":"^14.2.1","eslint-plugin-import":"^2.24.1","eslint-plugin-jest":"^24.4.0","jest":"^27.0.6","jest-extended":"^3.2.4","nock":"^13.3.0"},"funding":"https://github.com/sponsors/manuelmhtr"}; /***/ }),