blob: f85f2ac8c685276e94b7f16e179014100a9fafbe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#!/bin/bash
BASELINE_BRANCH="baseline"
CI_CONFIG=$(ci-config)
FILE=$1
LINE=$2
ERROR=$3
# Generated files in the compilation directory won't be found
# in the source tree, so instead of spitting an error, just ignore
# the error/warning when the file is not found.
if [ ! -f $FILE ]; then
exit 0
fi
COMMIT_ID=$(git annotate -L$LINE,$LINE $FILE | awk '{ print $1 }')
if [ "$COMMIT_ID" == "" ]; then
exit 1
fi
BRANCH=$(git branch -r --contains $COMMIT_ID)
FOUND=0
#
# If the commit id belongs to the baseline branch, then it is common
# to all branches and we can just ignore this commit
#
echo $BRANCH | grep -q $BASELINE_BRANCH
if [ $? -eq 0 ]; then
exit 0
fi
while read LINE; do
# ignore commented lines
echo $LINE | egrep -q '(^#|^\s*$|^\s*\t*#)' && continue
REMOTE_NAME=$(echo $LINE | awk '{ print $1 }')
REMOTE_BRANCH=$(echo $LINE | awk '{print $3}')
if [ "$REMOTE_NAME/$REMOTE_BRANCH" == $BRANCH ]; then
FOUND=1
break
fi
done < $CI_CONFIG
if [ $FOUND -eq 1 ]; then
echo
echo "The error/warning: $ERROR"
echo "... was introduced by commit:"
echo
git log -1 --pretty=medium $COMMIT_ID
echo
exit 1
fi
|