mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 17:07:15 +02:00
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.
This commit is contained in:
parent
961d7e88f4
commit
28499d23a0
1 changed files with 13 additions and 0 deletions
|
@ -41,6 +41,16 @@ where:
|
||||||
|
|
||||||
SCRIPT_DIR="$(realpath $(dirname $0))"
|
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() {
|
function callGoogleJavaFormatDiff() {
|
||||||
local forkPoint
|
local forkPoint
|
||||||
forkPoint=$(git merge-base --fork-point origin/master)
|
forkPoint=$(git merge-base --fork-point origin/master)
|
||||||
|
@ -48,10 +58,12 @@ function callGoogleJavaFormatDiff() {
|
||||||
local callResult
|
local callResult
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"check")
|
"check")
|
||||||
|
showNoncompliantFiles "$forkPoint" "\033[1mNeeds formatting: "
|
||||||
callResult=$(git diff -U0 ${forkPoint} | \
|
callResult=$(git diff -U0 ${forkPoint} | \
|
||||||
${SCRIPT_DIR}/google-java-format-diff.py -p1 | wc -l)
|
${SCRIPT_DIR}/google-java-format-diff.py -p1 | wc -l)
|
||||||
;;
|
;;
|
||||||
"format")
|
"format")
|
||||||
|
showNoncompliantFiles "$forkPoint" "\033[1mReformatting: "
|
||||||
callResult=$(git diff -U0 ${forkPoint} | \
|
callResult=$(git diff -U0 ${forkPoint} | \
|
||||||
${SCRIPT_DIR}/google-java-format-diff.py -p1 -i)
|
${SCRIPT_DIR}/google-java-format-diff.py -p1 -i)
|
||||||
;;
|
;;
|
||||||
|
@ -60,6 +72,7 @@ function callGoogleJavaFormatDiff() {
|
||||||
${SCRIPT_DIR}/google-java-format-diff.py -p1)
|
${SCRIPT_DIR}/google-java-format-diff.py -p1)
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
echo -e "\033[0m" 1>&2
|
||||||
echo "${callResult}"
|
echo "${callResult}"
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue