From 52bbfe926be03f66d57d15743e9914bc4e201c8c Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 5 Oct 2019 15:12:11 +0200 Subject: add uncrustify pre-commit hook --- contrib/auditor-report.tex.j2 | 9 +++++---- contrib/uncrustify_precommit | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 4 deletions(-) create mode 100755 contrib/uncrustify_precommit (limited to 'contrib') diff --git a/contrib/auditor-report.tex.j2 b/contrib/auditor-report.tex.j2 index 33aab79cf..7694ccea8 100644 --- a/contrib/auditor-report.tex.j2 +++ b/contrib/auditor-report.tex.j2 @@ -93,7 +93,7 @@ This section analyzes the income of the exchange operator from fees. Deposit fees & {{ data.total_deposit_fee_income }} \\ Melt fees & {{ data.total_melt_fee_income }} \\ Refund fees & {{ data.total_refund_fee_income }} \\ - Aggregation fees & {{ data.total_aggregation_fee_income }} \\ + Aggregation fees & {{ data.total_aggregation_fee_income }} \\ \hline \hline {\bf Total} & {{ data.income_fee_total }} \\ \end{tabular} \end{center} @@ -845,7 +845,7 @@ impact. {% if data.row_inconsistencies|length() == 0 %} {\bf No row inconsistencies found.} {% else %} - \begin{longtable}{p{2.5cm}|l|p{7cm}} + \begin{longtable}{p{2.5cm}|l|p{5cm}} {\bf Table} & {\bf Row} & {\bf Diagnostic} \\ \hline \hline \endfirsthead @@ -881,11 +881,12 @@ This section describes cases where the exchange did not close a reserve and wire back the remaining funds when the reserve expired. +% Table generation tested by testcase #21 in test-auditor.sh {% if data.reserve_not_closed_inconsistencies|length() == 0 %} {\bf All expired reserves were closed.} {% else %} - \begin{longtable}{p{5.5cm}|c|r} + \begin{longtable}{p{4.5cm}|c|r} {\bf Reserve} & {\bf Expired} & {\bf Balance} \\ \hline \hline \endfirsthead {\bf Reserve} & {\bf Expired} & {\bf Balance} \\ \hline \hline @@ -900,7 +901,7 @@ reserve expired. \label{table:reserve:not_closed} \endlastfoot {% for item in data.reserve_not_closed_inconsistencies %} - {\tt \tiny {{ item.reserve_pub }} } & + {\tt \tiny \truncate{4.3cm}{ {{ item.reserve_pub }} } } & {\tiny {{ item.expiration_time }} } & {{ item.balance }} \\ \hline {% endfor %} diff --git a/contrib/uncrustify_precommit b/contrib/uncrustify_precommit new file mode 100755 index 000000000..fd29998c3 --- /dev/null +++ b/contrib/uncrustify_precommit @@ -0,0 +1,35 @@ +#!/bin/sh + +# use as .git/hooks/pre-commit + +exec 1>&2 + +RET=0 +changed=$(git diff --cached --name-only) +crustified="" + +for f in $changed; +do + if echo $f | grep \\.[c,h]\$ > /dev/null + then + # compare result of uncrustify with changes + # + # only change any of the invocations here if + # they are portable across all cmp and shell + # implementations ! + uncrustify -q -c uncrustify.cfg -f $f | cmp -s $f - + if test $? = 1 ; + then + crustified=" $crustified $f" + RET=1 + fi + fi +done + +if [ $RET = 1 ]; +then + echo "Run" + echo "uncrustify --no-backup -c uncrustify.cfg ${crustified}" + echo "before commiting." +fi +exit $RET -- cgit v1.2.3