From 794e9ebe50f902ab92900a9f062f288a0b7c2625 Mon Sep 17 00:00:00 2001 From: ellnor01 <51320439+ellnor01@users.noreply.github.com> Date: Mon, 4 May 2020 19:25:28 +0100 Subject: [PATCH] Add argument to specify branch for clang-format check (#761) If a change is not added to an origin/master branch, an argument can be used to specify the relevant branch name for the clang-format comparison. Change-Id: I8ce712d077bf4d048a04a29c12bc2cb45e4abb93 Signed-off-by: Ellen Norris-Thompson --- check-format.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/check-format.sh b/check-format.sh index 509de621..7eae2fdc 100755 --- a/check-format.sh +++ b/check-format.sh @@ -1,10 +1,13 @@ #!/usr/bin/env bash +# Arg used to specify non-'origin/master' comparison branch +ORIGIN_BRANCH=${1:-"origin/master"} + # Run git-clang-format to check for violations if [ "$TRAVIS" == "true" ]; then EXTRA_OPTS="--binary `which clang-format-9`" fi -CLANG_FORMAT_OUTPUT=$(git-clang-format --diff origin/master --extensions c,cpp,h,hpp $EXTRA_OPTS) +CLANG_FORMAT_OUTPUT=$(git-clang-format --diff $ORIGIN_BRANCH --extensions c,cpp,h,hpp $EXTRA_OPTS) # Check for no-ops grep '^no modified files to format$' <<<"$CLANG_FORMAT_OUTPUT" && exit 0