Merge: doc: fixed some typos and other misc. corrections
[nit.git] / misc / jenkins / checksignedoffby.sh
1 #!/bin/bash
2 # This file is part of NIT ( http://www.nitlanguage.org ).
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 # Check missing signed-off-by in commits
17 # Usage: checksignedoffby from to
18
19 set -e
20
21 from=${1:-origin/master}
22 to=${2:-HEAD}
23
24 err=0
25
26 cd `git rev-parse --show-toplevel`
27
28 echo "checksignedoffby $from (`git rev-parse "$from"`) .. $to (`git rev-parse "$to"`)"
29 for ref in `git rev-list --no-merges "$from".."$to"`; do
30 # What is the expected?
31 sig=`git --no-pager show -s --format='Signed-off-by: %an <%ae>' $ref`
32 # Do we found some signed-off-by?
33 git --no-pager show -s --format="%b" $ref | grep "^Signed-off-by:" > check_signedoff_list.out || {
34 echo ""
35 echo "Missing $sig for commit"
36 git --no-pager show -s --oneline $ref
37 err=1
38 continue
39 }
40 # Do we found the expected thing?
41 cat check_signedoff_list.out | grep -q "^$sig\$" && continue
42 echo ""
43 echo "Bad or missing Signed-off-by for commit"
44 git --no-pager show -s --oneline $ref
45 echo "Expected (from local git config):"
46 echo "$sig"
47 echo "Got:"
48 cat check_signedoff_list.out
49 err=1
50 done
51
52 rm check_signedoff_list.out 2> /dev/null || true
53
54 if test "$err" = 1; then
55 echo ""
56 echo "Please check that each commit contains a \`Signed-off-by:\` statement that matches the author's name and email."
57 echo "Note that existing commits should be amended; pushing new commit is not sufficient."
58 fi
59
60 exit $err