From 6f736a79b787d2d1f9234d3112c2783ed9ee0f3c Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Thu, 11 Feb 2021 15:35:37 +0100 Subject: [PATCH] chore(script): Allow compare base to be a commit sha1 hash --- scripts/elvis-check.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/elvis-check.sh b/scripts/elvis-check.sh index 0e105bf99..e367dbfa9 100755 --- a/scripts/elvis-check.sh +++ b/scripts/elvis-check.sh @@ -23,10 +23,17 @@ if [ ! -f ./elvis ] || [ "$(./elvis -v | grep -oE '[1-9]+\.[0-9]+\.[0-9]+\-emqx- chmod +x ./elvis fi -git fetch origin "$base" +if [[ "$base" =~ [0-9a-f]{8,40} ]]; then + # base is a commit sha1 + compare_base="$base" +else + remote="$(git remote -v | grep -E 'github\.com(.|/)emqx' | grep fetch | awk '{print $1}')" + git fetch "$remote" "$base" + compare_base="$remote/$base" +fi git_diff() { - git diff --name-only origin/"$base"...HEAD + git diff --name-only "$compare_base"...HEAD } bad_file_count=0