blob: 720abc4b8501176dd742b70748b29ced56d6c307 [file] [log] [blame]
Rupert Swarbrick105df012021-01-29 11:33:13 +00001#!/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
11if [ $# != 1 ]; then
12 echo >&2 "Usage: lint-commits.sh <tgt-branch>"
13 exit 1
14fi
15tgt_branch="$1"
16
Rupert Swarbrick81ada4f2021-02-16 15:59:39 +000017merge_base="$(git merge-base origin/$tgt_branch HEAD)" || {
Rupert Swarbrick105df012021-01-29 11:33:13 +000018 echo >&2 "Failed to find fork point for origin/$tgt_branch."
19 exit 1
20}
21echo "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.
31util/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