This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
osmith gerrit-no-reply at lists.osmocom.orgosmith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ci/+/24702 ) Change subject: lint: add helper scripts ...................................................................... lint: add helper scripts Add lint_diff.sh, which runs checkpatch on git diff to either HEAD~1 (if the tree is clean) or HEAD. This can be used as pre-commit hook, and it's what jenkins will run. Add lint_all.sh, which runs checkpatch on a whole repository to test if the rules we are checking for make sense in Osmocom context. Related: OS#5087 Change-Id: I1d02c169b05fb05b87209a444a5ddb86efc99d04 --- A lint/lint_all.sh A lint/lint_diff.sh 2 files changed, 81 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/02/24702/1 diff --git a/lint/lint_all.sh b/lint/lint_all.sh new file mode 100755 index 0000000..1c25578 --- /dev/null +++ b/lint/lint_all.sh @@ -0,0 +1,43 @@ +#!/bin/sh -e +# Script to test if linting is sane by running it on a whole repository +GIT_DIR="$(git rev-parse --show-toplevel 2>/dev/null || true)" +SCRIPT_DIR="$(dirname "$(realpath "$0")")" +OUT=/tmp/lint_all_out +TYPES="$1" + +echo "Running find in $GIT_DIR" +files=$(find \ + "$GIT_DIR" \ + -name '*.c' \ + -o -name '*.h' \ + -o -name '*.cpp' \ + -o -name '*.hpp') + +if [ -n "$TYPES" ]; then + echo "Running checkpath with --types="$TYPES" in $GIT_DIR" + + "$SCRIPT_DIR"/checkpatch/checkpatch.pl \ + -f \ + --color=always \ + --no-summary \ + --no-tree \ + --show-types \ + --terse \ + --types="$TYPES" \ + $files \ + | tee "$OUT" + +else + echo "Running checkpath in $GIT_DIR" + + "$SCRIPT_DIR"/checkpatch/checkpatch_osmo.sh \ + -f \ + --color=always \ + --no-summary \ + --show-types \ + --terse \ + $files \ + | tee "$OUT" +fi + +wc -l "$OUT" diff --git a/lint/lint_diff.sh b/lint/lint_diff.sh new file mode 100755 index 0000000..f8daab7 --- /dev/null +++ b/lint/lint_diff.sh @@ -0,0 +1,38 @@ +#!/bin/sh -e +# Jenkins runs this script on submitted gerrit patches. Can be used as git pre-commit hook. +COMMIT="$1" +GIT_DIR="$(git rev-parse --show-toplevel 2>/dev/null || true)" +SCRIPT_DIR="$(dirname "$(realpath "$0")")" + +if [ -z "$GIT_DIR" ]; then + echo "ERROR: path is not a git repository: $PWD" + exit 1 +fi + +if [ -z "$COMMIT" ]; then + # Clean worktree: diff last commit against the one before + COMMIT="HEAD~1" + + if [ -n "$(git status --porcelain)" ]; then + # Dirty worktree: diff uncommitted changes against last commit + COMMIT="HEAD" + fi +fi + +echo "Running checkpatch on 'git diff $COMMIT'..." +echo +if git diff -U0 "$COMMIT" | "$SCRIPT_DIR/checkpatch/checkpatch_osmo.sh" - \ + --color=always \ + --mailback \ + --show-types \ + --showfile \ + --terse +then + exit 0 +fi + +echo +echo "Please fix the linting errors above. More information:" +echo "https://osmocom.org/projects/cellular-infrastructure/wiki/Linting" +echo +exit 1 -- To view, visit https://gerrit.osmocom.org/c/osmo-ci/+/24702 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-ci Gerrit-Branch: master Gerrit-Change-Id: I1d02c169b05fb05b87209a444a5ddb86efc99d04 Gerrit-Change-Number: 24702 Gerrit-PatchSet: 1 Gerrit-Owner: osmith <osmith at sysmocom.de> Gerrit-MessageType: newchange -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210616/d147ec13/attachment.htm>