Skip to content

Commit

Permalink
Check file existence in the before revision not the after revision
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Baldry <[email protected]>
(cherry picked from commit f2a060c3a6f9f550a0be6b4691dcad7c034f61fe)
Signed-off-by: Jack Baldry <[email protected]>
  • Loading branch information
jdbaldry committed Feb 22, 2024
1 parent 3e64550 commit f89cedc
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions scripts/readability
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ case "${#}" in
;;
3)
# Can only compare if the file exists in both revisions.
if git show "$3:$1" &>/dev/null; then
if git show "$2:$1" &>/dev/null; then
readarray -t before < <(readability "$1" "$2" | grep Readability | sort)
readarray -t after < <(readability "$1" "$3" | grep Readability | sort)

Expand All @@ -81,12 +81,9 @@ case "${#}" in
printf '%s\t%s\t%.2f\t(Δ%+.2f)\t%s\n' "$1" "${rule}" "${after_score}" "${score}" "${guide}"
done
else
readarray -t now < <(readability "$1" "$3" | grep Readability | sort)

for ((i = 0; i < "${#now[@]}"; i++)); do
read -r _file rule score guide <<<"${before[$i]}"
while read -r _file rule score guide; do
printf '%s\t%s\t%.2f\t(Δ%+.2f)\t%s\n' "$1" "${rule}" "${score}" 0 "${guide}"
done
done < <(readability "$1" "$3" | grep Readability | sort)
fi
;;
*)
Expand Down

0 comments on commit f89cedc

Please sign in to comment.