diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4896fef989..f9b3dc02cb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -49,7 +49,7 @@ Coding Style The formatting is automated using [clang-format](https://clang.llvm.org/docs/ClangFormat.html). Run `./contrib/scripts/nm-code-format.sh -i` ([[1]](contrib/scripts/nm-code-format.sh)) to reformat -the code or run `clang-format` directly. +the code or run `clang-format` directly. Pass `--help` for the list of options. As the generated format depends on the version of clang-format, you need to use the correct clang-format version. That is basically the version that our [gitlab-ci @@ -58,6 +58,7 @@ for the "check-tree" test. This is the version from a recent Fedora installation You may also run `./contrib/scripts/nm-code-format-container.sh` which uses a Fedora container with podman and the correct version of clang-format. +This accepts the same arguments as `./contrib/scripts/nm-code-format.sh`. You are welcome to not bother and open a merge request with wrong formatting, but note that we then will automatically adjust your contribution before diff --git a/contrib/scripts/nm-code-format-container.sh b/contrib/scripts/nm-code-format-container.sh index e6584322d3..7a5ce0d466 100755 --- a/contrib/scripts/nm-code-format-container.sh +++ b/contrib/scripts/nm-code-format-container.sh @@ -16,36 +16,31 @@ FEDORA_VERSION="$(sed '/^ tier: 1/,/^ - name/!d' .gitlab-ci/config.yml | sed test -n "$FEDORA_VERSION" || die "Could not detect the Fedora version in .gitlab-ci/config.yml" -PODNAME="nm-code-format-f$FEDORA_VERSION" +IMAGENAME="nm-code-format:f$FEDORA_VERSION" -RENEW=0 -for a; do - case "$a" in - -f) - RENEW=1 - ;; - *) - die "invalid argument \"$a\"" - ;; - esac -done +ARGS=( "$@" ) -set -x - -if [ "$RENEW" == 1 ]; then - if podman container exists "$PODNAME" ; then - podman rm "$PODNAME" - fi +if ! podman image exists "$IMAGENAME" ; then + echo "Building image \"$IMAGENAME\"..." + podman build \ + --squash-all \ + --tag "$IMAGENAME" \ + -f <(cat <