aboutsummaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2021-05-20 15:54:30 +0200
committerHampusM <hampus@hampusmat.com>2021-05-20 15:54:30 +0200
commite486999f2a02b0b7fef77d52e5e3100ca7fa596a (patch)
tree69aa1c05684ad652c0db72d9f28e13517a802e69 /api
parent7578c24113ba71d7435a94c649566e4e39e0e88c (diff)
Too large patch diffs become hidden
Diffstat (limited to 'api')
-rw-r--r--api/git.js26
1 files changed, 24 insertions, 2 deletions
diff --git a/api/git.js b/api/git.js
index 3161df0..4eb7fff 100644
--- a/api/git.js
+++ b/api/git.js
@@ -157,12 +157,27 @@ function getCommit(base_dir, repo_name, commit_oid)
{
return patch.hunks().then((hunks) =>
{
- console.log(patch.newFile().path());
+ console.log("\n" + patch.newFile().path());
const patch_start = patch_header_data[0][patch_index] + patch_header_data[1][patch_index];
const patch_end = (patch_header_data[0][patch_index + 1] !== undefined) ? patch_header_data[0][patch_index + 1] : all_patches.length - 1;
const patch_content = all_patches.slice(patch_start, patch_end);
+ console.log(patch_content.length);
+ if(patch_content.length > 5000) {
+ console.log("Collapsed!");
+
+ arr.push({
+ from: patch.oldFile().path(),
+ to: patch.newFile().path(),
+ additions: patch.lineStats()["total_additions"],
+ deletions: patch.lineStats()["total_deletions"],
+ too_large: true,
+ hunks: null
+ });
+ return arr;
+ }
+
// Go through all of the patch's hunks
// Patches are split into parts of where in the file the change is made. Those parts are called hunks.
return hunks.reduce((acc, hunk, hunk_index) =>
@@ -197,7 +212,14 @@ function getCommit(base_dir, repo_name, commit_oid)
old_lines: prev_hunk.oldLines(),
}, parseHunkAddDel(patch_content.slice(hunks_data[0], patch_end))));
- arr.push({ from: patch.oldFile().path(), to: patch.newFile().path(), hunks: hunks_data[1] });
+ arr.push({
+ from: patch.oldFile().path(),
+ to: patch.newFile().path(),
+ additions: patch.lineStats()["total_additions"],
+ deletions: patch.lineStats()["total_deletions"],
+ too_large: false,
+ hunks: hunks_data[1]
+ });
return arr;
});