diff options
| author | Nikolay Yakimov <root@livid.pp.ru> | 2020-05-26 08:07:24 +0300 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-25 22:07:24 -0700 | 
| commit | 52a73abfe407317c32eb8d0f839e01c584b9e9d4 (patch) | |
| tree | 5d6dde56d360d2d6ade96303920e7e7c11aff9b3 | |
| parent | 46cb70a30c18a8d2a85dab135ed75cc44d722458 (diff) | |
| download | pandoc-52a73abfe407317c32eb8d0f839e01c584b9e9d4.tar.gz | |
[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
| -rw-r--r-- | .github/workflows/ci.yml | 10 | ||||
| -rw-r--r-- | .github/workflows/commit-validation.yml | 38 | 
2 files changed, 38 insertions, 10 deletions
| diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0eeb2f086..05bb75f7f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,16 +58,6 @@ jobs:      steps:      - uses: actions/checkout@v1 -    - name: Check commit message -      run: | -        # Get last commit message -        if git log -1 --pretty=format:"%s" --no-merges | grep -E -c "^[^#].{78}"; then -          echo "Last commit log contains a line with more than 78 characters." -          exit 1 -        else -          echo "Commit log looks good." -        fi -      # declare/restore cached things      # caching doesn't work for scheduled runs yet      # https://github.com/actions/cache/issues/63 diff --git a/.github/workflows/commit-validation.yml b/.github/workflows/commit-validation.yml new file mode 100644 index 000000000..0b52e94e5 --- /dev/null +++ b/.github/workflows/commit-validation.yml @@ -0,0 +1,38 @@ +name: commit-validation +on: [ push, pull_request ] + +jobs: +  check-commit-msg-length: +    runs-on: ubuntu-latest +    steps: +    - uses: actions/checkout@v1 +    - name: Check commit message length +      run: | +        # Get last commit messages +        if [ "${{github.event_name}}" = "push" ]; then +          if [ "${{github.event.before}}" = "0000000000000000000000000000000000000000" ]; then +            # We are on a new branch +            current="$(echo '${{github.ref}}' | sed 's!^refs/heads!origin!')" +            readarray -t other < <(git show-ref | awk -F' ' '{ sub(/^refs\/remotes\//,"",$NF); }($NF != "'"$current"'"){print "^" $NF;}') +            LOG_RANGE=( "$current" "${other[@]}" ) +            unset current other +          else +            # We are on existing branch +            LOG_RANGE=( "${{github.event.before}}.." ) +          fi +        elif [ "${{github.event_name}}" = "pull_request" ]; then +          LOG_RANGE=( "origin/${{github.base_ref}}.." ) +        fi +        if [[ -v LOG_RANGE ]]; then +          if git log --no-merges --pretty=format:"%s" "${LOG_RANGE[@]}" -- | grep -qE "^[^#].{78}"; then +            echo -e "Last commit log contains a line with more than 78 characters:\n" +            git log --no-merges --pretty=format:"%h: %s" "${LOG_RANGE[@]}" -- | grep -E "^[^:]+: [^#].{78}" +            echo +            exit 1 +          else +            echo "Commit log looks good." +          fi +          unset LOG_RANGE +        else +          echo "Not checking commits on ${{github.event_name}}" +        fi | 
