-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest0.bash
More file actions
32 lines (25 loc) · 874 Bytes
/
test0.bash
File metadata and controls
32 lines (25 loc) · 874 Bytes
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
#!/usr/bin/env bash
NEWSCORES=()
OLDSCORES=()
FILENAMES=`git diff --name-only --diff-filter=M main src | grep ".*.py"`
EXITCODE=0
INDEXABLEFILENAMES=()
touch tempfile.py
for FN in ${FILENAMES[@]}; do
INDEXABLEFILENAMES+=( $FN )
done
for FN in ${FILENAMES[@]}; do
NEWSCORES+=( `python3 -m pylint $FN | sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p'` )
done
for FN in ${FILENAMES[@]}; do
git show origin/$CI_DEFAULT_BRANCH:${FN} > tempfile.py
OLDSCORES+=( `python3 -m pylint tempfile.py | sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p'` )
done
for I in ${!NEWSCORES[@]}; do
if `python3 -c "exit(0 if ${NEWSCORES[I]} < ${OLDSCORES[I]} else 1)"`; then
echo "New score lower than old in file ${INDEXABLEFILENAMES[I]}. New score: ${NEWSCORES[I]} Old score: ${OLDSCORES[I]}"
EXITCODE=1
fi
done
rm tempfile.py
exit $EXITCODE