Skip to content

Commit 97c98de

Browse files
committed
fix: Improve Tekton gitlint step to list all failing commits
* Updated the Gitlint invocation method within the Tekton pipeline script. * Changed the commit linting check to collect all non-compliant commit hashes. * Modified the step to output a list of every commit that failed the linting check before exiting. * Provided clearer feedback to developers by identifying all commits needing correction. Signed-off-by: Chmouel Boudjnah <[email protected]>
1 parent 767851d commit 97c98de

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

.tekton/linter.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,22 @@ spec:
8080
8181
# Check all commits between base_sha and HEAD
8282
base_sha="{{ body.pull_request.base.sha }}"
83-
failed=0
83+
failed=()
8484
while read -r commit_hash; do
8585
echo "Checking commit: $commit_hash"
86-
if ! gitlint --commit "$commit_hash" --ignore "Merge branch"; then
87-
failed=1
86+
if ! git log -1 --pretty=format:%B "$commit_hash" | gitlint --stage; then
87+
echo "Gitlint failed for commit: $commit_hash"
88+
failed+=("$commit_hash")
8889
fi
8990
done < <(git log "${base_sha}..HEAD" --format=format:%H --no-merges)
9091
91-
exit $failed
92+
if [ "${#failed[@]}" -ne 0 ]; then
93+
echo "Failed commits: ${failed[@]}"
94+
exit 1
95+
else
96+
echo "Gitlint completed. All commits passed."
97+
exit 0
98+
fi
9299
93100
- name: check-generated-schemas
94101
displayName: "Check generated OpenAPI schemas"

0 commit comments

Comments
 (0)