From cbf2de9caa511479fd61e67e3a24dd6c22d7351d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Fri, 11 Sep 2015 18:16:14 -0700 Subject: [PATCH] CI: check formatting via rewritemeta --- .gitlab-ci.yml | 7 +++++-- tools/verify-rewritemeta.sh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100755 tools/verify-rewritemeta.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 26ae2b4122..6ed487bd92 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,10 @@ before_script: - export PATH="$PWD/fdroidserver:$PATH" - touch config.py -test: +lint: script: - - fdroid readmeta - fdroid lint + +format: + script: + - ./tools/verify-rewritemeta diff --git a/tools/verify-rewritemeta.sh b/tools/verify-rewritemeta.sh new file mode 100755 index 0000000000..ec503fcb2d --- /dev/null +++ b/tools/verify-rewritemeta.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +# Verify that rewritemeta has been run. + +set -e + +err() { + echo "$@" >&2 + exit 1 +} + +has_changed_files() { + git update-index -q --refresh + git diff-index --quiet HEAD -- && return 1 || return 0 +} + +list_changed_files() { + git diff-index --name-only HEAD -- || return 0 +} + +if has_changed_files; then + list_changed_files + err "Unstaged changes found; refusing to continue." +fi + +fdroid rewritemeta + +if has_changed_files; then + list_changed_files + err "Run rewritemeta to fix formatting on those files." +fi