-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject.sh
More file actions
67 lines (63 loc) · 1.97 KB
/
project.sh
File metadata and controls
67 lines (63 loc) · 1.97 KB
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
#!/bin/bash
TICKET_FOLDER=$1
HOME_PATH=$2
[ -z $HOME_PATH ] && HOME_PATH=$(pwd)
PROJECT_PATH="$HOME_PATH/$TICKET_FOLDER"
## Color
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
## Check Inputs
[ $# -eq 0 ] && printf "No TICKET parameter provided, example: \n${YELLOW}./project.sh\n" && exit 0
mkdir -p $PROJECT_PATH
echo $PROJECT_PATH
# Default projects
PROJECT_LIST="$PROJECT_PATH/.projects"
# Check if the branches file exists
if [ ! -f "$PROJECT_LIST" ]; then
printf "\n${RED}Error: File $PROJECT_LIST does not exist.${NC}\n"
exit 1
fi
# Function to extract the repository name from a Git URL
extract_repo_name() {
local git_url="$1"
# Use basename to get the last part of the URL, then strip off the .git suffix
local repo_name=$(basename -s .git "$git_url")
echo "$repo_name"
}
#
printf "\n${GREEN}List of folders: ${NC}\n"
cd $PROJECT_PATH
ls -ls
#
# Add New Line
echo "" >> $PROJECT_LIST
printf "\n${GREEN}List the projects for each visited folder from the file: ${PROJECT_LIST}${NC}\n"
while IFS=' ' read -r git_url; do
if [[ -n "$git_url" ]]; then
folder_name=$(extract_repo_name "$git_url")
git clone $git_url $folder_name
fi
done < "$PROJECT_LIST"
cd $HOME_PATH
# Update branches
./branches/info.sh $TICKET_FOLDER
./branches/init.sh $TICKET_FOLDER
./branches/update.sh $TICKET_FOLDER
# Load submodules and update rights
while IFS=' ' read -r git_url; do
if [[ -n "$git_url" ]]; then
folder_name=$(extract_repo_name "$git_url")
BRANCH_FOLDER="$PROJECT_PATH/$folder_name"
[[ ! -d "$BRANCH_FOLDER" ]] && printf "${RED}${PROJECT_PATH}${NC}\n" && continue
printf "${YELLOW}$BRANCH_FOLDER ${NC}\n"
cd $BRANCH_FOLDER
#git submodule update --init --recursive --remote
chmod +x *.sh
chmod +x *.py
fi
done < "$PROJECT_LIST"
# The last one repo in .projects must be docker compose project
#printf "${YELLOW}Start docker environment${NC}\n"
#bash ../../docker_rebuild.sh