-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-ops.bash
More file actions
65 lines (56 loc) · 1.81 KB
/
git-ops.bash
File metadata and controls
65 lines (56 loc) · 1.81 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
#!/bin/bash
source /home/webdev/.bashrc
read -p "Please input the deployment name you are moving like aimless-abbott: " deployment
# deployment=complaining-colborn
# deplyment=$1
# do not alter this list or the order of it
declare -a repos=(
"web"
"gems"
"gmml"
"md"
)
# do not alter this list or the order of it
declare -a directories=(
"/website/DOCKER/GLYCAM/$deployment"
"/website/DOCKER/GLYCAM/$deployment/V_2/Web_Programs/gems"
"/website/DOCKER/GLYCAM/$deployment/V_2/Web_Programs/gems/gmml"
"/website/DOCKER/GLYCAM/$deployment/V_2/Web_Programs/gems/External/MD_Utils"
)
# Move pre-push hook to pre-push.inactive in each directory
for dir in "${directories[@]}"; do
cd "$dir" && mv .git/hooks/pre-push .git/hooks/pre-push.inactive
echo "Moved .git/hooks/pre-push to .git/hooks/pre-push.inactive in $dir"
done
read -p "Are you moving to dev or actual: " movingto
# movingto=dev
# movingto=$2
# Check if it's a dry run or not
# read -p "Is this a dry run? (yes/no): " dry_run
dry_run=no
for ((i=0; i<${#directories[@]}; i++))
do
directory="${directories[$i]}"
repo="${repos[$i]}"
# echo $repo
cd "$directory" || exit 1
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p' | grep -o "test")
if [ "$branch" = "test" ]; then
if [ "$movingto" = "dev" ]; then
new_branch="$repo-$movingto"
else
new_branch="$movingto"
fi
git tag -a $deployment -m "Script setting deployment tag"
git push origin $deployment
git remote set-branches --add origin ${movingto}
git fetch origin
git checkout $new_branch
git rebase $deployment
git push $new_branch
echo $new_branch
else
echo "Git branch is not on test. Please change branch to test."
fi
cd - >/dev/null || exit 1
done