14 - uses: actions/checkout@v3
16 ref: ${{ github.event.pull_request.head.sha }}
19 - name: Determine branch name
21 BRANCH="${GITHUB_BASE_REF#refs/heads/}"
22 echo "Building for $BRANCH"
23 echo "BRANCH=$BRANCH" >> $GITHUB_ENV
25 - name: Test for merge commits, subject, S.O.B., and email
27 source .github/workflows/ci_helpers.sh
30 for commit in $(git rev-list HEAD ^origin/$BRANCH); do
31 info "=== Checking commit '$commit'"
32 if git show --format='%P' -s $commit | grep -qF ' '; then
33 err "Pull request should not include merge commits"
37 authorname="$(git show -s --format=%aN $commit)"
38 if echo $authorname | grep -q '\S\+\s\+\S\+'; then
39 success "Author name ($authorname) seems ok"
40 elif echo $authorname | grep -q '\S\+'; then
41 success "Author name ($authorname) seems to be nick or alias"
43 err "Author name ($authorname) must be one of: real name 'firstname lastname' OR nickname/alias/handle "
47 committername="$(git show -s --format=%cN $commit)"
48 # Pattern \S\+\s\+\S\+ matches >= 2 names i.e. 3 and more e.g. "John Von Doe" also match
49 if echo $committername | grep -q '\S\+\s\+\S\+'; then
50 success "Committer name ($committername) seems ok"
51 elif echo $committername | grep -q '\S\+'; then
52 # Pattern \S\+ matches single names, typical of nicks or handles
53 success "Committer name ($committername) seems to be nick or alias"
55 err "Committer name ($committername) must be one of: real name 'firstname lastname' OR nickname/alias/handle "
59 subject="$(git show -s --format=%s $commit)"
60 if echo "$subject" | grep -q -e '^[0-9A-Za-z,+/_-]\+: ' -e '^Revert '; then
61 success "Commit subject line seems ok ($subject)"
62 elif echo "$subject" | grep -iq '^Translated using Weblate.*'; then
63 success "Weblate commit subject line exception OK: $subject"
65 err "Commit subject line MUST start with '<package name>: ' ($subject)"
69 body="$(git show -s --format=%b $commit)"
70 authoremail="$(git show -s --format='<%aE>' $commit)"
71 sob="$(git show -s --format='Signed-off-by: %aN <%aE>' $commit)"
72 if echo "$body" | grep -qF "$sob"; then
73 success "Signed-off-by matches author"
74 elif echo "$authoremail" | grep -iqF "<hosted@weblate.org>"; then
75 success "Signed-off-by exception: authored by Weblate"
77 err "Signed-off-by is missing or doesn't match author (should be '$sob')"
81 if echo "$authoremail" | grep -iqF "users.noreply"; then
82 err "Real email address policy: please configure GitHub email ($authoremail) to a real one"