forked from 4Applepen/Userge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.sh
97 lines (79 loc) · 2.13 KB
/
utils.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
#!/bin/bash
#
# Copyright (C) 2020 by UsergeTeam@Github, < https://github.com/UsergeTeam >.
#
# This file is part of < https://github.com/UsergeTeam/Userge > project,
# and is released under the "GNU v3.0 License Agreement".
# Please see < https://github.com/uaudith/Userge/blob/master/LICENSE >
#
# All rights reserved.
declare -r pVer=$(sed -E 's/\w+ ([2-3])\.([0-9]+)\.([0-9]+)/\1.\2.\3/g' < <(python3.8 -V))
log() {
local text="$*"
test ${#text} -gt 0 && test ${text::1} != '~' \
&& echo -e "[$(date +'%d-%b-%y %H:%M:%S') - INFO] - init - ${text#\~}"
}
quit() {
local err="\t:: ERROR :: $1\nExiting With SIGTERM (143) ..."
if (( getMessageCount )); then
replyLastMessage "$err"
else
log "$err"
fi
exit 143
}
runPythonCode() {
python${pVer%.*} -c "$1"
}
runPythonModule() {
python${pVer%.*} -m "$@"
}
gitInit() {
git init &> /dev/null
}
gitClone() {
git clone "$@" &> /dev/null
}
remoteIsExist() {
grep -q $1 < <(git remote)
}
addHeroku() {
git remote add heroku $HEROKU_GIT_URL
}
addUpstream() {
git remote add $UPSTREAM_REMOTE ${UPSTREAM_REPO%.git}.git
}
updateUpstream() {
git remote rm $UPSTREAM_REMOTE && addUpstream
}
fetchUpstream() {
git fetch $UPSTREAM_REMOTE &> /dev/null
}
fetchBranches() {
local r_bs l_bs
r_bs=$(grep -oP '(?<=refs/heads/)\w+' < <(git ls-remote --heads $UPSTREAM_REMOTE))
l_bs=$(grep -oP '\w+' < <(git branch))
for r_b in $r_bs; do
[[ $l_bs =~ $r_b ]] || git branch $r_b $UPSTREAM_REMOTE/$r_b &> /dev/null
done
}
upgradePip() {
pip3 install -U pip &> /dev/null
}
installReq() {
pip3 install -r $1/requirements.txt &> /dev/null
}
printLine() {
echo '->- ->- ->- ->- ->- ->- ->- --- -<- -<- -<- -<- -<- -<- -<-'
}
printLogo() {
printLine
echo '
________ __ __ ______
/_ __/ /_ ___ / / / /_______ _____/ ____/__
/ / / __ \/ _ \ / / / / ___/ _ \/ ___/ / __/ _ \
/ / / / / / __/ / /_/ (__ ) __/ / / /_/ / __/
/_/ /_/ /_/\___/ \____/____/\___/_/ \____/\___/
'
printLine
}