blob: 8f5c4eefa715d270af580d9bc0e8af376ad904cf [file] [log] [blame]
Fabio Utzig5b989102017-09-04 16:27:51 -03001#!/bin/bash
2
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15MAIN_BRANCH=master
16
17# ignores last commit because travis/gh creates a merge commit
Fabio Utzig5101b0f2017-09-06 21:50:52 -030018commits=$(git log --format=%h ${MAIN_BRANCH}..HEAD | tail -n +2)
Fabio Utzig5b989102017-09-04 16:27:51 -030019
Fabio Utzig31180172017-09-06 21:38:14 -030020has_commits=false
Fabio Utzig5b989102017-09-04 16:27:51 -030021for sha in $commits; do
Fabio Utzig5b989102017-09-04 16:27:51 -030022 expected="Signed-off-by: $(git show -s --format="%an <%ae>" ${sha})"
Fabio Utzig31180172017-09-06 21:38:14 -030023 lines="$(git show -s --format=%B ${sha})"
24 found_sob=false
25 IFS=$'\n'
26 for line in ${lines}; do
27 stripped=$(echo $line | sed -e 's/^\s*//' | sed -e 's/\s*$//')
28 if [[ $stripped == ${expected} ]]; then
29 found_sob=true
30 break
31 fi
32 done
Fabio Utzig5b989102017-09-04 16:27:51 -030033
Fabio Utzig31180172017-09-06 21:38:14 -030034 if [[ ${found_sob} = false ]]; then
35 echo -e "No \"${expected}\" found in commit ${sha}"
Fabio Utzig5b989102017-09-04 16:27:51 -030036 exit 1
37 fi
Fabio Utzig31180172017-09-06 21:38:14 -030038
39 has_commits=true
Fabio Utzig5b989102017-09-04 16:27:51 -030040done
Fabio Utzig31180172017-09-06 21:38:14 -030041
42if [[ ${has_commits} = false ]]; then
43 echo "No commits found in this PR!"
44 exit 1
45fi