[epiphany] Rename run-uncrustify to check-code-style without automatic patching
- From: Jan-Michael Brummer <jbrummer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Rename run-uncrustify to check-code-style without automatic patching
- Date: Sat, 6 Jul 2019 08:51:56 +0000 (UTC)
commit 2b88214f557ffa1f62ae161c4a8f7f2ae12dcee1
Author: Jan-Michael Brummer <jan brummer tabos org>
Date: Fri Jul 5 23:56:23 2019 +0200
Rename run-uncrustify to check-code-style without automatic patching
Instead of changing the code automatically create a common patch file which
can be applied manually.
data/{run-uncrustify => check-code-style} | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/data/run-uncrustify b/data/check-code-style
similarity index 51%
rename from data/run-uncrustify
rename to data/check-code-style
index c145183be..57b604e39 100755
--- a/data/run-uncrustify
+++ b/data/check-code-style
@@ -16,12 +16,37 @@ then
exit 1
fi
+patch=$(mktemp)
+
for DIR in $SOURCE_ROOT/embed $SOURCE_ROOT/lib $SOURCE_ROOT/src $SOURCE_ROOT/tests
do
# Aligning prototypes is not working yet, so avoid headers
for FILE in $(find "$DIR" -name "*.c" ! -path "*/contrib/*")
do
- "$UNCRUSTIFY" -c "$SOURCE_ROOT/data/uncrustify.cfg" --replace --no-backup "$FILE"
- "$LINEUP_PARAMETERS" "$FILE" > "$FILE.temp" && mv "$FILE.temp" "$FILE"
+ cp $FILE $FILE.check
+ "$UNCRUSTIFY" -c "$SOURCE_ROOT/data/uncrustify.cfg" --replace --no-backup "$FILE.check"
+ "$LINEUP_PARAMETERS" "$FILE.check" > "$FILE.temp" && mv "$FILE.temp" "$FILE.check"
+ diff -u "$FILE" "$FILE.check" | sed -e "1s|--- |--- a/|" -e "2s|+++ -|+++ b/$file|" >> "$patch"
+ rm $FILE.check
done
done
+
+if [ ! -s "$patch" ] ; then
+ printf "** Commit is valid. \\o/\n"
+ rm -f "$patch"
+ exit 0
+fi
+
+printf "** Commit does not comply to the correct style :(\n\n"
+
+if hash colordiff 2> /dev/null; then
+ colordiff < $patch
+else
+ cat "$patch"
+fi
+
+printf "\n"
+printf "You can apply these changed with: git apply $patch\n"
+printf "\n"
+
+exit 1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]