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