generated from linz/template-python-hello-world
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset-dev-env.bash
executable file
·95 lines (82 loc) · 1.74 KB
/
reset-dev-env.bash
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
#!/usr/bin/env bash
set -o errexit -o noclobber -o nounset -o pipefail
usage() {
cat >&2 << 'EOF'
./reset-dev-env.bash --all
./reset-dev-env.bash [--delete] [--hooks] [--python]
./reset-dev-env.bash --help
`--all` implies `--delete --hooks --python`.
EOF
}
arguments="$(getopt --options '' \
--longoptions all,delete,help,hooks,python --name "$0" -- "$@")"
eval set -- "$arguments"
unset arguments
while true
do
case "$1" in
--all)
delete=1
hooks=1
python=1
shift
;;
--delete)
delete=1
shift
;;
--help)
usage
exit
;;
--hooks)
hooks=1
shift
;;
--python)
python=1
shift
;;
--)
shift
break
;;
*)
printf 'Not implemented: %q\n' "$1" >&2
exit 1
;;
esac
done
if [[ -z "${hooks-}" ]] \
&& [[ -z "${python-}" ]]
then
usage
exit 1
fi
cd "$(dirname "${BASH_SOURCE[0]}")"
if [[ -n "${delete-}" ]]
then
echo "Cleaning Git repository"
git clean -d --exclude='.idea' --force -x
fi
if [[ -n "${python-}" ]]
then
if [[ -n "${delete-}" ]]
then
echo "Removing Python packages"
rm --force --recursive ./.venv
fi
echo "Installing Python packages"
poetry env use "$(cat .python-version)"
poetry install \
--no-root \
--sync
fi
if [[ -n "${hooks-}" ]]
then
echo "Installing Git hooks"
# shellcheck source=/dev/null
. .venv/bin/activate
pre-commit install --hook-type=commit-msg --overwrite
pre-commit install --hook-type=pre-commit --overwrite
fi