-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_projects
executable file
·56 lines (48 loc) · 1.6 KB
/
get_projects
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
#!/bin/bash
python_version="3.11"
org="stranded-in-python"
repos="movix-ugc movix-auth movix-sqlite-etl movix-etl movix-api movix-notification-api movix-notification-scheduler movix-notification-worker movix-admin movix-notification-etl movix-billing-api movix-subscription-api"
default_repos_folder="projects"
default_venv_folder=".venv"
default_requirements="requirements/local.txt"
default_main_branch="main"
default_remote="origin"
if [ ! $(which pre-commit) ]; then
npm install pre-commit --global
pre-commit install
fi
if [ ! -d "./${default_repos_folder}" ]; then
echo "Not found ${default_repos_folder} dir, creating..."
mkdir ${default_repos_folder}
fi
cd $default_repos_folder
for repo in $repos; do
if [ ! -d "./${repo}" ]; then
echo "Not found ${repo} repo, cloning..."
git clone [email protected]:$org/$repo.git
cd $repo
python${python_version} -m venv $default_venv_folder
source $default_venv_folder/bin/activate
pip install -r $default_requirements
# check if pre-commit is installed
if [ $(which pre-commit) ]; then
pre-commit install --hook-type pre-commit --hook-type pre-push --hook-type pre-merge-commit
fi
deactivate
cd ..
echo "Installed and configured ${repo}"
else
echo "Updating ${repo}..."
cd ${repo}
local_branch=$(git rev-parse --abbrev-ref HEAD)
git fetch
git stash
git checkout $default_main_branch
git pull $default_remote $default_main_branch
git co $local_branch
git stash pop
echo "Successfully updated ${repo}/${default_main_branch}. Local changed are in stash"
cd ..
fi
done
cd ..