Skip to content

Commit

Permalink
HBASE-26892 Add spotless:check in our pre commit general check
Browse files Browse the repository at this point in the history
  • Loading branch information
Apache9 committed May 3, 2022
1 parent da55154 commit c8e3031
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
49 changes: 49 additions & 0 deletions dev-support/hbase-personality.sh
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,55 @@ function hbaseanti_patchfile
return 0
}

######################################

add_test_type spotless

## @description spotless file filter
## @audience private
## @stability evolving
## @param filename
function spotless_filefilter
{
# always add spotless check as it can format almost all types of files
add_test spotless
}
## @description run spotless:check to check format issues
## @audience private
## @stability evolving
## @param repostatus
function spotless_rebuild
{
local repostatus=$1
local logfile="${PATCH_DIR}/${repostatus}-spotless.txt"

if ! verify_needed_test spotless; then
return 0
fi

big_console_header "Checking spotless on ${repostatus}"

start_clock

local -a maven_args=('spotless:check')

# disabled because "maven_executor" needs to return both command and args
# shellcheck disable=2046
echo_and_redirect "${logfile}" $(maven_executor) "${maven_args[@]}"

count=$(${GREP} -c '\[ERROR\]' "${logfile}")
if [[ ${count} -gt 0 ]]; then
add_vote_table -1 spotless "${repostatus} has ${count} errors when running spotless:check, run spotless:apply to fix."
add_footer_table spotless "@@BASE@@/${repostatus}-spotless.txt"
return 1
fi

add_vote_table +1 spotless "${repostatus} has no errors when running spotless:check."
return 0
}

######################################

## @description process the javac output for generating WARNING/ERROR
## @audience private
## @stability evolving
Expand Down
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2756,6 +2756,9 @@
<include>**/*.txt</include>
<include>*.txt</include>
</includes>
<excludes>
<exclude>**/target/**</exclude>
</excludes>
<!-- define the steps to apply to those files -->
<trimTrailingWhitespace/>
<endWithNewline/>
Expand Down

0 comments on commit c8e3031

Please sign in to comment.