You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if [[ ! "${commit_message}" =~ ^(feat|fix|docs|chore|style|refactor|perf|test|build|ci|revert)(\([a-zA-Z0-9_-]+\))?(!?): ]]; then
57
-
echo "::error file=COMMIT_MESSAGE::Commit ${commit_sha} does not start with a conventional commit type (e.g., 'feat:', 'fix:'). Message: '${commit_message}'"
133
+
134
+
echo "${COMMIT_MESSAGE}"
135
+
136
+
echo ""
137
+
138
+
139
+
140
+
# Check for skip keywords
141
+
142
+
skip_this_commit=false
143
+
144
+
for keyword in "${skip_keywords[@]}"; do
145
+
146
+
# Trim whitespace from keyword
147
+
148
+
trimmed_keyword=$(echo "$keyword" | xargs)
149
+
150
+
151
+
152
+
if [[ -n "$trimmed_keyword" ]] &&
153
+
154
+
[[ "${COMMIT_MESSAGE}" == *"$trimmed_keyword"* ]]; then
155
+
156
+
echo "Skipping validation for commit ${commit_sha} due to skip keyword: ${trimmed_keyword}"
157
+
158
+
skip_this_commit=true
159
+
160
+
break
161
+
162
+
fi
163
+
164
+
done
165
+
166
+
167
+
168
+
if [ "$skip_this_commit" = true ]; then
169
+
170
+
continue
171
+
172
+
fi
173
+
174
+
175
+
176
+
# --- Validation Logic Start ---
177
+
178
+
179
+
180
+
# 1. Check Conventional Commit format
181
+
182
+
if [[ ! "${COMMIT_MESSAGE}" =~ ^(feat|fix|docs|chore|style|refactor|perf|test|build|ci|revert)(\([a-zA-Z0-9_-]+\))?(!?): ]]; then
183
+
184
+
echo "::error file=COMMIT_MESSAGE::Commit ${commit_sha} does not start with a conventional commit type. Message: '${COMMIT_MESSAGE}'"
185
+
58
186
has_validation_failed=true
59
-
continue # Move to the next commit
187
+
188
+
continue
189
+
190
+
fi
191
+
192
+
193
+
194
+
# Extract commit subject (first line)
195
+
196
+
commit_subject=$(echo "${COMMIT_MESSAGE}" | head -n 1)
echo "::error file=COMMIT_MESSAGE::Commit ${commit_sha} subject is too short (min 15 characters). Length: ${#commit_subject}. Subject: '${commit_subject}'"
205
+
206
+
has_validation_failed=true
207
+
208
+
continue
209
+
60
210
fi
61
-
# Extract the first line (subject) for further checks.
62
-
commit_subject=$(echo "${commit_message}" | head -n 1)
63
-
# 2. Check subject line length (e.g., max 72 characters)
0 commit comments