|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# |
| 4 | +# This file is a hack to suppress warnings from Roave BC check |
| 5 | +# |
| 6 | + |
| 7 | +echo "Running..." |
| 8 | + |
| 9 | +# Capture output to variable |
| 10 | +OUTPUT=$(./vendor/bin/roave-backward-compatibility-check 2>&1) |
| 11 | +echo "$OUTPUT" |
| 12 | + |
| 13 | +# Remove rows we want to suppress |
| 14 | +OUTPUT=`echo "$OUTPUT" | sed '/The return type of Github\\\HttpClient\\\Plugin\\\Authentication#handleRequest() changed from no type to Http\\\Promise\\\Promise/'d` |
| 15 | +OUTPUT=`echo "$OUTPUT" | sed '/The return type of Github\\\HttpClient\\\Plugin\\\Authentication#handleRequest() changed from no type to Http\\\Promise\\\Promise/'d` |
| 16 | +OUTPUT=`echo "$OUTPUT" | sed '/The parameter $exception of Github\\\HttpClient\\\Plugin\\\History#addFailure() changed from Http\\\Client\\\Exception to a non-contravariant Psr\\\Http\\\Client\\\ClientExceptionInterface/'d` |
| 17 | +OUTPUT=`echo "$OUTPUT" | sed '/The parameter $exception of Github\\\HttpClient\\\Plugin\\\History#addFailure() changed from Http\\\Client\\\Exception to Psr\\\Http\\\Client\\\ClientExceptionInterface/'d` |
| 18 | +OUTPUT=`echo "$OUTPUT" | sed '/The return type of Github\\\HttpClient\\\Plugin\\\PathPrepend#handleRequest() changed from no type to Http\\\Promise\\\Promise/'d` |
| 19 | +OUTPUT=`echo "$OUTPUT" | sed '/The return type of Github\\\HttpClient\\\Plugin\\\GithubExceptionThrower#handleRequest() changed from no type to Http\\\Promise\\\Promise/'d` |
| 20 | +OUTPUT=`echo "$OUTPUT" | sed '/Method getMessage() was added to interface Github\\\Exception\\\ExceptionInterface/'d` |
| 21 | +OUTPUT=`echo "$OUTPUT" | sed '/Method getCode() was added to interface Github\\\Exception\\\ExceptionInterface/'d` |
| 22 | +OUTPUT=`echo "$OUTPUT" | sed '/Method getFile() was added to interface Github\\\Exception\\\ExceptionInterface/'d` |
| 23 | +OUTPUT=`echo "$OUTPUT" | sed '/Method getLine() was added to interface Github\\\Exception\\\ExceptionInterface/'d` |
| 24 | +OUTPUT=`echo "$OUTPUT" | sed '/Method getTrace() was added to interface Github\\\Exception\\\ExceptionInterface/'d` |
| 25 | +OUTPUT=`echo "$OUTPUT" | sed '/Method getPrevious() was added to interface Github\\\Exception\\\ExceptionInterface/'d` |
| 26 | +OUTPUT=`echo "$OUTPUT" | sed '/Method getTraceAsString() was added to interface Github\\\Exception\\\ExceptionInterface/'d` |
| 27 | +OUTPUT=`echo "$OUTPUT" | sed '/Method __toString() was added to interface Github\\\Exception\\\ExceptionInterface/'d` |
| 28 | + |
| 29 | +# Number of rows we found with "[BC]" in them |
| 30 | +BC_BREAKS=`echo "$OUTPUT" | grep -o '\[BC\]' | wc -l | awk '{ print $1 }'` |
| 31 | + |
| 32 | +# The last row of the output is "X backwards-incompatible changes detected". Find X. |
| 33 | +STATED_BREAKS=`echo "$OUTPUT" | tail -n 1 | awk -F' ' '{ print $1 }'` |
| 34 | + |
| 35 | +# If |
| 36 | +# We found "[BC]" in the command output after we removed suppressed lines |
| 37 | +# OR |
| 38 | +# We have suppressed X number of BC breaks. If $STATED_BREAKS is larger than X |
| 39 | +# THEN |
| 40 | +# exit 1 |
| 41 | + |
| 42 | +if [ $BC_BREAKS -gt 0 ] || [ $STATED_BREAKS -gt 13 ]; then |
| 43 | + echo "EXIT 1" |
| 44 | + exit 1 |
| 45 | +fi |
| 46 | + |
| 47 | +# No BC breaks found |
| 48 | +echo "EXIT 0" |
| 49 | +exit 0 |
0 commit comments