-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.sh
104 lines (81 loc) · 1.75 KB
/
functions.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
#!/bin/bash
MYFOLDER="$(dirname "$(realpath "$0")")"
source $MYFOLDER/colors.sh
cleanup_repo () {
if [[ ! ${V_REPO:-} ]]
then
echo -e "${RED}ERR Cannot cleanup, V_REPO is undefined!${NC}"
return 4
fi
if [[ ! ${V_PATH:-} ]]
then
echo -e "${RED}ERR Cannot cleanup ${V_REPO}, V_PATH is undefined!${NC}"
return 3
fi
if [[ ! -d ${V_PATH} ]]
then
echo -e "${RED}ERR Cannot cleanup ${V_PATH}, directory does not exist${NC}"
return 2
fi
echo -e "${GREEN}----- Cleaning ${V_PATH} from ${V_REPO}${NC}"
a_oldpath=$PWD
cd ${V_PATH}
git reset --hard
git clean -fxd :/
git checkout ${V_REPO}
cd ${a_oldpath}
}
pick_custom () {
COMMAND=""
if [[ ${V_QUERY:-} ]]
then
COMMAND="${COMMAND} -Q \"${V_QUERY}\""
fi
if [[ ${V_PATH:-} ]]
then
COMMAND="${COMMAND} -P ${V_PATH}"
echo -e "${GREEN}----- Patching ${V_PATH}${NC}"
fi
if [[ ${V_URI:-} ]]
then
COMMAND="${COMMAND} -g ${V_URI}"
fi
if [[ ${V_EXCLUDE:-} ]]
then
COMMAND="${COMMAND} --exclude \"${V_EXCLUDE}\""
fi
if [[ ! ${COMMAND:-} ]]
then
if [[ ${V_PSET:-} ]]
then
COMMAND="${COMMAND} ${V_PSET}"
else
echo -e "${YELLOW} Nothing to do, skipping${NC}"
return 1
fi
fi
bash -c "$MYFOLDER/repopick.py ${COMMAND}"
# do not clean up V_URI
V_QUERY=""
V_PATH=""
V_EXCLUDE=""
V_PSET=""
COMMAND=""
# do not clean up V_URI
unset V_QUERY
unset V_PATH
unset V_EXCLUDE
unset V_PSET
unset COMMAND
}
pick_repo () {
if [[ ! ${V_REPO:-} ]]
then
echo -e "${RED}ERR Nothing to do, V_REPO is empty${NC}"
return 6
fi
V_QUERY="NOT+label:Code-Review=-2+AND+NOT+label:Verified=-1+(status:open+project:${V_REPO}+branch:${BRANCH})"
pick_custom
V_REPO=""
unset V_REPO
}