diff --git a/tag_generator.sh b/tag_generator.sh index acbca910..141408f9 100755 --- a/tag_generator.sh +++ b/tag_generator.sh @@ -69,17 +69,17 @@ else echo "compare_json:$compare_json\n" new_patch=$patch new_minor=$minor - declare -A seen_commits # 用于去重 + seen_commits="" # 用于去重 while IFS= read -r commit_json; do commit_id=$(echo "$commit_json" | jq -r '.id') commit_title=$(echo "$commit_json" | jq -r '.title') commit_message=$(echo "$commit_json" | jq -r '.message') - # commit id 去重 - if [[ -n "${seen_commits[$commit_id]}" ]]; then + # commit id 去重(兼容所有 shell) + if echo "$seen_commits" | grep -q "$commit_id"; then continue fi - seen_commits[$commit_id]=1 + seen_commits="$seen_commits $commit_id" # 跳过 Merge 和 Revert 提交 if [[ "$commit_title" =~ ^Merge ]] || [[ "$commit_title" =~ ^Revert ]]; then