aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/merge-check.sh
blob: 9e0d5e1e7575f37c9510043c150618dd7fac3c37 (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
#!/bin/bash
SINCE=$1
UNTIL=$2

if [ "$SINCE" = "" ] || [ "$UNTIL" = "" ]
then
	echo "Usage: $0 <since> <until>"
	exit 3
fi

testname="merge check for `pwd|sed "s/.*\///"`"
echo "##teamcity[testStarted name='$testname' captureStandardOutput='true']"

command="git --no-pager log --no-color $SINCE..$UNTIL"
# TODO Why do I get whitespace in the beginning of the wc output?
change_count=`$command --oneline|wc -l|tr -d ' '`

if [ "$change_count" = "0" ]
then
	echo "No unmerged commits"
else 
	command="$command --format=short"
	message="There are $change_count commits in $UNTIL that are missing from $SINCE"
	echo $message
	echo ""
	$command
	# Escape []|' and newline with | to make teamcity happy
	details=`$command|sed "s/[]['\|]/|&/g"|perl -p -e 's/\n/|n/'`
	echo "##teamcity[testFailed name='$testname' message='$message' details='|n$details']"
fi

echo "##teamcity[testFinished name='$testname']"

# Give non-ok exit status
if [ "$change_count" != "0" ]
then
	exit 1
fi