Created
May 9, 2020 14:35
-
-
Save kmdupr33/6653557196d103958aa1d9ab628cdb7a to your computer and use it in GitHub Desktop.
exp-util-ref-1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
file="$1" | |
last_sha="$(git rev-list HEAD | tail -n 1)" | |
function sum_numbers() { | |
perl -lane '$t+=$_ for @F; print $t' | |
} | |
file_diffs_sum="$(git diff --shortstat "${last_sha}" "${file}" | sum_numbers)" | |
all_diffs_sum="$(git diff --shortstat "${last_sha}" | sum_numbers)" | |
echo "file_diffs: ${file_diffs_sum}" | |
echo "all_diffs: ${all_diffs_sum}" | |
score="$(echo "scale=5 ; ${file_diffs_sum} / ${all_diffs_sum} * 100" | bc)" | |
echo "Score: ${score} percent" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment