commit eafa4885ee6f7de7cf44cb1e0ee3871bb634ecff
parent a6a164072f9cb4880f4a9d51e3fb1e2c07445d86
Author: Özgür Kesim <oec-taler@kesim.org>
Date: Wed, 18 Dec 2024 12:11:28 +0100
[contrib] added doxygen and codespell checks to pre-commit
The git-hook for pre-commit has been extended to call
doxygen and codespell prior to accept a commit.
If no (significant) files have changed, exit early.
It calls the tools only when files were changed and the tools
codespell and doxygen are actually available. It recommends to
install the tool, when it is missing.
Also, the files to skip for codespell (in CI) is now in a
seperate file contrib/ci/jobs/000-codespell/skip.txt.
Diffstat:
3 files changed, 134 insertions(+), 104 deletions(-)
diff --git a/contrib/ci/jobs/000-codespell/job.sh b/contrib/ci/jobs/000-codespell/job.sh
@@ -2,106 +2,6 @@
set -exuo pipefail
job_dir=$(dirname "${BASH_SOURCE[0]}")
+skip=$(cat $job_dir/skip.txt)
-skip=$(cat <<EOF
-ABOUT-NLS
-*/afl-tests/*
-**/auditor/*.sql
-**/templating/test-specs/*
-*.bbl
-*.bib
-*build-aux*
-*.bst
-*.cache/*
-*/cbdc-es.tex
-*/cbdc-it.tex
-*.cls
-configure*
-config.status
-config.guess
-./src/include/taler_dbevents.h
-*/contrib/*
-*/contrib/hellos/**
-*.dat
-*.deflate
-*.doc
-*/doc/*
-**/doc/flows/main.de.tex
-*/doc/texinfo.tex
-*.docx
-*.ecc
-*.eot
-*.epgz
-*.eps
-*.epub
-**/ExchangeSelection/example.ts
-*.fee
-*.fees
-*.file
-**/fonts/**
-*.gif
-*/.git/**
-*.gz
-*/i18n/strings.ts
-*.info
-*.jpeg
-*.jpg
-*.??.json
-*.json
-*/keys/*
-*key
-*.latexmkrc
-*libtool*
-*.log
-*/m4/*
-*.m4
-**/*.map
-*.min.js
-*.mp4
-*.odg
-*.ods
-*.odt
-*.pack.js
-*.pdf
-*.png
-*.PNG
-**/pnpm-lock.yaml
-*.po
-*.pptx
-*.priv
-**/rfc.bib
-*.rpath
-**/signing-key.asc
-*.sqlite
-*/src/anastasis-data.ts
-**/*.svg
-*.svg
-*.tag
-**/templating/mustach**
-*/templating/test?/**
-*/testcurl/test_tricky.c
-*/debian/tmp/**
-*/debian/taler-exchange/**
-*/debian/.debhelper/**
-*/debian/autoreconf.before
-*/debian/autoreconf.after
-debian/taler-terms-generator/**/*
-taler-terms-generator
-*.tgz
-*.ttf
-*.ttf
-**/valgrind.h
-*/vpn/tests/**
-*.wav
-*.woff
-*.woff2
-*.xcf
-*.xlsx
-*.zkey
-release-artifacts
-EOF
-);
-
-echo Current directory: `pwd`
-
-codespell -I "${job_dir}"/dictionary.txt -S ${skip//$'\n'/,}
+codespell -d -I "${job_dir}"/dictionary.txt -S ${skip//$'\n'/,}
diff --git a/contrib/ci/jobs/000-codespell/skip.txt b/contrib/ci/jobs/000-codespell/skip.txt
@@ -0,0 +1,95 @@
+ABOUT-NLS
+*/afl-tests/*
+**/auditor/*.sql
+**/templating/test-specs/*
+*.bbl
+*.bib
+*build-aux*
+*.bst
+*.cache/*
+*/cbdc-es.tex
+*/cbdc-it.tex
+*.cls
+configure*
+config.status
+config.guess
+./src/include/taler_dbevents.h
+*/contrib/*
+*/contrib/hellos/**
+*.dat
+*.deflate
+*.doc
+*/doc/*
+**/doc/flows/main.de.tex
+*/doc/texinfo.tex
+*.docx
+*.ecc
+*.eot
+*.epgz
+*.eps
+*.epub
+**/ExchangeSelection/example.ts
+*.fee
+*.fees
+*.file
+**/fonts/**
+*.gif
+*/.git/**
+*.gz
+*/i18n/strings.ts
+*.info
+*.jpeg
+*.jpg
+*.??.json
+*.json
+*/keys/*
+*key
+*.latexmkrc
+*libtool*
+*.log
+*/m4/*
+*.m4
+**/*.map
+*.min.js
+*.mp4
+*.odg
+*.ods
+*.odt
+*.pack.js
+*.pdf
+*.png
+*.PNG
+**/pnpm-lock.yaml
+*.po
+*.pptx
+*.priv
+**/rfc.bib
+*.rpath
+**/signing-key.asc
+*.sqlite
+*/src/anastasis-data.ts
+**/*.svg
+*.svg
+*.tag
+**/templating/mustach**
+*/templating/test?/**
+*/testcurl/test_tricky.c
+*/debian/tmp/**
+*/debian/taler-exchange/**
+*/debian/.debhelper/**
+*/debian/autoreconf.before
+*/debian/autoreconf.after
+debian/taler-terms-generator/**/*
+taler-terms-generator
+*.tgz
+*.ttf
+*.ttf
+**/valgrind.h
+*/vpn/tests/**
+*.wav
+*.woff
+*.woff2
+*.xcf
+*.xlsx
+*.zkey
+release-artifacts
diff --git a/contrib/uncrustify_precommit b/contrib/uncrustify_precommit
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# use as .git/hooks/pre-commit
exec 1>&2
@@ -7,6 +7,12 @@ RET=0
changed=$(git diff --cached --name-only | grep -v mustach | grep -v templating/test | grep -v valgrind.h)
crustified=""
+# If nothing (important) has changed, return here
+[ -z "$changed" ] && exit 0
+
+( echo "$changed" | grep -q '\.[ch] *$*') && \
+ echo "Checking formatting with uncrustify..."
+
for f in $changed;
do
if echo $f | grep \\.[c,h]\$ > /dev/null
@@ -30,5 +36,34 @@ then
echo "Run"
echo "uncrustify --replace -c uncrustify.cfg ${crustified}"
echo "before committing."
+ exit $RET
+fi
+
+# Make sure we have no stupid spelling error
+if (which codespell > /dev/null)
+then
+ ( set -o pipefail;
+ echo "Checking for spelling errors with codespell..."
+ contrib/ci/jobs/000-codespell/job.sh src 2> /dev/null;
+ ) || { echo "Please fix the code spell errors first"; exit 2; }
+else
+ echo "No codespell installed, skipping spell check."
+ echo "** Please consider installing codespell! **"
fi
-exit $RET
+
+
+# Make sure doxygen is happy with our annotations
+if (which doxygen > /dev/null)
+then
+ [ -f doc/doxygen/Makefile ] && \
+ ( set -o pipefail;
+ echo "Checking that doxygen is happy..."
+ cd doc/doxygen;
+ make fast 2>&1 | (grep error:; exit 0);
+ ) || { echo "Please fix the errors reported by doxygen first"; exit 3; }
+else
+ echo "No doxygen installed, skipping check."
+ echo "** Please consider installing doxygen! **"
+fi
+
+echo "Commit is all clear!"