]> git.proxmox.com Git - ceph.git/blob - ceph/src/pmdk/utils/check-commits.sh
import ceph 16.2.7
[ceph.git] / ceph / src / pmdk / utils / check-commits.sh
1 #!/usr/bin/env bash
2 # SPDX-License-Identifier: BSD-3-Clause
3 # Copyright 2016-2020, Intel Corporation
4
5 #
6 # Used to check whether all the commit messages in a pull request
7 # follow the GIT/PMDK guidelines.
8 #
9 # usage: ./check-commits.sh [range]
10 #
11
12 if [ -z "$1" ]; then
13 # on CI run this check only for pull requests
14 if [ -n "$CI_REPO_SLUG" ]; then
15 if [[ "$CI_REPO_SLUG" != "$GITHUB_REPO" \
16 || $CI_EVENT_TYPE != "pull_request" ]];
17 then
18 echo "SKIP: $0 can only be executed for pull requests to $GITHUB_REPO"
19 exit 0
20 fi
21 fi
22 # CI_COMMIT_RANGE can be invalid for force pushes - use another
23 # method to determine the list of commits
24 if [[ $(git rev-list $CI_COMMIT_RANGE 2>/dev/null) || -n "$CI_COMMIT_RANGE" ]]; then
25 MERGE_BASE=$(echo $CI_COMMIT_RANGE | cut -d. -f1)
26 [ -z $MERGE_BASE ] && \
27 MERGE_BASE=$(git log --pretty="%cN:%H" | grep GitHub | head -n1 | cut -d: -f2)
28 RANGE=$MERGE_BASE..$CI_COMMIT
29 else
30 MERGE_BASE=$(git log --pretty="%cN:%H" | grep GitHub | head -n1 | cut -d: -f2)
31 RANGE=$MERGE_BASE..HEAD
32 fi
33 else
34 RANGE="$1"
35 fi
36
37 COMMITS=$(git log --pretty=%H $RANGE)
38
39 set -e
40
41 for commit in $COMMITS; do
42 `dirname $0`/check-commit.sh $commit
43 done