diff --git a/tag_generator.sh b/tag_generator.sh index 9ba43254..acbca910 100755 --- a/tag_generator.sh +++ b/tag_generator.sh @@ -69,18 +69,30 @@ else echo "compare_json:$compare_json\n" new_patch=$patch new_minor=$minor + declare -A 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 + continue + fi + seen_commits[$commit_id]=1 + + # 跳过 Merge 和 Revert 提交 + if [[ "$commit_title" =~ ^Merge ]] || [[ "$commit_title" =~ ^Revert ]]; then + continue + fi + echo "----$commit_message" - if [[ "$commit_message" =~ ("feat:"*) ]] && [[ $new_minor == $minor ]]; then + if [[ "$commit_message" =~ ^feat: ]] && [[ $new_minor == $minor ]]; then ((new_minor++)) - elif [[ "$commit_message" =~ ("fix:"*) ]]; then - ((new_patch++)) - elif [[ ! "$commit_message" =~ ("Merge"* | "Revert"*) ]]; then + elif [[ "$commit_message" =~ ^fix: ]]; then ((new_patch++)) fi - done < <(echo "$compare_json" | jq -c '.commits[] | {id: .id, message: .message}') + done < <(echo "$compare_json" | jq -c '.commits[] | {id: .id, title: .title, message: .message}') next_tag="v${major}.${new_minor}.${new_patch}_sky" fi