-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgpoc
More file actions
executable file
·40 lines (38 loc) · 1.24 KB
/
gpoc
File metadata and controls
executable file
·40 lines (38 loc) · 1.24 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
#!/bin/bash
## git push current branch name
gpoc(){
# Prevent push to "master" option
safe_guard="true"
current_branch="$(git symbolic-ref --short HEAD)"
echo "Current branch is ${current_branch}"
push_dest="$(git remote show origin | grep "mkanenobu")"
push_name="${current_branch}"
if [ -n "${following_branch}" ]; then
push_name="${following_branch}"
fi
# 自分のリポジトリならプッシュ先関係なくでもプッシュ
if [ -n "${push_dest}" ]; then
echo "Push to ${push_name}"
git push origin "${push_name}"
else
# 自分のリポジトリではなく、プッシュ先の名前にmaster,release,developが含まれるときは確認
if [[ "${push_name}" =~ (master|release|develop) ]]; then
if [ "${safe_guard}" == "true" ]; then
echo "Don't allow to push to master, release, develop"
exit 1
else
echo "You are going to push to ${push_name}"
read -rp "Are you sure? (type 'Agree'):" confirm
if [ "${confirm}" == "Agree" ]; then
echo "Push to ${push_name}"
git push origin "${push_name}"
else
echo "If you want to push, Type 'Agree'"
fi
fi
else
git push origin "${push_name}"
fi
fi
}
gpoc