check_format: compare commits against previous commit.
Previously when doing the naming conventions check, we were checking against master which was causing some weird issues on patches which weren't rebased. The much simpler check is to just compare each patch against the previous one. This method still works to prevent any bad changes from getting merged, but handles naming issues on a patch by patch basis. Signed-off-by: Seth Howell <seth.howell@intel.com> Change-Id: Ic031ce07ca1c67819b792dc292dcf6c50df5b1a2 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2733 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
parent
ef9fd47d07
commit
a354903737
@ -209,15 +209,17 @@ fi
|
||||
rm -f scripts/posix.log
|
||||
|
||||
echo -n "Checking for proper function naming conventions..."
|
||||
# commit_to_compare = HEAD - 1.
|
||||
commit_to_compare="$(git log --pretty=oneline --skip=1 -n 1 | awk '{print $1}')"
|
||||
failed_naming_conventions=false
|
||||
changed_c_libs=()
|
||||
declared_symbols=()
|
||||
|
||||
# Build an array of all the modified C files.
|
||||
mapfile -t changed_c_libs < <(git diff --name-only HEAD origin/master -- lib/**/*.c module/**/*.c)
|
||||
mapfile -t changed_c_libs < <(git diff --name-only HEAD $commit_to_compare -- lib/**/*.c module/**/*.c)
|
||||
# Matching groups are 1. qualifiers / return type. 2. function name 3. argument list / comments and stuff after that.
|
||||
# Capture just the names of newly added (or modified) function definitions.
|
||||
mapfile -t declared_symbols < <(git diff -U0 origin/master HEAD -- include/spdk*/*.h | sed -En 's/(^[+].*)(spdk[a-z,A-Z,0-9,_]*)(\(.*)/\2/p')
|
||||
mapfile -t declared_symbols < <(git diff -U0 $commit_to_compare HEAD -- include/spdk*/*.h | sed -En 's/(^[+].*)(spdk[a-z,A-Z,0-9,_]*)(\(.*)/\2/p')
|
||||
|
||||
for c_file in "${changed_c_libs[@]}"; do
|
||||
lib_map_file="mk/spdk_blank.map"
|
||||
@ -228,7 +230,7 @@ for c_file in "${changed_c_libs[@]}"; do
|
||||
fi
|
||||
# Matching groups are 1. leading +sign. 2, function name 3. argument list / anything after that.
|
||||
# Capture just the names of newly added (or modified) functions that start with "spdk_"
|
||||
mapfile -t defined_symbols < <(git diff -U0 origin/master HEAD -- $c_file | sed -En 's/(^[+])(spdk[a-z,A-Z,0-9,_]*)(\(.*)/\2/p')
|
||||
mapfile -t defined_symbols < <(git diff -U0 $commit_to_compare HEAD -- $c_file | sed -En 's/(^[+])(spdk[a-z,A-Z,0-9,_]*)(\(.*)/\2/p')
|
||||
# It's possible that we just modified a functions arguments so unfortunately we can't just look at changed lines in this function.
|
||||
# matching groups are 1. All leading whitespace 2. function name. Capture just the symbol name.
|
||||
mapfile -t exported_symbols < <(sed -En 's/(^[[:space:]]*)(spdk[a-z,A-Z,0-9,_]*);/\2/p' < $lib_map_file)
|
||||
|
Loading…
Reference in New Issue
Block a user