From ad5caef601b663dda9c1fef3393d55a0f387deaa Mon Sep 17 00:00:00 2001 From: Tim 'mithro' Ansell Date: Thu, 23 Jan 2020 10:37:15 -0800 Subject: [PATCH] kokoro: Behave better on large diffs. If the diff is very large, don't do a couple of things; * Output the patch into the console log. * Generate a pretty HTML version of the diff. Signed-off-by: Tim 'mithro' Ansell --- .github/kokoro/db-full.sh | 59 ++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 17 deletions(-) diff --git a/.github/kokoro/db-full.sh b/.github/kokoro/db-full.sh index 2fa14180..5fc5030d 100755 --- a/.github/kokoro/db-full.sh +++ b/.github/kokoro/db-full.sh @@ -129,13 +129,6 @@ echo "----------------------------------------" echo "----------------------------------------" git diff --stat --irreversible-delete --find-renames --find-copies --ignore-all-space origin/master - # Output the actually diff - echo - echo "----------------------------------------" - echo " Database Diff" - echo "----------------------------------------" - git diff --color --irreversible-delete --find-renames --find-copies --ignore-all-space origin/master - # Save the diff to be uploaded as an artifact echo echo "----------------------------------------" @@ -146,17 +139,49 @@ echo "----------------------------------------" --patch-with-stat --no-color --irreversible-delete --find-renames --find-copies origin/master \ > diff.patch - # Pretty HTML file version - diff2html --summary=open --file diff.html --format html \ - -- \ - --irreversible-delete --find-renames --find-copies \ - --ignore-all-space origin/master || true + MAX_DIFF_LINES=50000 + DIFF_LINES="$(wc -l diff.patch | sed -e's/ .*$//')" + if [ $DIFF_LINES -gt $MAX_DIFF_LINES ]; then + echo + echo "----------------------------------------" + echo " Database Diff" + echo "----------------------------------------" + echo "diff has $DIFF_LINES lines which is too large to display!" - # Programmatic JSON version - diff2html --file diff.json --format json \ - -- \ - --irreversible-delete --find-renames --find-copies \ - --ignore-all-space origin/master || true + echo + echo "----------------------------------------" + echo " Generating pretty diff output" + echo "----------------------------------------" + echo "diff has $DIFF_LINES lines which is too large for HTML output!" + else + # Output the actually diff + echo + echo "----------------------------------------" + echo " Database Diff" + echo "----------------------------------------" + git diff --color --irreversible-delete --find-renames --find-copies --ignore-all-space origin/master + + echo + echo "----------------------------------------" + echo " Generating pretty diff output" + echo "----------------------------------------" + ( + # Allow the diff2html to fail. + set +e + + # Pretty HTML file version + diff2html --summary=open --file diff.html --format html \ + -- \ + --irreversible-delete --find-renames --find-copies \ + --ignore-all-space origin/master || true + + # Programmatic JSON version + diff2html --file diff.json --format json \ + -- \ + --irreversible-delete --find-renames --find-copies \ + --ignore-all-space origin/master || true + ) || true + fi ) echo "----------------------------------------"