mirror of
https://gitlab.freedesktop.org/plymouth/plymouth.git
synced 2026-05-09 08:18:02 +02:00
.gitlab-ci: Don't regress formatting
The formatting in the codebase isn't perfect, but there's no reason to make it worse. This commit adds a CI check to make sure new code is styled right.
This commit is contained in:
parent
651c22f11a
commit
25523a2f87
2 changed files with 45 additions and 2 deletions
|
|
@ -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
|
||||
|
|
@ -15,7 +16,7 @@ fedora-x86_64:
|
|||
stage: build
|
||||
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
|
||||
|
|
@ -25,7 +26,7 @@ debian-stable-x86_64:
|
|||
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
|
||||
|
|
|
|||
42
scripts/check-format.sh
Executable file
42
scripts/check-format.sh
Executable file
|
|
@ -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
|
||||
|
||||
Loading…
Add table
Reference in a new issue