1
0
Fork 0

fixed linter script

now support staging area and HEAD~1
This commit is contained in:
Christian Kühnel 2020-03-26 09:47:45 +01:00
parent 3f81b7fb2a
commit 580d4ba63c
3 changed files with 16 additions and 5 deletions

View file

@ -122,10 +122,9 @@ pipeline {
steps {
dir("${LLVM_DIR}")
{
script {
try {
sh(script: "${SCRIPT_DIR}/lint.sh")
sh(script: "${SCRIPT_DIR}/lint.sh HEAD~1")
} catch (e) {
success = false;
failure_message += "\nFailed to run linters" // append as build might already be broken

View file

@ -17,8 +17,11 @@ import re
import sys
import pathspec
# Takes an output of git diff and removes files ignored by patten specified by ignore file.
def main():
# FIXME: use argparse for parsing commandline parameters
# Maybe FIXME: Replace path to file with flags for tidy/format, use paths relative to `__file__`
argv = sys.argv[1:]
if not argv:
print("Please provide a path to .ignore file.")

View file

@ -19,12 +19,21 @@
set -eux
echo "Running linters... ====================================="
# In the normal case: diff staging area against head
# Optionml: diff against another commit, set via command line parameter
COMMIT=HEAD
if (( $# == 1 )); then
COMMIT="$1"
fi;
cd "${WORKSPACE}"
if [ ! -f "compile_commands.json" ] ; then
echo "Could not find compile commands.json in $(pwd)"
exit 1
fi
# clang-format
# Let clang format apply patches --diff doesn't produces results in the format we want.
git-clang-format
git-clang-format "${COMMIT}"
set +e
git diff -U0 --exit-code | "${SCRIPT_DIR}/ignore_diff.py" "${SCRIPT_DIR}/clang-format.ignore" > "${TARGET_DIR}"/clang-format.patch
set -e
@ -32,6 +41,6 @@ set -e
git checkout -- .
# clang-tidy
git diff -U0 HEAD | "${SCRIPT_DIR}/ignore_diff.py" "${SCRIPT_DIR}/clang-tidy.ignore" | clang-tidy-diff -p1 -quiet | sed "/^[[:space:]]*$/d" > "${TARGET_DIR}"/clang-tidy.txt
git diff -U0 "${COMMIT}" | "${SCRIPT_DIR}/ignore_diff.py" "${SCRIPT_DIR}/clang-tidy.ignore" | clang-tidy-diff -p1 -quiet | sed "/^[[:space:]]*$/d" > "${TARGET_DIR}"/clang-tidy.txt
echo "linters completed ======================================"