File: check-code-style

package info (click to toggle)
epiphany-browser 49.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,032 kB
  • sloc: ansic: 77,370; javascript: 7,062; xml: 720; python: 190; sh: 77; makefile: 14
file content (60 lines) | stat: -rwxr-xr-x 1,484 bytes parent folder | download
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
59
60
#!/bin/bash

SOURCE_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd .. && pwd )"

UNCRUSTIFY=$(command -v uncrustify)
if [ -z "$UNCRUSTIFY" ];
then
    echo "Uncrustify is not installed on your system."
    exit 1
fi

LINEUP_PARAMETERS="$SOURCE_ROOT/data/lineup-parameters"
if [ ! -x "$LINEUP_PARAMETERS" ];
then
    echo "lineup-parameters script is missing"
    exit 1
fi

# create a filename to store our generated patch
prefix="epiphany-ccs"
suffix="$(date +%C%y-%m-%d_%Hh%Mm%Ss)"
patch="/tmp/$prefix-$suffix.patch"

# clean up old patches
rm -f /tmp/$prefix*.patch

pushd "$SOURCE_ROOT" || exit
for DIR in embed lib src tests
do
  # Aligning prototypes is not working yet, so avoid headers
  find "$DIR" -name "*.c" ! -path "*/contrib/*" -type f -print0 | while IFS= read -r -d '' FILE;
  do
    "$UNCRUSTIFY" -q -c "data/uncrustify.cfg" -f "$FILE" -o "$FILE".uncrustify
    "$LINEUP_PARAMETERS" "$FILE".uncrustify > "$FILE.temp" && mv "$FILE".temp "$FILE".uncrustify
    diff -urN "$FILE" "$FILE".uncrustify | \
        sed -e "1s|--- |--- a/|" -e "2s|+++ |+++ b/|" >> "$patch"
    rm "$FILE".uncrustify
  done
done
popd || exit

if [ ! -s "$patch" ] ; then
  printf "** Commit is valid. \\o/\n"
  rm -f "$patch"
  exit 0
fi

printf "** Commit does not comply to the correct style :(\n\n"

if hash colordiff 2> /dev/null; then
  colordiff < "$patch"
else
  cat "$patch"
fi

printf "\n"
printf "You can apply these changed with: git apply %s\n" "$patch"
printf "\n"

exit 1