Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 1 | # |
Vincent Driessen | 6c2d30b | 2010-01-26 22:18:36 +0100 | [diff] [blame] | 2 | # git-flow -- A collection of Git extensions to provide high-level |
| 3 | # repository operations for Vincent Driessen's branching model. |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 4 | # |
| 5 | # Original blog post presenting this model is found at: |
Vincent Driessen | ddb350b | 2010-07-09 09:42:09 +0200 | [diff] [blame] | 6 | # http://nvie.com/git-model |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 7 | # |
| 8 | # Feel free to contribute to this project at: |
| 9 | # http://github.com/nvie/gitflow |
| 10 | # |
Vincent Driessen | d72acba | 2010-04-04 16:10:17 +0200 | [diff] [blame] | 11 | # Copyright 2010 Vincent Driessen. All rights reserved. |
| 12 | # |
| 13 | # Redistribution and use in source and binary forms, with or without |
| 14 | # modification, are permitted provided that the following conditions are met: |
| 15 | # |
| 16 | # 1. Redistributions of source code must retain the above copyright notice, |
| 17 | # this list of conditions and the following disclaimer. |
| 18 | # |
| 19 | # 2. Redistributions in binary form must reproduce the above copyright |
| 20 | # notice, this list of conditions and the following disclaimer in the |
| 21 | # documentation and/or other materials provided with the distribution. |
| 22 | # |
| 23 | # THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR |
| 24 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 25 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 26 | # EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
| 27 | # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 28 | # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 29 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 30 | # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
| 31 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
| 32 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 33 | # |
| 34 | # The views and conclusions contained in the software and documentation are |
| 35 | # those of the authors and should not be interpreted as representing official |
| 36 | # policies, either expressed or implied, of Vincent Driessen. |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 37 | # |
| 38 | |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 39 | require_git_repo |
| 40 | require_gitflow_initialized |
Vincent Driessen | d72e4ac | 2010-02-16 21:33:51 +0100 | [diff] [blame] | 41 | gitflow_load_settings |
Nowell Strite | ff275fa | 2010-09-22 13:19:30 -0400 | [diff] [blame] | 42 | VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`") |
Vincent Driessen | c1598bf | 2010-02-20 16:52:48 +0100 | [diff] [blame] | 43 | PREFIX=$(git config --get gitflow.prefix.hotfix) |
Benedikt Böhm | 49dd62b | 2010-01-28 00:51:15 +0100 | [diff] [blame] | 44 | |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 45 | usage() { |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 46 | echo "usage: git flow hotfix [list] [-v]" |
Vincent Driessen | a2e4116 | 2010-02-24 01:37:07 +0100 | [diff] [blame] | 47 | echo " git flow hotfix start [-F] <version> [<base>]" |
Guillaume-Jean Herbiet | 8fee0c2 | 2010-10-04 11:35:10 +0200 | [diff] [blame] | 48 | echo " git flow hotfix finish [-Fsumpk] <version>" |
Peter Schröder | 0b324de | 2011-11-12 17:36:36 +0100 | [diff] [blame] | 49 | echo " git flow hotfix publish <version>" |
Vedang Manerikar | 37f7d14 | 2012-03-12 17:03:11 +0530 | [diff] [blame^] | 50 | echo " git flow hotfix track <version>" |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 51 | } |
| 52 | |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 53 | cmd_default() { |
Vincent Driessen | b866b01 | 2010-01-28 01:01:53 +0100 | [diff] [blame] | 54 | cmd_list "$@" |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 55 | } |
| 56 | |
Vincent Driessen | b866b01 | 2010-01-28 01:01:53 +0100 | [diff] [blame] | 57 | cmd_list() { |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 58 | DEFINE_boolean verbose false 'verbose (more) output' v |
| 59 | parse_args "$@" |
| 60 | |
Vincent Driessen | f46e290 | 2010-02-15 23:01:52 +0100 | [diff] [blame] | 61 | local hotfix_branches |
| 62 | local current_branch |
| 63 | local short_names |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 64 | hotfix_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX") |
Vincent Driessen | 27592dd | 2010-02-06 14:45:39 +0100 | [diff] [blame] | 65 | if [ -z "$hotfix_branches" ]; then |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 66 | warn "No hotfix branches exist." |
Randy Merrill | b681b45 | 2010-06-26 13:14:15 +0800 | [diff] [blame] | 67 | warn "" |
| 68 | warn "You can start a new hotfix branch:" |
| 69 | warn "" |
Stefan Schüßler | c4d0cb1 | 2010-12-02 18:55:06 +0800 | [diff] [blame] | 70 | warn " git flow hotfix start <version> [<base>]" |
Randy Merrill | 4de01f2 | 2010-06-26 13:19:06 +0800 | [diff] [blame] | 71 | warn "" |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 72 | exit 0 |
| 73 | fi |
Adam Gibbins | cf3da5a | 2010-08-22 19:13:34 +0100 | [diff] [blame] | 74 | current_branch=$(git branch --no-color | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g') |
Vincent Driessen | 6884523 | 2010-02-10 00:43:21 +0100 | [diff] [blame] | 75 | short_names=$(echo "$hotfix_branches" | sed "s ^$PREFIX g") |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 76 | |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 77 | # determine column width first |
Vincent Driessen | f46e290 | 2010-02-15 23:01:52 +0100 | [diff] [blame] | 78 | local width=0 |
| 79 | local branch |
Vincent Driessen | 27592dd | 2010-02-06 14:45:39 +0100 | [diff] [blame] | 80 | for branch in $short_names; do |
Vincent Driessen | f46e290 | 2010-02-15 23:01:52 +0100 | [diff] [blame] | 81 | local len=${#branch} |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 82 | width=$(max $width $len) |
| 83 | done |
Vincent Driessen | f46e290 | 2010-02-15 23:01:52 +0100 | [diff] [blame] | 84 | width=$(($width+3)) |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 85 | |
Vincent Driessen | f46e290 | 2010-02-15 23:01:52 +0100 | [diff] [blame] | 86 | local branch |
Vincent Driessen | 27592dd | 2010-02-06 14:45:39 +0100 | [diff] [blame] | 87 | for branch in $short_names; do |
Vincent Driessen | f46e290 | 2010-02-15 23:01:52 +0100 | [diff] [blame] | 88 | local fullname=$PREFIX$branch |
| 89 | local base=$(git merge-base "$fullname" "$MASTER_BRANCH") |
| 90 | local master_sha=$(git rev-parse "$MASTER_BRANCH") |
| 91 | local branch_sha=$(git rev-parse "$fullname") |
Vincent Driessen | 27592dd | 2010-02-06 14:45:39 +0100 | [diff] [blame] | 92 | if [ "$fullname" = "$current_branch" ]; then |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 93 | printf "* " |
| 94 | else |
| 95 | printf " " |
| 96 | fi |
| 97 | if flag verbose; then |
| 98 | printf "%-${width}s" "$branch" |
| 99 | if [ "$branch_sha" = "$master_sha" ]; then |
| 100 | printf "(no commits yet)" |
| 101 | else |
Vincent Driessen | f46e290 | 2010-02-15 23:01:52 +0100 | [diff] [blame] | 102 | local tagname=$(git name-rev --tags --no-undefined --name-only "$base") |
| 103 | local nicename |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 104 | if [ "$tagname" != "" ]; then |
Vincent Driessen | c5fcc01 | 2010-02-10 00:18:08 +0100 | [diff] [blame] | 105 | nicename=$tagname |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 106 | else |
Vincent Driessen | a4dd223 | 2010-02-10 00:34:59 +0100 | [diff] [blame] | 107 | nicename=$(git rev-parse --short "$base") |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 108 | fi |
| 109 | printf "(based on $nicename)" |
| 110 | fi |
| 111 | else |
| 112 | printf "%s" "$branch" |
| 113 | fi |
| 114 | echo |
| 115 | done |
Vincent Driessen | 186d2b5 | 2010-01-27 23:48:39 +0100 | [diff] [blame] | 116 | } |
| 117 | |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 118 | cmd_help() { |
| 119 | usage |
| 120 | exit 0 |
| 121 | } |
| 122 | |
Vincent Driessen | b866b01 | 2010-01-28 01:01:53 +0100 | [diff] [blame] | 123 | parse_args() { |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 124 | # parse options |
| 125 | FLAGS "$@" || exit $? |
| 126 | eval set -- "${FLAGS_ARGV}" |
| 127 | |
| 128 | # read arguments into global variables |
Vincent Driessen | f1eaa4e | 2011-02-03 16:11:25 +0100 | [diff] [blame] | 129 | VERSION=$1 |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 130 | BRANCH=$PREFIX$VERSION |
| 131 | } |
| 132 | |
| 133 | require_version_arg() { |
Vincent Driessen | b866b01 | 2010-01-28 01:01:53 +0100 | [diff] [blame] | 134 | if [ "$VERSION" = "" ]; then |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 135 | warn "Missing argument <version>" |
Vincent Driessen | b866b01 | 2010-01-28 01:01:53 +0100 | [diff] [blame] | 136 | usage |
| 137 | exit 1 |
| 138 | fi |
Vincent Driessen | b866b01 | 2010-01-28 01:01:53 +0100 | [diff] [blame] | 139 | } |
| 140 | |
Vincent Driessen | 010252a | 2010-02-04 10:31:29 +0100 | [diff] [blame] | 141 | require_base_is_on_master() { |
Adam Gibbins | cf3da5a | 2010-08-22 19:13:34 +0100 | [diff] [blame] | 142 | if ! git branch --no-color --contains "$BASE" 2>/dev/null \ |
Vincent Driessen | 010252a | 2010-02-04 10:31:29 +0100 | [diff] [blame] | 143 | | sed 's/[* ] //g' \ |
| 144 | | grep -q "^$MASTER_BRANCH\$"; then |
| 145 | die "fatal: Given base '$BASE' is not a valid commit on '$MASTER_BRANCH'." |
| 146 | fi |
| 147 | } |
| 148 | |
Vincent Driessen | 6d64d2c | 2010-02-16 06:41:13 +0100 | [diff] [blame] | 149 | require_no_existing_hotfix_branches() { |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 150 | local hotfix_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX") |
Vincent Driessen | 6d64d2c | 2010-02-16 06:41:13 +0100 | [diff] [blame] | 151 | local first_branch=$(echo ${hotfix_branches} | head -n1) |
| 152 | first_branch=${first_branch#$PREFIX} |
| 153 | [ -z "$hotfix_branches" ] || \ |
| 154 | die "There is an existing hotfix branch ($first_branch). Finish that one first." |
| 155 | } |
| 156 | |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 157 | cmd_start() { |
Vincent Driessen | de95e00 | 2010-07-22 15:11:17 +0200 | [diff] [blame] | 158 | DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 159 | parse_args "$@" |
Vincent Driessen | c5fcc01 | 2010-02-10 00:18:08 +0100 | [diff] [blame] | 160 | BASE=${2:-$MASTER_BRANCH} |
Vincent Driessen | 010252a | 2010-02-04 10:31:29 +0100 | [diff] [blame] | 161 | require_version_arg |
| 162 | require_base_is_on_master |
Vincent Driessen | 6d64d2c | 2010-02-16 06:41:13 +0100 | [diff] [blame] | 163 | require_no_existing_hotfix_branches |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 164 | |
| 165 | # sanity checks |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 166 | require_clean_working_tree |
| 167 | require_branch_absent "$BRANCH" |
| 168 | require_tag_absent "$VERSION_PREFIX$VERSION" |
Vincent Driessen | ca73caf | 2010-02-07 19:46:38 +0100 | [diff] [blame] | 169 | if flag fetch; then |
Vincent Driessen | a4dd223 | 2010-02-10 00:34:59 +0100 | [diff] [blame] | 170 | git fetch -q "$ORIGIN" "$MASTER_BRANCH" |
Vincent Driessen | 2acfffd | 2010-01-29 12:37:22 +0100 | [diff] [blame] | 171 | fi |
Konstantin Tjuterev | f6fcc4e | 2011-04-14 19:20:19 +0300 | [diff] [blame] | 172 | if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then |
Vincent Driessen | de95e00 | 2010-07-22 15:11:17 +0200 | [diff] [blame] | 173 | require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH" |
| 174 | fi |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 175 | |
| 176 | # create branch |
Vincent Driessen | a4dd223 | 2010-02-10 00:34:59 +0100 | [diff] [blame] | 177 | git checkout -b "$BRANCH" "$BASE" |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 178 | |
| 179 | echo |
| 180 | echo "Summary of actions:" |
| 181 | echo "- A new branch '$BRANCH' was created, based on '$BASE'" |
| 182 | echo "- You are now on branch '$BRANCH'" |
| 183 | echo |
| 184 | echo "Follow-up actions:" |
| 185 | echo "- Bump the version number now!" |
| 186 | echo "- Start committing your hot fixes" |
| 187 | echo "- When done, run:" |
| 188 | echo |
Vincent Driessen | 010252a | 2010-02-04 10:31:29 +0100 | [diff] [blame] | 189 | echo " git flow hotfix finish '$VERSION'" |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 190 | echo |
| 191 | } |
| 192 | |
Peter Schröder | 0b324de | 2011-11-12 17:36:36 +0100 | [diff] [blame] | 193 | cmd_publish() { |
| 194 | parse_args "$@" |
| 195 | require_version_arg |
| 196 | |
| 197 | # sanity checks |
| 198 | require_clean_working_tree |
| 199 | require_branch "$BRANCH" |
| 200 | git fetch -q "$ORIGIN" |
| 201 | require_branch_absent "$ORIGIN/$BRANCH" |
| 202 | |
| 203 | # create remote branch |
| 204 | git push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH" |
| 205 | git fetch -q "$ORIGIN" |
| 206 | |
| 207 | # configure remote tracking |
| 208 | git config "branch.$BRANCH.remote" "$ORIGIN" |
| 209 | git config "branch.$BRANCH.merge" "refs/heads/$BRANCH" |
| 210 | git checkout "$BRANCH" |
| 211 | |
| 212 | echo |
| 213 | echo "Summary of actions:" |
| 214 | echo "- A new remote branch '$BRANCH' was created" |
| 215 | echo "- The local branch '$BRANCH' was configured to track the remote branch" |
| 216 | echo "- You are now on branch '$BRANCH'" |
| 217 | echo |
| 218 | } |
| 219 | |
Vedang Manerikar | 37f7d14 | 2012-03-12 17:03:11 +0530 | [diff] [blame^] | 220 | cmd_track() { |
| 221 | parse_args "$@" |
| 222 | require_version_arg |
| 223 | |
| 224 | # sanity checks |
| 225 | require_clean_working_tree |
| 226 | require_branch_absent "$BRANCH" |
| 227 | git fetch -q "$ORIGIN" |
| 228 | require_branch "$ORIGIN/$BRANCH" |
| 229 | |
| 230 | # create tracking branch |
| 231 | git checkout -b "$BRANCH" "$ORIGIN/$BRANCH" |
| 232 | |
| 233 | echo |
| 234 | echo "Summary of actions:" |
| 235 | echo "- A new remote tracking branch '$BRANCH' was created" |
| 236 | echo "- You are now on branch '$BRANCH'" |
| 237 | echo |
| 238 | } |
| 239 | |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 240 | cmd_finish() { |
Vincent Driessen | de95e00 | 2010-07-22 15:11:17 +0200 | [diff] [blame] | 241 | DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F |
Vincent Driessen | 1a2868b | 2010-02-07 23:23:16 +0100 | [diff] [blame] | 242 | DEFINE_boolean sign false "sign the release tag cryptographically" s |
| 243 | DEFINE_string signingkey "" "use the given GPG-key for the digital signature (implies -s)" u |
| 244 | DEFINE_string message "" "use the given tag message" m |
Vincent Driessen | ddba2df | 2010-02-19 06:42:18 +0100 | [diff] [blame] | 245 | DEFINE_boolean push false "push to $ORIGIN after performing finish" p |
Vincent Driessen | ddd9dfe | 2010-10-05 12:34:38 +0200 | [diff] [blame] | 246 | DEFINE_boolean keep false "keep branch after performing finish" k |
Vincent Driessen | ca8be52 | 2010-10-05 14:33:50 +0200 | [diff] [blame] | 247 | DEFINE_boolean notag false "don't tag this release" n |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 248 | parse_args "$@" |
Vincent Driessen | 010252a | 2010-02-04 10:31:29 +0100 | [diff] [blame] | 249 | require_version_arg |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 250 | |
Vincent Driessen | 1a2868b | 2010-02-07 23:23:16 +0100 | [diff] [blame] | 251 | # handle flags that imply other flags |
| 252 | if [ "$FLAGS_signingkey" != "" ]; then |
| 253 | FLAGS_sign=$FLAGS_TRUE |
| 254 | fi |
| 255 | |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 256 | # sanity checks |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 257 | require_branch "$BRANCH" |
| 258 | require_clean_working_tree |
Vincent Driessen | ca73caf | 2010-02-07 19:46:38 +0100 | [diff] [blame] | 259 | if flag fetch; then |
Vincent Driessen | a4dd223 | 2010-02-10 00:34:59 +0100 | [diff] [blame] | 260 | git fetch -q "$ORIGIN" "$MASTER_BRANCH" || \ |
Vincent Driessen | 1a2868b | 2010-02-07 23:23:16 +0100 | [diff] [blame] | 261 | die "Could not fetch $MASTER_BRANCH from $ORIGIN." |
Vincent Driessen | a4dd223 | 2010-02-10 00:34:59 +0100 | [diff] [blame] | 262 | git fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \ |
Vincent Driessen | 1a2868b | 2010-02-07 23:23:16 +0100 | [diff] [blame] | 263 | die "Could not fetch $DEVELOP_BRANCH from $ORIGIN." |
Vincent Driessen | 2acfffd | 2010-01-29 12:37:22 +0100 | [diff] [blame] | 264 | fi |
Konstantin Tjuterev | f6fcc4e | 2011-04-14 19:20:19 +0300 | [diff] [blame] | 265 | if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then |
Vincent Driessen | de95e00 | 2010-07-22 15:11:17 +0200 | [diff] [blame] | 266 | require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH" |
| 267 | fi |
Konstantin Tjuterev | f6fcc4e | 2011-04-14 19:20:19 +0300 | [diff] [blame] | 268 | if has "$ORIGIN/$DEVELOP_BRANCH" $(git_remote_branches); then |
Vincent Driessen | de95e00 | 2010-07-22 15:11:17 +0200 | [diff] [blame] | 269 | require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH" |
| 270 | fi |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 271 | |
Vincent Driessen | 5fa4758 | 2010-02-09 00:31:33 +0100 | [diff] [blame] | 272 | # try to merge into master |
| 273 | # in case a previous attempt to finish this release branch has failed, |
| 274 | # but the merge into master was successful, we skip it now |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 275 | if ! git_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then |
Vincent Driessen | a4dd223 | 2010-02-10 00:34:59 +0100 | [diff] [blame] | 276 | git checkout "$MASTER_BRANCH" || \ |
Vincent Driessen | 5fa4758 | 2010-02-09 00:31:33 +0100 | [diff] [blame] | 277 | die "Could not check out $MASTER_BRANCH." |
Vincent Driessen | a4dd223 | 2010-02-10 00:34:59 +0100 | [diff] [blame] | 278 | git merge --no-ff "$BRANCH" || \ |
Vincent Driessen | 5fa4758 | 2010-02-09 00:31:33 +0100 | [diff] [blame] | 279 | die "There were merge conflicts." |
| 280 | # TODO: What do we do now? |
| 281 | fi |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 282 | |
Vincent Driessen | ca8be52 | 2010-10-05 14:33:50 +0200 | [diff] [blame] | 283 | if noflag notag; then |
| 284 | # try to tag the release |
| 285 | # in case a previous attempt to finish this release branch has failed, |
| 286 | # but the tag was set successful, we skip it now |
| 287 | local tagname=$VERSION_PREFIX$VERSION |
| 288 | if ! git_tag_exists "$tagname"; then |
| 289 | local opts="-a" |
| 290 | flag sign && opts="$opts -s" |
| 291 | [ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'" |
| 292 | [ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'" |
Randy Merrill | d0df88d | 2011-10-13 21:09:26 -0700 | [diff] [blame] | 293 | eval git tag $opts "$VERSION_PREFIX$VERSION" || \ |
Vincent Driessen | ca8be52 | 2010-10-05 14:33:50 +0200 | [diff] [blame] | 294 | die "Tagging failed. Please run finish again to retry." |
| 295 | fi |
Vincent Driessen | 5fa4758 | 2010-02-09 00:31:33 +0100 | [diff] [blame] | 296 | fi |
Vincent Driessen | 1a2868b | 2010-02-07 23:23:16 +0100 | [diff] [blame] | 297 | |
Vincent Driessen | 5fa4758 | 2010-02-09 00:31:33 +0100 | [diff] [blame] | 298 | # try to merge into develop |
| 299 | # in case a previous attempt to finish this release branch has failed, |
| 300 | # but the merge into develop was successful, we skip it now |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 301 | if ! git_is_branch_merged_into "$BRANCH" "$DEVELOP_BRANCH"; then |
Vincent Driessen | a4dd223 | 2010-02-10 00:34:59 +0100 | [diff] [blame] | 302 | git checkout "$DEVELOP_BRANCH" || \ |
Vincent Driessen | 5fa4758 | 2010-02-09 00:31:33 +0100 | [diff] [blame] | 303 | die "Could not check out $DEVELOP_BRANCH." |
| 304 | |
Vincent Driessen | d29e315 | 2010-02-09 00:55:06 +0100 | [diff] [blame] | 305 | # TODO: Actually, accounting for 'git describe' pays, so we should |
| 306 | # ideally git merge --no-ff $tagname here, instead! |
Vincent Driessen | a4dd223 | 2010-02-10 00:34:59 +0100 | [diff] [blame] | 307 | git merge --no-ff "$BRANCH" || \ |
Vincent Driessen | 5fa4758 | 2010-02-09 00:31:33 +0100 | [diff] [blame] | 308 | die "There were merge conflicts." |
| 309 | # TODO: What do we do now? |
| 310 | fi |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 311 | |
| 312 | # delete branch |
Vincent Driessen | ddd9dfe | 2010-10-05 12:34:38 +0200 | [diff] [blame] | 313 | if noflag keep; then |
Guillaume-Jean Herbiet | 8fee0c2 | 2010-10-04 11:35:10 +0200 | [diff] [blame] | 314 | git branch -d "$BRANCH" |
| 315 | fi |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 316 | |
Vincent Driessen | ddba2df | 2010-02-19 06:42:18 +0100 | [diff] [blame] | 317 | if flag push; then |
| 318 | git push "$ORIGIN" "$DEVELOP_BRANCH" || \ |
| 319 | die "Could not push to $DEVELOP_BRANCH from $ORIGIN." |
| 320 | git push "$ORIGIN" "$MASTER_BRANCH" || \ |
| 321 | die "Could not push to $MASTER_BRANCH from $ORIGIN." |
Vincent Driessen | ca8be52 | 2010-10-05 14:33:50 +0200 | [diff] [blame] | 322 | if noflag notag; then |
| 323 | git push --tags "$ORIGIN" || \ |
| 324 | die "Could not push tags to $ORIGIN." |
| 325 | fi |
Vincent Driessen | ddba2df | 2010-02-19 06:42:18 +0100 | [diff] [blame] | 326 | fi |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 327 | |
| 328 | echo |
| 329 | echo "Summary of actions:" |
Benedikt Böhm | 350e715 | 2010-01-26 13:05:05 +0100 | [diff] [blame] | 330 | echo "- Latest objects have been fetched from '$ORIGIN'" |
Vincent Driessen | 010252a | 2010-02-04 10:31:29 +0100 | [diff] [blame] | 331 | echo "- Hotfix branch has been merged into '$MASTER_BRANCH'" |
Vincent Driessen | ca8be52 | 2010-10-05 14:33:50 +0200 | [diff] [blame] | 332 | if noflag notag; then |
| 333 | echo "- The hotfix was tagged '$VERSION_PREFIX$VERSION'" |
| 334 | fi |
Vincent Driessen | 010252a | 2010-02-04 10:31:29 +0100 | [diff] [blame] | 335 | echo "- Hotfix branch has been back-merged into '$DEVELOP_BRANCH'" |
Guillaume-Jean Herbiet | 8fee0c2 | 2010-10-04 11:35:10 +0200 | [diff] [blame] | 336 | if flag keep; then |
Vincent Driessen | ddd9dfe | 2010-10-05 12:34:38 +0200 | [diff] [blame] | 337 | echo "- Hotfix branch '$BRANCH' is still available" |
Guillaume-Jean Herbiet | 8fee0c2 | 2010-10-04 11:35:10 +0200 | [diff] [blame] | 338 | else |
| 339 | echo "- Hotfix branch '$BRANCH' has been deleted" |
| 340 | fi |
Vincent Driessen | ddba2df | 2010-02-19 06:42:18 +0100 | [diff] [blame] | 341 | if flag push; then |
| 342 | echo "- '$DEVELOP_BRANCH', '$MASTER_BRANCH' and tags have been pushed to '$ORIGIN'" |
| 343 | fi |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 344 | echo |
| 345 | } |