Skip to content
Permalink
Browse files

Print filenames that need to be reformatted (#386)

* Print filenames that need to be reformatted

Print the names of all java files that need reformatting during the check and
reformat operations.
  • Loading branch information
mindhog committed Nov 26, 2019
1 parent 961d7e8 commit 28499d23a0675ad05a641668e64a21b3ab3f4953
Showing with 13 additions and 0 deletions.
  1. +13 −0 java-format/google-java-format-git-diff.sh
@@ -41,17 +41,29 @@ where:

SCRIPT_DIR="$(realpath $(dirname $0))"

function showNoncompliantFiles() {
local forkPoint="$1"
local message="$2"

git diff -U0 ${forkPoint} | \
${SCRIPT_DIR}/google-java-format-diff.py -p1 | \
awk -v "message=$message" \
'/\+\+\+ ([^ ]*)/ { print message $2 }' 1>&2
}

function callGoogleJavaFormatDiff() {
local forkPoint
forkPoint=$(git merge-base --fork-point origin/master)

local callResult
case "$1" in
"check")
showNoncompliantFiles "$forkPoint" "\033[1mNeeds formatting: "
callResult=$(git diff -U0 ${forkPoint} | \
${SCRIPT_DIR}/google-java-format-diff.py -p1 | wc -l)
;;
"format")
showNoncompliantFiles "$forkPoint" "\033[1mReformatting: "
callResult=$(git diff -U0 ${forkPoint} | \
${SCRIPT_DIR}/google-java-format-diff.py -p1 -i)
;;
@@ -60,6 +72,7 @@ function callGoogleJavaFormatDiff() {
${SCRIPT_DIR}/google-java-format-diff.py -p1)
;;
esac
echo -e "\033[0m" 1>&2
echo "${callResult}"
exit 0
}

0 comments on commit 28499d2

Please sign in to comment.
You can’t perform that action at this time.