git.iko.soy/typeable/pandoc
on master help sign in
[CI] broken commit message length test (#6398)

* [CI] Fix commit message length check * [CI] Smarter commit message length check * [CI] Fix commit message length check for new branches * [CI] Output offending commits

commit52a73abfe407317c32eb8d0f839e01c584b9e9d4 authorNikolay Yakimov <root@livid.pp.ru> dateTue 26 May 2020, 08:07 (6 years ago) parent46cb70a
2 files changed+38−10
.github/workflows/ci.yml−10 .github/workflows/commit-validation.yml+38
.github/workflows/ci.yml−10
@@ -58,16 +58,6 @@ jobs:
5858 steps:
5959 - uses: actions/checkout@v1
6060
61− - name: Check commit message
62− run: |
63− # Get last commit message
64− if git log -1 --pretty=format:"%s" --no-merges | grep -E -c "^[^#].{78}"; then
65− echo "Last commit log contains a line with more than 78 characters."
66− exit 1
67− else
68− echo "Commit log looks good."
69− fi
70−
7161 # declare/restore cached things
7262 # caching doesn't work for scheduled runs yet
7363 # https://github.com/actions/cache/issues/63
.github/workflows/commit-validation.ymlnew file+38
@@ -0,0 +1,38 @@
1+name: commit-validation
2+on: [ push, pull_request ]
3+
4+jobs:
5+ check-commit-msg-length:
6+ runs-on: ubuntu-latest
7+ steps:
8+ - uses: actions/checkout@v1
9+ - name: Check commit message length
10+ run: |
11+ # Get last commit messages
12+ if [ "${{github.event_name}}" = "push" ]; then
13+ if [ "${{github.event.before}}" = "0000000000000000000000000000000000000000" ]; then
14+ # We are on a new branch
15+ current="$(echo '${{github.ref}}' | sed 's!^refs/heads!origin!')"
16+ readarray -t other < <(git show-ref | awk -F' ' '{ sub(/^refs\/remotes\//,"",$NF); }($NF != "'"$current"'"){print "^" $NF;}')
17+ LOG_RANGE=( "$current" "${other[@]}" )
18+ unset current other
19+ else
20+ # We are on existing branch
21+ LOG_RANGE=( "${{github.event.before}}.." )
22+ fi
23+ elif [ "${{github.event_name}}" = "pull_request" ]; then
24+ LOG_RANGE=( "origin/${{github.base_ref}}.." )
25+ fi
26+ if [[ -v LOG_RANGE ]]; then
27+ if git log --no-merges --pretty=format:"%s" "${LOG_RANGE[@]}" -- | grep -qE "^[^#].{78}"; then
28+ echo -e "Last commit log contains a line with more than 78 characters:\n"
29+ git log --no-merges --pretty=format:"%h: %s" "${LOG_RANGE[@]}" -- | grep -E "^[^:]+: [^#].{78}"
30+ echo
31+ exit 1
32+ else
33+ echo "Commit log looks good."
34+ fi
35+ unset LOG_RANGE
36+ else
37+ echo "Not checking commits on ${{github.event_name}}"
38+ fi