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 | |
pccr | dc902ed | 2012-04-21 00:23:55 -0400 | [diff] [blame] | 39 | init() { |
| 40 | require_git_repo |
| 41 | require_gitflow_initialized |
| 42 | gitflow_load_settings |
| 43 | VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`") |
| 44 | PREFIX=$(git config --get gitflow.prefix.release) |
| 45 | } |
Benedikt Böhm | 49dd62b | 2010-01-28 00:51:15 +0100 | [diff] [blame] | 46 | |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 47 | usage() { |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 48 | echo "usage: git flow release [list] [-v]" |
Stefan Näwe | 2074360 | 2011-04-15 01:42:35 -0700 | [diff] [blame] | 49 | echo " git flow release start [-F] <version> [<base>]" |
Myke Hines | 6fa8fed | 2012-04-19 11:01:23 -0700 | [diff] [blame] | 50 | echo " git flow release finish [-FsumpkS] <version>" |
Felipe Talavera | bbca922 | 2010-09-30 12:25:08 -0700 | [diff] [blame] | 51 | echo " git flow release publish <name>" |
| 52 | echo " git flow release track <name>" |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 53 | } |
| 54 | |
Vincent Driessen | 170dc74 | 2010-01-28 00:20:51 +0100 | [diff] [blame] | 55 | cmd_default() { |
Vincent Driessen | b866b01 | 2010-01-28 01:01:53 +0100 | [diff] [blame] | 56 | cmd_list "$@" |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 57 | } |
| 58 | |
Vincent Driessen | b866b01 | 2010-01-28 01:01:53 +0100 | [diff] [blame] | 59 | cmd_list() { |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 60 | DEFINE_boolean verbose false 'verbose (more) output' v |
| 61 | parse_args "$@" |
| 62 | |
Vincent Driessen | f46e290 | 2010-02-15 23:01:52 +0100 | [diff] [blame] | 63 | local release_branches |
| 64 | local current_branch |
| 65 | local short_names |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 66 | release_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX") |
Vincent Driessen | 27592dd | 2010-02-06 14:45:39 +0100 | [diff] [blame] | 67 | if [ -z "$release_branches" ]; then |
Vincent Driessen | 170dc74 | 2010-01-28 00:20:51 +0100 | [diff] [blame] | 68 | warn "No release branches exist." |
Randy Merrill | b681b45 | 2010-06-26 13:14:15 +0800 | [diff] [blame] | 69 | warn "" |
| 70 | warn "You can start a new release branch:" |
| 71 | warn "" |
| 72 | warn " git flow release start <name> [<base>]" |
Randy Merrill | 4de01f2 | 2010-06-26 13:19:06 +0800 | [diff] [blame] | 73 | warn "" |
Vincent Driessen | 170dc74 | 2010-01-28 00:20:51 +0100 | [diff] [blame] | 74 | exit 0 |
| 75 | fi |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 76 | |
Adam Gibbins | cf3da5a | 2010-08-22 19:13:34 +0100 | [diff] [blame] | 77 | 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] | 78 | short_names=$(echo "$release_branches" | sed "s ^$PREFIX g") |
Vincent Driessen | 27592dd | 2010-02-06 14:45:39 +0100 | [diff] [blame] | 79 | |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 80 | # determine column width first |
Vincent Driessen | f46e290 | 2010-02-15 23:01:52 +0100 | [diff] [blame] | 81 | local width=0 |
| 82 | local branch |
Vincent Driessen | 27592dd | 2010-02-06 14:45:39 +0100 | [diff] [blame] | 83 | for branch in $short_names; do |
Vincent Driessen | f46e290 | 2010-02-15 23:01:52 +0100 | [diff] [blame] | 84 | local len=${#branch} |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 85 | width=$(max $width $len) |
| 86 | done |
Vincent Driessen | f46e290 | 2010-02-15 23:01:52 +0100 | [diff] [blame] | 87 | width=$(($width+3)) |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 88 | |
Vincent Driessen | f46e290 | 2010-02-15 23:01:52 +0100 | [diff] [blame] | 89 | local branch |
Vincent Driessen | 27592dd | 2010-02-06 14:45:39 +0100 | [diff] [blame] | 90 | for branch in $short_names; do |
Vincent Driessen | f46e290 | 2010-02-15 23:01:52 +0100 | [diff] [blame] | 91 | local fullname=$PREFIX$branch |
| 92 | local base=$(git merge-base "$fullname" "$DEVELOP_BRANCH") |
| 93 | local develop_sha=$(git rev-parse "$DEVELOP_BRANCH") |
| 94 | local branch_sha=$(git rev-parse "$fullname") |
Vincent Driessen | 27592dd | 2010-02-06 14:45:39 +0100 | [diff] [blame] | 95 | if [ "$fullname" = "$current_branch" ]; then |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 96 | printf "* " |
| 97 | else |
| 98 | printf " " |
| 99 | fi |
| 100 | if flag verbose; then |
| 101 | printf "%-${width}s" "$branch" |
| 102 | if [ "$branch_sha" = "$develop_sha" ]; then |
| 103 | printf "(no commits yet)" |
| 104 | else |
Vincent Driessen | f46e290 | 2010-02-15 23:01:52 +0100 | [diff] [blame] | 105 | local nicename=$(git rev-parse --short "$base") |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 106 | printf "(based on $nicename)" |
| 107 | fi |
| 108 | else |
| 109 | printf "%s" "$branch" |
| 110 | fi |
| 111 | echo |
| 112 | done |
Vincent Driessen | 170dc74 | 2010-01-28 00:20:51 +0100 | [diff] [blame] | 113 | } |
| 114 | |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 115 | cmd_help() { |
| 116 | usage |
| 117 | exit 0 |
| 118 | } |
| 119 | |
Vincent Driessen | b866b01 | 2010-01-28 01:01:53 +0100 | [diff] [blame] | 120 | parse_args() { |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 121 | # parse options |
| 122 | FLAGS "$@" || exit $? |
| 123 | eval set -- "${FLAGS_ARGV}" |
| 124 | |
| 125 | # read arguments into global variables |
Vincent Driessen | f1eaa4e | 2011-02-03 16:11:25 +0100 | [diff] [blame] | 126 | VERSION=$1 |
Vincent Driessen | c5fcc01 | 2010-02-10 00:18:08 +0100 | [diff] [blame] | 127 | BRANCH=$PREFIX$VERSION |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | require_version_arg() { |
Vincent Driessen | b866b01 | 2010-01-28 01:01:53 +0100 | [diff] [blame] | 131 | if [ "$VERSION" = "" ]; then |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 132 | warn "Missing argument <version>" |
Vincent Driessen | b866b01 | 2010-01-28 01:01:53 +0100 | [diff] [blame] | 133 | usage |
| 134 | exit 1 |
| 135 | fi |
Vincent Driessen | b866b01 | 2010-01-28 01:01:53 +0100 | [diff] [blame] | 136 | } |
| 137 | |
Vincent Driessen | 010252a | 2010-02-04 10:31:29 +0100 | [diff] [blame] | 138 | require_base_is_on_develop() { |
Adam Gibbins | cf3da5a | 2010-08-22 19:13:34 +0100 | [diff] [blame] | 139 | if ! git branch --no-color --contains "$BASE" 2>/dev/null \ |
Vincent Driessen | 010252a | 2010-02-04 10:31:29 +0100 | [diff] [blame] | 140 | | sed 's/[* ] //g' \ |
| 141 | | grep -q "^$DEVELOP_BRANCH\$"; then |
| 142 | die "fatal: Given base '$BASE' is not a valid commit on '$DEVELOP_BRANCH'." |
| 143 | fi |
| 144 | } |
| 145 | |
Vincent Driessen | 6d64d2c | 2010-02-16 06:41:13 +0100 | [diff] [blame] | 146 | require_no_existing_release_branches() { |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 147 | local release_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX") |
Vincent Driessen | 6d64d2c | 2010-02-16 06:41:13 +0100 | [diff] [blame] | 148 | local first_branch=$(echo ${release_branches} | head -n1) |
| 149 | first_branch=${first_branch#$PREFIX} |
| 150 | [ -z "$release_branches" ] || \ |
| 151 | die "There is an existing release branch ($first_branch). Finish that one first." |
| 152 | } |
| 153 | |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 154 | cmd_start() { |
Vincent Driessen | de95e00 | 2010-07-22 15:11:17 +0200 | [diff] [blame] | 155 | DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 156 | parse_args "$@" |
Vincent Driessen | c5fcc01 | 2010-02-10 00:18:08 +0100 | [diff] [blame] | 157 | BASE=${2:-$DEVELOP_BRANCH} |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 158 | require_version_arg |
Vincent Driessen | 010252a | 2010-02-04 10:31:29 +0100 | [diff] [blame] | 159 | require_base_is_on_develop |
Vincent Driessen | 6d64d2c | 2010-02-16 06:41:13 +0100 | [diff] [blame] | 160 | require_no_existing_release_branches |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 161 | |
| 162 | # sanity checks |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 163 | require_clean_working_tree |
| 164 | require_branch_absent "$BRANCH" |
| 165 | require_tag_absent "$VERSION_PREFIX$VERSION" |
Vincent Driessen | ca73caf | 2010-02-07 19:46:38 +0100 | [diff] [blame] | 166 | if flag fetch; then |
Vincent Driessen | a4dd223 | 2010-02-10 00:34:59 +0100 | [diff] [blame] | 167 | git fetch -q "$ORIGIN" "$DEVELOP_BRANCH" |
Vincent Driessen | 2acfffd | 2010-01-29 12:37:22 +0100 | [diff] [blame] | 168 | fi |
Konstantin Tjuterev | f6fcc4e | 2011-04-14 19:20:19 +0300 | [diff] [blame] | 169 | if has "$ORIGIN/$DEVELOP_BRANCH" $(git_remote_branches); then |
Vincent Driessen | de95e00 | 2010-07-22 15:11:17 +0200 | [diff] [blame] | 170 | require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH" |
| 171 | fi |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 172 | |
| 173 | # create branch |
Vincent Driessen | a4dd223 | 2010-02-10 00:34:59 +0100 | [diff] [blame] | 174 | git checkout -b "$BRANCH" "$BASE" |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 175 | |
| 176 | echo |
| 177 | echo "Summary of actions:" |
Vincent Driessen | 010252a | 2010-02-04 10:31:29 +0100 | [diff] [blame] | 178 | echo "- A new branch '$BRANCH' was created, based on '$BASE'" |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 179 | echo "- You are now on branch '$BRANCH'" |
| 180 | echo |
| 181 | echo "Follow-up actions:" |
| 182 | echo "- Bump the version number now!" |
| 183 | echo "- Start committing last-minute fixes in preparing your release" |
| 184 | echo "- When done, run:" |
| 185 | echo |
Vincent Driessen | 010252a | 2010-02-04 10:31:29 +0100 | [diff] [blame] | 186 | echo " git flow release finish '$VERSION'" |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 187 | echo |
| 188 | } |
| 189 | |
| 190 | cmd_finish() { |
Vincent Driessen | de95e00 | 2010-07-22 15:11:17 +0200 | [diff] [blame] | 191 | DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F |
Vincent Driessen | 1a2868b | 2010-02-07 23:23:16 +0100 | [diff] [blame] | 192 | DEFINE_boolean sign false "sign the release tag cryptographically" s |
| 193 | DEFINE_string signingkey "" "use the given GPG-key for the digital signature (implies -s)" u |
| 194 | DEFINE_string message "" "use the given tag message" m |
Steve Streeting | 2e9ab49 | 2012-06-08 17:38:34 -0700 | [diff] [blame] | 195 | DEFINE_string messagefile "" "use the contents of the given file as a tag message" f |
Vincent Driessen | ddba2df | 2010-02-19 06:42:18 +0100 | [diff] [blame] | 196 | DEFINE_boolean push false "push to $ORIGIN after performing finish" p |
Vincent Driessen | ddd9dfe | 2010-10-05 12:34:38 +0200 | [diff] [blame] | 197 | DEFINE_boolean keep false "keep branch after performing finish" k |
Vincent Driessen | ca8be52 | 2010-10-05 14:33:50 +0200 | [diff] [blame] | 198 | DEFINE_boolean notag false "don't tag this release" n |
Vincent Driessen | 0c4d0bf | 2012-07-09 14:23:59 +0200 | [diff] [blame] | 199 | DEFINE_boolean squash false "squash release during merge" S |
Jason L. Shiffer | 6809f0e | 2010-02-18 23:57:08 -0500 | [diff] [blame] | 200 | |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 201 | parse_args "$@" |
Vincent Driessen | 3c337fb | 2010-02-04 11:30:18 +0100 | [diff] [blame] | 202 | require_version_arg |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 203 | |
Vincent Driessen | 1a2868b | 2010-02-07 23:23:16 +0100 | [diff] [blame] | 204 | # handle flags that imply other flags |
| 205 | if [ "$FLAGS_signingkey" != "" ]; then |
| 206 | FLAGS_sign=$FLAGS_TRUE |
| 207 | fi |
| 208 | |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 209 | # sanity checks |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 210 | require_branch "$BRANCH" |
| 211 | require_clean_working_tree |
Vincent Driessen | ca73caf | 2010-02-07 19:46:38 +0100 | [diff] [blame] | 212 | if flag fetch; then |
Vincent Driessen | a4dd223 | 2010-02-10 00:34:59 +0100 | [diff] [blame] | 213 | git fetch -q "$ORIGIN" "$MASTER_BRANCH" || \ |
Vincent Driessen | 1a2868b | 2010-02-07 23:23:16 +0100 | [diff] [blame] | 214 | die "Could not fetch $MASTER_BRANCH from $ORIGIN." |
Vincent Driessen | a4dd223 | 2010-02-10 00:34:59 +0100 | [diff] [blame] | 215 | git fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \ |
Vincent Driessen | 1a2868b | 2010-02-07 23:23:16 +0100 | [diff] [blame] | 216 | die "Could not fetch $DEVELOP_BRANCH from $ORIGIN." |
Vincent Driessen | 2acfffd | 2010-01-29 12:37:22 +0100 | [diff] [blame] | 217 | fi |
Konstantin Tjuterev | f6fcc4e | 2011-04-14 19:20:19 +0300 | [diff] [blame] | 218 | if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then |
Vincent Driessen | de95e00 | 2010-07-22 15:11:17 +0200 | [diff] [blame] | 219 | require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH" |
| 220 | fi |
Konstantin Tjuterev | f6fcc4e | 2011-04-14 19:20:19 +0300 | [diff] [blame] | 221 | if has "$ORIGIN/$DEVELOP_BRANCH" $(git_remote_branches); then |
Vincent Driessen | de95e00 | 2010-07-22 15:11:17 +0200 | [diff] [blame] | 222 | require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH" |
| 223 | fi |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 224 | |
Vincent Driessen | 5fa4758 | 2010-02-09 00:31:33 +0100 | [diff] [blame] | 225 | # try to merge into master |
| 226 | # in case a previous attempt to finish this release branch has failed, |
| 227 | # but the merge into master was successful, we skip it now |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 228 | if ! git_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then |
Vincent Driessen | a4dd223 | 2010-02-10 00:34:59 +0100 | [diff] [blame] | 229 | git checkout "$MASTER_BRANCH" || \ |
Vincent Driessen | 5fa4758 | 2010-02-09 00:31:33 +0100 | [diff] [blame] | 230 | die "Could not check out $MASTER_BRANCH." |
Vincent Driessen | 0c4d0bf | 2012-07-09 14:23:59 +0200 | [diff] [blame] | 231 | if noflag squash; then |
| 232 | git merge --no-ff "$BRANCH" || \ |
| 233 | die "There were merge conflicts." |
| 234 | # TODO: What do we do now? |
| 235 | else |
| 236 | git merge --squash "$BRANCH" || \ |
| 237 | die "There were merge conflicts." |
| 238 | git commit |
| 239 | fi |
Vincent Driessen | 5fa4758 | 2010-02-09 00:31:33 +0100 | [diff] [blame] | 240 | fi |
Vincent Driessen | 1a2868b | 2010-02-07 23:23:16 +0100 | [diff] [blame] | 241 | |
Vincent Driessen | ca8be52 | 2010-10-05 14:33:50 +0200 | [diff] [blame] | 242 | if noflag notag; then |
| 243 | # try to tag the release |
| 244 | # in case a previous attempt to finish this release branch has failed, |
| 245 | # but the tag was set successful, we skip it now |
| 246 | local tagname=$VERSION_PREFIX$VERSION |
| 247 | if ! git_tag_exists "$tagname"; then |
| 248 | local opts="-a" |
| 249 | flag sign && opts="$opts -s" |
| 250 | [ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'" |
| 251 | [ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'" |
Steve Streeting | 2e9ab49 | 2012-06-08 17:38:34 -0700 | [diff] [blame] | 252 | [ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'" |
Randy Merrill | 05c4dbc | 2011-10-13 20:28:10 -0700 | [diff] [blame] | 253 | eval git tag $opts "$tagname" || \ |
Vincent Driessen | ca8be52 | 2010-10-05 14:33:50 +0200 | [diff] [blame] | 254 | die "Tagging failed. Please run finish again to retry." |
| 255 | fi |
Vincent Driessen | 5fa4758 | 2010-02-09 00:31:33 +0100 | [diff] [blame] | 256 | fi |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 257 | |
Vincent Driessen | 5fa4758 | 2010-02-09 00:31:33 +0100 | [diff] [blame] | 258 | # try to merge into develop |
| 259 | # in case a previous attempt to finish this release branch has failed, |
| 260 | # but the merge into develop was successful, we skip it now |
Vincent Driessen | 7832d6e | 2010-02-21 21:31:03 +0100 | [diff] [blame] | 261 | if ! git_is_branch_merged_into "$BRANCH" "$DEVELOP_BRANCH"; then |
Vincent Driessen | a4dd223 | 2010-02-10 00:34:59 +0100 | [diff] [blame] | 262 | git checkout "$DEVELOP_BRANCH" || \ |
Vincent Driessen | 5fa4758 | 2010-02-09 00:31:33 +0100 | [diff] [blame] | 263 | die "Could not check out $DEVELOP_BRANCH." |
Vincent Driessen | d29e315 | 2010-02-09 00:55:06 +0100 | [diff] [blame] | 264 | |
| 265 | # TODO: Actually, accounting for 'git describe' pays, so we should |
| 266 | # ideally git merge --no-ff $tagname here, instead! |
Vincent Driessen | 0c4d0bf | 2012-07-09 14:23:59 +0200 | [diff] [blame] | 267 | if noflag squash; then |
| 268 | git merge --no-ff "$BRANCH" || \ |
| 269 | die "There were merge conflicts." |
| 270 | # TODO: What do we do now? |
| 271 | else |
| 272 | git merge --squash "$BRANCH" || \ |
| 273 | die "There were merge conflicts." |
| 274 | # TODO: What do we do now? |
| 275 | git commit |
| 276 | fi |
Vincent Driessen | 5fa4758 | 2010-02-09 00:31:33 +0100 | [diff] [blame] | 277 | fi |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 278 | |
| 279 | # delete branch |
Vincent Driessen | ddd9dfe | 2010-10-05 12:34:38 +0200 | [diff] [blame] | 280 | if noflag keep; then |
Vincent Driessen | 46f9998 | 2010-10-05 12:45:29 +0200 | [diff] [blame] | 281 | if [ "$BRANCH" = "$(git_current_branch)" ]; then |
| 282 | git checkout "$MASTER_BRANCH" |
| 283 | fi |
Guillaume-Jean Herbiet | 8fee0c2 | 2010-10-04 11:35:10 +0200 | [diff] [blame] | 284 | git branch -d "$BRANCH" |
| 285 | fi |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 286 | |
Vincent Driessen | ddba2df | 2010-02-19 06:42:18 +0100 | [diff] [blame] | 287 | if flag push; then |
| 288 | git push "$ORIGIN" "$DEVELOP_BRANCH" || \ |
| 289 | die "Could not push to $DEVELOP_BRANCH from $ORIGIN." |
| 290 | git push "$ORIGIN" "$MASTER_BRANCH" || \ |
| 291 | die "Could not push to $MASTER_BRANCH from $ORIGIN." |
Vincent Driessen | ca8be52 | 2010-10-05 14:33:50 +0200 | [diff] [blame] | 292 | if noflag notag; then |
| 293 | git push --tags "$ORIGIN" || \ |
| 294 | die "Could not push tags to $ORIGIN." |
| 295 | fi |
Felipe Talavera | 4c90d92 | 2010-09-30 13:30:03 -0700 | [diff] [blame] | 296 | git push "$ORIGIN" :"$BRANCH" || \ |
| 297 | die "Could not delete the remote $BRANCH in $ORIGIN." |
Vincent Driessen | ddba2df | 2010-02-19 06:42:18 +0100 | [diff] [blame] | 298 | fi |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 299 | |
| 300 | echo |
| 301 | echo "Summary of actions:" |
Benedikt Böhm | 350e715 | 2010-01-26 13:05:05 +0100 | [diff] [blame] | 302 | echo "- Latest objects have been fetched from '$ORIGIN'" |
Benedikt Böhm | 4a864fb | 2010-01-26 12:59:27 +0100 | [diff] [blame] | 303 | echo "- Release branch has been merged into '$MASTER_BRANCH'" |
Vincent Driessen | ca8be52 | 2010-10-05 14:33:50 +0200 | [diff] [blame] | 304 | if noflag notag; then |
| 305 | echo "- The release was tagged '$tagname'" |
| 306 | fi |
Benedikt Böhm | 4a864fb | 2010-01-26 12:59:27 +0100 | [diff] [blame] | 307 | echo "- Release branch has been back-merged into '$DEVELOP_BRANCH'" |
Guillaume-Jean Herbiet | 8fee0c2 | 2010-10-04 11:35:10 +0200 | [diff] [blame] | 308 | if flag keep; then |
Vincent Driessen | ddd9dfe | 2010-10-05 12:34:38 +0200 | [diff] [blame] | 309 | echo "- Release branch '$BRANCH' is still available" |
Guillaume-Jean Herbiet | 8fee0c2 | 2010-10-04 11:35:10 +0200 | [diff] [blame] | 310 | else |
| 311 | echo "- Release branch '$BRANCH' has been deleted" |
| 312 | fi |
Vincent Driessen | ddba2df | 2010-02-19 06:42:18 +0100 | [diff] [blame] | 313 | if flag push; then |
| 314 | echo "- '$DEVELOP_BRANCH', '$MASTER_BRANCH' and tags have been pushed to '$ORIGIN'" |
Felipe Talavera | 4c90d92 | 2010-09-30 13:30:03 -0700 | [diff] [blame] | 315 | echo "- Release branch '$BRANCH' in '$ORIGIN' has been deleted." |
Vincent Driessen | ddba2df | 2010-02-19 06:42:18 +0100 | [diff] [blame] | 316 | fi |
Benedikt Böhm | 00ccea6 | 2010-01-26 12:39:36 +0100 | [diff] [blame] | 317 | echo |
| 318 | } |
Felipe Talavera | fbcf4a0 | 2010-09-30 12:03:01 -0700 | [diff] [blame] | 319 | |
| 320 | cmd_publish() { |
| 321 | parse_args "$@" |
Felipe Talavera | df706ac | 2010-09-30 13:11:34 -0700 | [diff] [blame] | 322 | require_version_arg |
Felipe Talavera | fbcf4a0 | 2010-09-30 12:03:01 -0700 | [diff] [blame] | 323 | |
| 324 | # sanity checks |
| 325 | require_clean_working_tree |
| 326 | require_branch "$BRANCH" |
| 327 | git fetch -q "$ORIGIN" |
| 328 | require_branch_absent "$ORIGIN/$BRANCH" |
| 329 | |
| 330 | # create remote branch |
| 331 | git push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH" |
| 332 | git fetch -q "$ORIGIN" |
| 333 | |
| 334 | # configure remote tracking |
| 335 | git config "branch.$BRANCH.remote" "$ORIGIN" |
| 336 | git config "branch.$BRANCH.merge" "refs/heads/$BRANCH" |
| 337 | git checkout "$BRANCH" |
| 338 | |
| 339 | echo |
| 340 | echo "Summary of actions:" |
| 341 | echo "- A new remote branch '$BRANCH' was created" |
| 342 | echo "- The local branch '$BRANCH' was configured to track the remote branch" |
| 343 | echo "- You are now on branch '$BRANCH'" |
| 344 | echo |
| 345 | } |
| 346 | |
| 347 | cmd_track() { |
| 348 | parse_args "$@" |
Felipe Talavera | df706ac | 2010-09-30 13:11:34 -0700 | [diff] [blame] | 349 | require_version_arg |
Felipe Talavera | fbcf4a0 | 2010-09-30 12:03:01 -0700 | [diff] [blame] | 350 | |
| 351 | # sanity checks |
| 352 | require_clean_working_tree |
| 353 | require_branch_absent "$BRANCH" |
| 354 | git fetch -q "$ORIGIN" |
| 355 | require_branch "$ORIGIN/$BRANCH" |
| 356 | |
| 357 | # create tracking branch |
| 358 | git checkout -b "$BRANCH" "$ORIGIN/$BRANCH" |
| 359 | |
| 360 | echo |
| 361 | echo "Summary of actions:" |
| 362 | echo "- A new remote tracking branch '$BRANCH' was created" |
| 363 | echo "- You are now on branch '$BRANCH'" |
| 364 | echo |
| 365 | } |