Rupert Swarbrick | 105df01 | 2021-01-29 11:33:13 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # Copyright lowRISC contributors. |
| 3 | # Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | |
| 6 | # A wrapper around lint_commits.py, used for CI. |
| 7 | # |
| 8 | # Expects a single argument, which is the pull request's target branch |
| 9 | # (usually "master"). |
| 10 | |
| 11 | if [ $# != 1 ]; then |
| 12 | echo >&2 "Usage: lint-commits.sh <tgt-branch>" |
| 13 | exit 1 |
| 14 | fi |
| 15 | tgt_branch="$1" |
| 16 | |
Rupert Swarbrick | 81ada4f | 2021-02-16 15:59:39 +0000 | [diff] [blame] | 17 | merge_base="$(git merge-base origin/$tgt_branch HEAD)" || { |
Rupert Swarbrick | 105df01 | 2021-01-29 11:33:13 +0000 | [diff] [blame] | 18 | echo >&2 "Failed to find fork point for origin/$tgt_branch." |
| 19 | exit 1 |
| 20 | } |
| 21 | echo "Checking commit messages since $merge_base" |
| 22 | |
| 23 | # Notes: |
| 24 | # * Merge commits are not checked. We always use rebases instead of |
| 25 | # merges to keep a linear history, which makes merge commits disappear |
| 26 | # ultimately, making them only a CI artifact which should not be |
| 27 | # checked. |
| 28 | # * 'type=error' is used even for warnings. Only "errors" are shown in |
| 29 | # the GitHub checks API. However, warnings don't return a non-zero |
| 30 | # error code so don't fail the build step. |
| 31 | util/lint_commits.py \ |
| 32 | --no-merges \ |
| 33 | --error-msg-prefix="##vso[task.logissue type=error]" \ |
| 34 | --warning-msg-prefix="##vso[task.logissue type=error]" \ |
| 35 | "$merge_base"..HEAD |