-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclose_branch.sh
49 lines (39 loc) · 1009 Bytes
/
close_branch.sh
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
#!/bin/bash
# usage: close_branch
# Default root path
root_path="~/work"
# community master repo
community_master_path=~/work/community-master
# enterprise master repo
enterprise_master_path=~/work/enterprise-master
# Branch name
branch_name=""
if [ $# -ne 1 ]
then
echo -e "Expected folder architecture:
~
└── work
├── community_master
├── enterprise_master
├── community_branch_to_close
└── enterprise_branch_to_close
Usage: bash close_branch.sh <branch_name>
Example: bash close_branch.sh 18.0-opw-420_my_old_branch-quad
\033[0;31m
/!\\ Use with caution as this is irreversible /!\\"
exit 0
fi
branch_name=$1
read -p "Remove branch '$branch_name'?" -n 1 -r
echo ""
if [[ $REPLY = "" ]];
then
cd $community_master_path
git worktree remove ../community_$branch_name --force
git branch -D $branch_name
cd $enterprise_master_path
git worktree remove ../enterprise_$branch_name --force
git branch -D $branch_name
echo "
Finished cleanup!"
fi