forked from oracle/adaptivemm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiff.sh
executable file
·123 lines (107 loc) · 1.7 KB
/
diff.sh
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/bash
ADAPTIVED=0
ADAPTIVEMM=0
ADAPTIVEMM_FILES=(
"adaptivemmd.8"
"adaptivemmd.c"
"adaptivemmd.cfg"
"adaptivemmd.service"
"adaptivemm.spec"
"build_spec.yaml"
"CONTRIBUTING.md"
"LICENSE.txt"
"Makefile"
"predict.c"
"predict.h"
"README.md"
"SECURITY.md"
)
RETURN_ADAPTIVED=false
START_HASH="origin/master"
END_HASH="HEAD"
VERBOSE=false
PRINTED_FILES=false
while getopts demsv option
do
case "${option}"
in
d) RETURN_ADAPTIVED=true;;
e)
eval nextopt=\${$OPTIND}
if [[ -n $nextopt && $nextopt != -* ]] ; then
OPTIND=$((OPTIND + 1))
END_HASH=$nextopt
fi
;;
m) RETURN_ADAPTIVED=false;;
s)
eval nextopt=\${$OPTIND}
if [[ -n $nextopt && $nextopt != -* ]] ; then
OPTIND=$((OPTIND + 1))
START_HASH=$nextopt
fi
;;
v) VERBOSE=true;;
esac
done
if [[ $RETURN_ADAPTIVED == true ]];
then
DIR=adaptived/
else
DIR=.
fi
CMD="git diff --name-only $START_HASH..$END_HASH $DIR"
FILES=$($CMD)
if [[ $VERBOSE == true ]];
then
echo "$CMD"
echo "-------------------------------"
fi
for FILE in $FILES;
do
if [[ $FILE == adaptived/* ]];
then
ADAPTIVED=1
if [[ $VERBOSE == true ]];
then
echo "$FILE"
PRINTED_FILES=true
fi
fi
for AMM_FILE in ${ADAPTIVEMM_FILES[@]};
do
if [[ $FILE == $AMM_FILE ]];
then
ADAPTIVEMM=1
if [[ $VERBOSE == true ]];
then
echo "$FILE"
PRINTED_FILES=true
fi
fi
done
done
if [[ $VERBOSE == true ]];
then
if [[ $PRINTED_FILES == false ]];
then
echo "No files were modified"
fi
fi
if [[ $RETURN_ADAPTIVED == true ]];
then
if [[ $VERBOSE == true ]];
then
echo "-------------------------------"
else
echo $ADAPTIVED
fi
else
if [[ $VERBOSE == true ]];
then
echo "-------------------------------"
else
echo $ADAPTIVEMM
fi
fi
exit 0