-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathgg-trials-bad-close
executable file
·40 lines (33 loc) · 1.26 KB
/
gg-trials-bad-close
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
installPath=/usr/local/bin/gg
source $installPath/gg-functions
testClear
get_currentBranch
get_currentBranchParent
get_isTrialBranch
if [[ -z $isTrialBranch ]]; then
printf "\nYou must be in one trial branch\n\n"
git status
exit 1
fi
get_isParentAlive
if [[ -z $isParentAlive ]]; then
printf "The trials' parent branch is missing, do the job manully\n"
fi
echo "You are in branch || $currentBranch ||"
printf "Do you want to close it like this?\n"
now=`date "+%Y-%m-%d-%H-%M-%S"`
printf "\tRecord the ref logs of this branch in .git/../.deletedTrailsBranchs and then\n"
gggttt;echo "git branch -D \"$currentBranch\""
echo "press ENTER to continue, press Ctrl+c to ESCAPE"
read temp
gitDir=$(git rev-parse --git-dir)/..
git checkout $currentBranchParent
echo "=================================================" >> $gitDir/.deletedTrailsBranchs
echo $currentBranch "deleted at" $now >> $gitDir/.deletedTrailsBranchs
echo
git log $currentBranchParent..$currentBranch >> $gitDir/.deletedTrailsBranchs
echo "press Enter to delete $currentBranch branch" \
&& echo "press Ctrl+c to ESCAPE" \
&& read temp && git branch -D $currentBranch \
&& git add $gitDir/.deletedTrailsBranchs&&git commit $gitDir/.deletedTrailsBranchs -m "bad close trial branch $currentBranch"