Skip to content

Commit eab32da

Browse files
committed
HBASE-26892 Add spotless:check in our pre commit general check
1 parent 152ecad commit eab32da

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

dev-support/hbase-personality.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,59 @@ function hbaseanti_patchfile
869869
return 0
870870
}
871871

872+
######################################
873+
874+
add_test_type spotless
875+
876+
## @description only run the test if java or pom changes.
877+
## @audience private
878+
## @stability evolving
879+
## @param filename
880+
function spotless_filefilter
881+
{
882+
local filename=$1
883+
884+
if [[ ${filename} =~ \.java$ ]] || [[ ${filename} =~ pom.xml$ ]]; then
885+
add_test spotless
886+
fi
887+
}
888+
889+
## @description run spotless:check to check format issues
890+
## @audience private
891+
## @stability evolving
892+
## @param repostatus
893+
function spotless_rebuild
894+
{
895+
local repostatus=$1
896+
local logfile="${PATCH_DIR}/${repostatus}-spotless.txt"
897+
898+
if ! verify_needed_test spotless; then
899+
return 0
900+
fi
901+
902+
big_console_header "Checking spotless on ${repostatus}"
903+
904+
start_clock
905+
906+
local -a maven_args=('spotless:check')
907+
908+
# disabled because "maven_executor" needs to return both command and args
909+
# shellcheck disable=2046
910+
echo_and_redirect "${logfile}" $(maven_executor) "${maven_args[@]}"
911+
912+
count=$(${GREP} -c '\[ERROR\]' "${logfile}")
913+
if [[ ${count} -gt 0 ]]; then
914+
add_vote_table -1 spotless "${repostatus} has ${count} errors when running spotless:check, run spotless:apply to fix."
915+
add_footer_table spotless "@@BASE@@/${repostatus}-spotless.txt"
916+
return 1
917+
fi
918+
919+
add_vote_table +1 spotless "${repostatus} has no errors when running spotless:check."
920+
return 0
921+
}
922+
923+
######################################
924+
872925
## @description process the javac output for generating WARNING/ERROR
873926
## @audience private
874927
## @stability evolving

0 commit comments

Comments
 (0)