Skip to content

Commit 386869a

Browse files
authored
HBASE-26892 Add spotless:check in our pre commit general check (#4393)
Signed-off-by: Nick Dimiduk <[email protected]>
1 parent 404e1d6 commit 386869a

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

dev-support/hbase-personality.sh

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

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

pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2756,6 +2756,10 @@
27562756
<include>**/*.txt</include>
27572757
<include>*.txt</include>
27582758
</includes>
2759+
<excludes>
2760+
<exclude>**/target/**</exclude>
2761+
<exclude>**/dependency-reduced-pom.xml</exclude>
2762+
</excludes>
27592763
<!-- define the steps to apply to those files -->
27602764
<trimTrailingWhitespace/>
27612765
<endWithNewline/>

0 commit comments

Comments
 (0)