| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | SOURCE_ROOT="$( cd "$( dirnamescip-shell system . . dirname. "${BASH_SOURCE[0]}" )" && cd .. && pwdscip-shell system . . pwd. )" |
| 4 | |
| 5 | UNCRUSTIFY=$(command -v uncrustify) |
| 6 | if [scip-shell system . . `[`. -z "$UNCRUSTIFY" ]; |
| 7 | then |
| 8 | echoscip-shell system . . echo. "Uncrustify is not installed on your system." |
| 9 | exit 1 |
| 10 | fi |
| 11 | |
| 12 | LINEUP_PARAMETERS="$SOURCE_ROOT/data/lineup-parameters" |
| 13 | if [scip-shell system . . `[`. ! -x "$LINEUP_PARAMETERS" ]; |
| 14 | then |
| 15 | echoscip-shell system . . echo. "lineup-parameters script is missing" |
| 16 | exit 1 |
| 17 | fi |
| 18 | |
| 19 | # create a filename to store our generated patch |
| 20 | prefix="libproxy-ccs" |
| 21 | suffix="$(datescip-shell system . . date. +%C%y-%m-%d_%Hh%Mm%Ss)" |
| 22 | patch="/tmp/$prefix-$suffix.patch" |
| 23 | |
| 24 | # clean up old patches |
| 25 | rmscip-shell system . . rm. -f /tmp/$prefix*.patch |
| 26 | |
| 27 | pushd $SOURCE_ROOT |
| 28 | for DIR in src |
| 29 | do |
| 30 | # Aligning prototypes is not working yet, so avoid headers |
| 31 | for FILE in $(findscip-shell system . . find. "$DIR" -name "*.c" ! -path "*/contrib/*") |
| 32 | do |
| 33 | "$UNCRUSTIFY" -q -c "data/uncrustify.cfg" -f "$FILE" -o "$FILE.uncrustify" |
| 34 | "$LINEUP_PARAMETERS" "$FILE.uncrustify" > "$FILE.temp" && mvscip-shell system . . mv. "$FILE.temp" "$FILE.uncrustify" |
| 35 | diffscip-shell system . . diff. -urN "$FILE" "$FILE.uncrustify" | \ |
| 36 | sed -e "1s|--- |--- a/|" -e "2s|+++ |+++ b/|" >> "$patch" |
| 37 | rmscip-shell system . . rm. "$FILE.uncrustify" |
| 38 | done |
| 39 | done |
| 40 | popd |
| 41 | |
| 42 | if [scip-shell system . . `[`. ! -s "$patch" ] ; then |
| 43 | printfscip-shell system . . printf. "** Commit is valid. \\o/\n" |
| 44 | rmscip-shell system . . rm. -f "$patch" |
| 45 | exit 0 |
| 46 | fi |
| 47 | |
| 48 | printfscip-shell system . . printf. "** Commit does not comply to the correct style :(\n\n" |
| 49 | |
| 50 | if hash colordiff 2> /dev/nullscip-shell filesystem . . `/dev/null`.; then |
| 51 | colordiff < $patch |
| 52 | else |
| 53 | catscip-shell system . . cat. "$patch" |
| 54 | fi |
| 55 | |
| 56 | printfscip-shell system . . printf. "\n" |
| 57 | printfscip-shell system . . printf. "You can apply these changed with: git apply $patch\n" |
| 58 | printfscip-shell system . . printf. "\n" |
| 59 | |
| 60 | exit 1 |