-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_old
More file actions
executable file
·140 lines (115 loc) · 2.92 KB
/
update_old
File metadata and controls
executable file
·140 lines (115 loc) · 2.92 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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
FILES=($(ls -d */))
parent_dir=$(pwd)
#Terminal colours
cyan="\\e[36m"
green="\\e[92m"
red="\\e[91m"
purple="\\e[95m"
yellow="\\e[33m"
blue="\\e[34m"
bold="\\e[01m"
ul="\\e[4m"
blink="\\e[5m"
invert="\\e[7m"
reset="\\e[0m"
#Flags
gradle=false
maven=false
changeBack=true
forceUpdate=false
stayOnBranch=false
#Array of projects to avoid with integration
avoid=("datasys-ares-commons/", "datasys-commons/", "datasys-ares-acceptance-tests/", "venv/")
#Options passed to script
while getopts 'gmcfs' flag; do
case "${flag}" in
g) gradle=true ;;
m) maven=true ;;
c) changeBack=false ;;
f) forceUpdate=true ;;
s) stayOnBranch=true ;;
*) error "Unexpected option ${flag}" ;;
esac
done
run_gradle() {
if "${gradle}" == true;
then
if [[ " ${avoid[@]} " =~ " ${folder} " ]];
then
printf "Applying ${green}Gradle${reset} clean build ${red}without unit test${reset} to ${cyan}${folder}${reset}\n"
./gradlew clean build -x test
else
printf "Applying ${green}Gradle${reset} clean build ${red}without unit and ${bold}feature tests${reset} to ${cyan}${folder}${reset}\n"
./gradlew clean build -x test -x integration
fi
fi
}
run_maven() {
if "${maven}" == true;
then
if [[ " ${avoid[@]} " =~ " ${i} " ]];
then
printf "${cyan}${folder}${red} does not contain a maven project.\n"
else
printf "Applying ${green}maven${reset} build to ${cyan}${folder}${reset}\n"
mvn -U clean install -DskipTests
fi
fi
}
brancher() {
printf "${bold}${blue}Current branch: ${reset}${bold}$1${reset}\n"
if [ "${branch}" != "master" ] && [ "${stayOnBranch}" == false ];
then
printf "Changing ${cyan}$2${reset} from ${green}$1${reset} branch to ${bold}${purple}master${reset}\n"
git checkout master
false
else
printf "${bold}Staying on the branch:${reset} $1\n"
true
fi
}
check_git() {
git remote update
localGit="$(git rev-parse @)"
remoteGit="$(git rev-parse origin/$1)"
printf "${purple}Local git commit:${reset} ${localGit}\n${purple}Remote git commit:${reset} ${remoteGit} - $1\n"
if [[ "${localGit}" != "${remoteGit}" ]];
then
true
else
false
fi
}
update_folder(){
check_git $1
gity="$?"
if [[ "${gity}" == 0 ]] || [ "${forceUpdate}" == true ];
then
printf "Pulling down latest HEAD for ${cyan}${folder}${reset}\n"
git pull origin master
else
printf "${yellow}${folder} is up-to-date\n"
fi
run_gradle
run_maven
}
printf "${bold}Updating all the folders inside of ${cyan}${parent_dir}${reset}..."
for folder in "${FILES[@]}"
do
printf "\n\n"
printf "${green}${folder}${reset}\n"
cd $folder
git stash
branch=$(git rev-parse --abbrev-ref HEAD)
brancher $branch $folder
change="$?"
update_folder "${branch}"
if [ "${changeBack}" ];
then
printf "Returning ${cyan}${folder}${reset} to ${green}${branch}${reset} branch\n"
git checkout "${branch}"
fi
cd $parent_dir
done;
printf "\n${bold}${green}Completed updating all subfolders... get working!\n"