| #!/bin/sh |
| # |
| # 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 |
| # |
| |
| usage() { |
| echo "usage: gitflow start release <release>" |
| echo " gitflow finish release <release>" |
| # TODO |
| #echo "" |
| #echo "options:" |
| #echo "--option Explanation" |
| #echo "" |
| #echo "start-only options:" |
| #echo "--bump <script>" |
| #echo " Run the given script to auto-update the version number" |
| #echo "" |
| #echo "finish-only options:" |
| #echo "--push Push to the origin repo when finished" |
| } |
| |
| parse_args() { |
| RELEASE="$1" |
| if [ "$RELEASE" = "" ]; then |
| echo "Missing argument <release>" |
| usage |
| exit 1 |
| fi |
| RELEASE_BRANCH="release-$RELEASE" |
| } |
| |
| start() { |
| parse_args "$@" |
| |
| # Checks |
| gitflow_check_clean_working_tree |
| gitflow_require_branches_equal 'develop' 'origin/develop' |
| gitflow_require_branch_absent "$RELEASE_BRANCH" |
| |
| # All checks passed, ready to roll |
| git checkout -b "$RELEASE_BRANCH" develop |
| |
| echo "" |
| echo "Summary of actions:" |
| echo "- A new branch '$RELEASE_BRANCH' was created, based on 'develop'" |
| echo "- You are now on branch '$RELEASE_BRANCH'" |
| echo "" |
| echo "Follow-up actions:" |
| echo "- Bump the version number now!" |
| echo "- Start committing last-minute fixes in preparing your release" |
| echo "- When done, run:" |
| echo "" |
| echo " gitflow finish release '$RELEASE_BRANCH'" |
| } |
| |
| finish() { |
| parse_args "$@" |
| |
| # Checks |
| gitflow_check_clean_working_tree |
| |
| git fetch origin develop # TODO: Make a flag to skip these fetches |
| git fetch origin master # TODO: Make a flag to skip these fetches |
| gitflow_require_branches_equal 'master' 'origin/master' |
| gitflow_require_branches_equal 'develop' 'origin/develop' |
| |
| # All checks passed, ready to roll |
| git checkout master |
| git merge --no-ff "$RELEASE_BRANCH" |
| git tag "$RELEASE" |
| git checkout develop |
| git merge --no-ff "$RELEASE_BRANCH" |
| git branch -d "$RELEASE_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 "- Release branch has been merged into 'master'" |
| echo "- The release was tagged '$RELEASE'" |
| echo "- Release branch has been back-merged into 'develop'" |
| echo "- Release branch '$RELEASE_BRANCH' has been deleted" |
| echo "" |
| } |
| |