gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] 144/335: add version check to uncrustify hook


From: gnunet
Subject: [libmicrohttpd] 144/335: add version check to uncrustify hook
Date: Sat, 27 Jul 2024 22:00:40 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to tag stf-m2
in repository libmicrohttpd.

commit 6326efdd96bc29d0a4f3fba1e0ed77dceda56f9e
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Mon Apr 8 21:15:31 2024 +0200

    add version check to uncrustify hook
---
 contrib/uncrustify_precommit | 53 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 52 insertions(+), 1 deletion(-)

diff --git a/contrib/uncrustify_precommit b/contrib/uncrustify_precommit
index 24873330..c7678c53 100755
--- a/contrib/uncrustify_precommit
+++ b/contrib/uncrustify_precommit
@@ -1,9 +1,60 @@
-#!/bin/sh
+#!/bin/bash
 
 # use as .git/hooks/pre-commit
 
+function vercomp () {
+    if [[ $1 == $2 ]]
+    then
+        return 0
+    fi
+    local IFS=.
+    local i ver1=($1) ver2=($2)
+    # fill empty fields in ver1 with zeros
+    for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
+    do
+        ver1[i]=0
+    done
+    for ((i=0; i<${#ver1[@]}; i++))
+    do
+        if [[ -z ${ver2[i]} ]]
+        then
+            # fill empty fields in ver2 with zeros
+            ver2[i]=0
+        fi
+        if ((10#${ver1[i]} > 10#${ver2[i]}))
+        then
+            return 1
+        fi
+        if ((10#${ver1[i]} < 10#${ver2[i]}))
+        then
+            return 2
+        fi
+    done
+    return 0
+}
+
 exec 1>&2
 
+if ! uncrustify --version > /dev/null
+then
+    echo 'uncrustify required'
+    exit 1
+fi
+
+HAVE=$(uncrustify --version | sed -e 's/.*-//' -e 's/_.//')
+
+vercmp 0.78.0 "$HAVE"
+case $? in
+    0)
+    ;;
+    1)
+        echo "your uncrustify is too old";
+        exit 1
+        ;;
+    2)
+        ;;
+esac
+
 RET=0
 changed=$(git diff --cached --name-only)
 crustified=""

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]