-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.sh
More file actions
executable file
·69 lines (52 loc) · 1.36 KB
/
check.sh
File metadata and controls
executable file
·69 lines (52 loc) · 1.36 KB
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
61
62
63
64
65
66
67
68
69
#!/usr/bin/env bash
##
## EPITECH PROJECT, 2023
## coconut
## File description:
## entrypoint script
##
if [ $# -ne 2 -a $# -ne 3 ]; then
echo "Usage: ./coding-style.sh <delivery_dir> <reports_dir> [copy_dest]"
exit 84
fi
DELIVERY_DIR=$1
REPORTS_DIR=$2
COPY_DEST=${3:-$DELIVERY_DIR}
if [ "$DELIVERY_DIR" = "/mnt/delivery" -a -z "$3" ]; then
mkdir -p /mnt/build
COPY_DEST=/mnt/build
fi
if [ ! -d "$DELIVERY_DIR" ]; then
echo "Error: $DELIVERY_DIR: No such directory"
exit 84
fi
if [ ! -d "$REPORTS_DIR" ]; then
echo "Error: $REPORTS_DIR: No such directory"
exit 84
fi
if [ ! -d "$COPY_DEST" ]; then
echo "Error: $COPY_DEST: No such directory"
exit 84
fi
cd "$COPY_DEST"
if [ "$DELIVERY_DIR" != "$COPY_DEST" ]; then
cp -a "$DELIVERY_DIR"/. .
fi
cd - >/dev/null
find "$COPY_DEST" \
\( -path "$COPY_DEST"/bonus \
-o -path "$COPY_DEST"/tests \) -prune \
-o \( -name '*.c' -o -name '*.h' \) -print0 \
> "$COPY_DEST/coding-style-files.log"
cd - >/dev/null
if [ -d rush-1-1 ]; then
bear -- gcc rush-1-*/*.c >/dev/null 2>&1
else
bear -- make re >/dev/null 2>&1
fi
cd - >/dev/null
REPORT="$REPORTS_DIR"/coding-style-reports.log.unsorted
cat "$COPY_DEST/coding-style-files.log" \
| xargs -0 -n 1 coconut -p "$COPY_DEST" -o "$REPORT"
sort -V "$REPORT" > "$REPORTS_DIR"/coding-style-reports.log
rm -f "$REPORT"