-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpush
More file actions
executable file
·34 lines (30 loc) · 751 Bytes
/
push
File metadata and controls
executable file
·34 lines (30 loc) · 751 Bytes
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
#!/bin/bash
promptYes() {
while true; do
read -p "$1 :" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit 1;;
* ) echo "Please answer yes or no.";;
esac
done
}
branch=$(_g)
if [[ "$branch" == "dev" ]]; then
promptYes "Confirm pushing to dev. [Y or N]"
elif [[ "$branch" == "master" ]]; then
promptYes "Confirm pushing to master. [Y or N]"
elif [[ "$branch" == "main" ]]; then
promptYes "Confirm pushing to main. [Y or N]"
else
echo "Pushing to origin $branch..."
sleep 0.5 # Small amount of time to cancel with ^C
fi
resp=$(git push origin "$branch" 2>&1)
if [ "$?" != 0 ]; then
echo "$resp"
promptYes "Force push?"
git push origin "$branch" --force-with-lease
else
echo "$resp"
fi