File: commit-checker.yml

package info (click to toggle)
openttd-opensfx 1.0.3-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,576 kB
  • sloc: sh: 166; makefile: 70; python: 12
file content (46 lines) | stat: -rw-r--r-- 1,439 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
name: Commit checker

on:
  pull_request:

jobs:
  commit-checker:
    name: Commit checker
    runs-on: ubuntu-latest

    steps:
    - name: Checkout
      uses: actions/checkout@v2
      with:
        fetch-depth: 4

    - name: Get pull-request commits
      run: |
        set -x
        # actions/checkout did a merge checkout of the pull-request. As such, the first
        # commit is the merge commit. This means that on HEAD^ is the base branch, and
        # on HEAD^2 are the commits from the pull-request. We now check if those trees
        # have a common parent. If not, we fetch a few more commits till we do. In result,
        # the log between HEAD^ and HEAD^2 will be the commits in the pull-request.
        DEPTH=4
        while [ -z "$(git merge-base HEAD^ HEAD^2)" ]; do
            git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --deepen=${DEPTH} origin HEAD
            DEPTH=$(( ${DEPTH} * 4 ))
        done

        # Just to show which commits we are going to evaluate.
        git log --oneline HEAD^..HEAD^2

    - name: Checkout commit-checker
      uses: actions/checkout@v2
      with:
        repository: OpenTTD/OpenTTD-git-hooks
        path: git-hooks
        ref: master

    - name: Check commits
      run: |
        set -x
        HOOKS_DIR=./git-hooks/hooks GIT_DIR=.git ./git-hooks/hooks/check-commits.sh HEAD^..HEAD^2
        echo "Commit checks passed"