Browse Source

chore(script): Allow compare base to be a commit sha1 hash

Zaiming Shi 5 năm trước cách đây
mục cha
commit
6f736a79b7
1 tập tin đã thay đổi với 9 bổ sung2 xóa
  1. 9 2
      scripts/elvis-check.sh

+ 9 - 2
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
     chmod +x ./elvis
 fi
 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() {
-    git diff --name-only origin/"$base"...HEAD
+    git diff --name-only "$compare_base"...HEAD
 }
 }
 
 
 bad_file_count=0
 bad_file_count=0