summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <halfline@gmail.com>2022-04-06 17:28:22 +0000
committerRay Strode <halfline@gmail.com>2022-04-06 17:28:22 +0000
commitb603ac17e3e6b3939ba5edddc71086a512d06853 (patch)
tree4c74e8571c66506db6f6731fd31184eda8979070
parentd021553e553be9a64b327a443f6f3993e9c4c2ff (diff)
parent25523a2f8743f6e3ca53600f094bf1396eb7967e (diff)
Merge branch 'wip/uncrustify-updates' into 'main'
.gitlab-ci: Don't regress formatting See merge request plymouth/plymouth!174
-rw-r--r--.gitlab-ci.yml11
-rwxr-xr-xscripts/check-format.sh42
-rw-r--r--scripts/default.cfg1
3 files changed, 51 insertions, 3 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index dbae8b96..56283a0c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -4,6 +4,7 @@ stages:
.autotools-build: &autotools-build
script:
+ - scripts/check-format.sh
- NOCONFIGURE=1 ./autogen.sh
- mkdir _build && cd _build
- ../configure --prefix /usr
@@ -13,15 +14,19 @@ stages:
fedora-x86_64:
stage: build
- image: 'registry.fedoraproject.org/fedora:30'
+ image: 'registry.fedoraproject.org/fedora:35'
before_script:
- - dnf install -y gcc libtool intltool gtk3-devel git libpng-devel gettext-devel libxslt docbook-style-xsl cairo-devel systemd-devel systemd-udev kernel-headers libdrm-devel pango-devel make ShellCheck
+ - dnf install -y gcc libtool intltool gtk3-devel git libpng-devel gettext-devel libxslt docbook-style-xsl cairo-devel systemd-devel systemd-udev kernel-headers libdrm-devel pango-devel make ShellCheck uncrustify patchutils
<<: *autotools-build
+ only:
+ - merge_requests
debian-stable-x86_64:
stage: build
image: debian:stable
before_script:
- apt-get update -qq
- - apt-get install -y -qq --no-install-recommends autoconf automake autopoint bc build-essential docbook-xsl gcc gettext git intltool libdrm-dev libgtk-3-dev libpango1.0-dev libpng-dev libtool libudev-dev make pkg-config libsystemd-dev udev xsltproc shellcheck
+ - apt-get install -y -qq --no-install-recommends autoconf automake autopoint bc build-essential docbook-xsl gcc gettext git intltool libdrm-dev libgtk-3-dev libpango1.0-dev libpng-dev libtool libudev-dev make pkg-config libsystemd-dev udev xsltproc shellcheck uncrustify patchutils
<<: *autotools-build
+ only:
+ - merge_requests
diff --git a/scripts/check-format.sh b/scripts/check-format.sh
new file mode 100755
index 00000000..2e313189
--- /dev/null
+++ b/scripts/check-format.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+if [ -z "$CI_MERGE_REQUEST_DIFF_BASE_SHA" ]; then
+ UPSTREAM_BRANCH="$(git rev-parse --abbrev-ref --symbolic-full-name @{u})"
+else
+ UPSTREAM_BRANCH="$CI_MERGE_REQUEST_DIFF_BASE_SHA"
+fi
+
+cp scripts/default.cfg latest-uncrustify-config.cfg
+
+git diff --quiet
+DIRTY_TREE="$?"
+
+if [ "$DIRTY_TREE" -ne 0 ]; then
+ git stash
+ git stash apply
+fi
+
+find -name '*.[ch]' -exec uncrustify -q -c latest-uncrustify-config.cfg --replace {} \;
+git diff > after
+
+git reset --hard $UPSTREAM_BRANCH
+find -name '*.[ch]' -exec uncrustify -q -c latest-uncrustify-config.cfg --replace {} \;
+git diff > before
+
+interdiff --no-revert-omitted before after > diff
+
+if [ -n "$(cat diff)" ]; then
+ echo "Uncrustify found style abnormalities" 2>&1
+ cat diff
+ exit 1
+fi
+
+git reset --hard HEAD@{1}
+
+if [ "$DIRTY_TREE" -ne 0 ]; then
+ git stash pop
+fi
+
+echo "No new style abnormalities found by uncrustify!"
+exit 0
+
diff --git a/scripts/default.cfg b/scripts/default.cfg
index 17828b33..78df1718 100644
--- a/scripts/default.cfg
+++ b/scripts/default.cfg
@@ -23,6 +23,7 @@ nl_brace_while = remove # "} while" vs "} \n while" - cuddle while
nl_brace_else = remove # "} else" vs "} \n else" - cuddle else
sp_brace_else = force
sp_else_brace = force
+nl_func_def_args = add
nl_func_var_def_blk = 1
nl_fcall_brace = remove # "list_for_each() {" vs "list_for_each()\n{"
nl_fdef_brace = add # "int foo() {" vs "int foo()\n{"