forked from nvie/gitflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-flow-hotfix
executable file
·111 lines (97 loc) · 2.67 KB
/
git-flow-hotfix
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#
# gitflow -- A collection of Git wrapper scripts to provide high-level
# repository operations for Vincent Driessen's branching model:
#
# Original blog post presenting this model is found at:
# http://nvie.com/archives/323
#
# Feel free to contribute to this project at:
# http://github.com/nvie/gitflow
#
# Copyright (c) 2010 by Vincent Driessen
# Copyright (c) 2010 by Benedikt Böhm
#
usage() {
echo "usage: git flow start hotfix <version> [<base>]"
echo " git flow finish hotfix <version> [<base>]"
# TODO
#echo ""
#echo "options:"
#echo "--option Explanation"
#echo ""
#echo "start-only options:"
#echo "--option Explanation"
#echo ""
#echo "finish-only options:"
#echo "--push Push to the origin repo when finished"
}
parse_args() {
VERSION="$1"
BASE="${2:-$MASTER_BRANCH}"
if [ "$VERSION" = "" ]; then
echo "Missing argument <version>."
usage
exit 1
fi
PREFIX=$(git config --get gitflow.prefix.hotfix || echo hotfix/)
BRANCH=$PREFIX$VERSION
}
cmd_help() {
usage
exit 0
}
cmd_start() {
parse_args "$@"
# sanity checks
gitflow_check_clean_working_tree
git fetch $ORIGIN
gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH
gitflow_require_branch_absent $BRANCH
# create branch
git checkout -b $BRANCH $BASE
echo
echo "Summary of actions:"
echo "- A new branch '$BRANCH' was created, based on '$BASE'"
echo "- You are now on branch '$BRANCH'"
echo
echo "Follow-up actions:"
echo "- Bump the version number now!"
echo "- Start committing your hot fixes"
echo "- When done, run:"
echo
echo " git flow finish hotfix '$HOTFIX_BRANCH'"
echo
}
cmd_finish() {
parse_args "$@"
# sanity checks
gitflow_check_clean_working_tree
git fetch $ORIGIN $MASTER_BRANCH
git fetch $ORIGIN $DEVELOP_BRANCH
gitflow_require_branches_equal $MASTER_BRANCH $ORIGIN/$MASTER_BRANCH
gitflow_require_branches_equal $DEVELOP_BRANCH $ORIGIN/$DEVELOP_BRANCH
# merge into BASE
git checkout $BASE
git merge --no-ff $BRANCH
git tag v$VERSION
# merge into develop if we fixed a master issue
# TODO: merge into support branch
if [ "$BASE" = "$MASTER_BRANCH" ]; then
git checkout $DEVELOP_BRANCH
git merge --no-ff $BRANCH
fi
# delete branch
git branch -d $BRANCH
# TODO: Implement an optional push to master
# git push origin develop; git push origin master; git push --tags origin
echo
echo "Summary of actions:"
echo "- Latest objects have been fetched from '$ORIGIN'"
echo "- Hotfix branch has been merged into '$BASE'"
echo "- The hotfix was tagged 'v$VERSION'"
if [ "$BASE" = "$MASTER_BRANCH" ]; then
echo "- Hotfix branch has been back-merged into '$DEVELOP_BRANCH'"
fi
echo "- Hotfix branch '$BRANCH' has been deleted"
echo
}