refactor the whole thing
- now works as sub commands to git if copied to $(git --exec-path) - now works with arbitrary commands for branch types - consistent variable names - new branch type 'support' for long-term support branches of historic versions - preliminary base branch support for hotfix branch type to create hotfixes form support branches
This commit is contained in:
parent
605b7cd8b4
commit
00ccea60ae
8 changed files with 439 additions and 319 deletions
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
#
|
||||
# gitflow -- A collection of Git wrapper scripts to provide high-level
|
||||
# repository operations for Vincent Driessen's branching model:
|
||||
|
@ -10,49 +10,92 @@
|
|||
# http://github.com/nvie/gitflow
|
||||
#
|
||||
# Copyright (c) 2010 by Vincent Driessen
|
||||
# Copyright (c) 2010 by Benedikt Böhm
|
||||
#
|
||||
|
||||
# Get the git dir
|
||||
GIT_DIR=$(git rev-parse --git-dir)
|
||||
|
||||
# Get all available branches
|
||||
LOCAL_BRANCHES=$(git branch | sed 's/^[* ] //')
|
||||
REMOTE_BRANCHES=$(git branch -r | sed 's/^[* ] //')
|
||||
ALL_BRANCHES="$LOCAL_BRANCHES\n$REMOTE_BRANCHES"
|
||||
|
||||
warn() { echo "$@" >&2; }
|
||||
die() { warn "$@"; exit 1; }
|
||||
has() { [[ " ${*:2} " == *" $1 "* ]]; }
|
||||
|
||||
usage() {
|
||||
echo "usage: git flow <cmd> <btype> <args>"
|
||||
echo
|
||||
echo "<btype> can be any of: feature, release, hotfix, support"
|
||||
echo
|
||||
echo "Try 'git flow help <btype>' for details."
|
||||
}
|
||||
|
||||
main() {
|
||||
if [ $# -lt 2 ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export GITFLOW_DIR=$(dirname "$0")
|
||||
|
||||
# sanity checks
|
||||
ACTION="$1"
|
||||
BTYPE="$2"
|
||||
shift 2
|
||||
|
||||
if [ ! -e "$GITFLOW_DIR/git-flow-$BTYPE" ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! git rev-parse --git-dir &>/dev/null; then
|
||||
die "Not a git repository"
|
||||
fi
|
||||
|
||||
# get all available branches
|
||||
LOCAL_BRANCHES=$(git branch | sed 's/^[* ] //')
|
||||
REMOTE_BRANCHES=$(git branch -r | sed 's/^[* ] //')
|
||||
ALL_BRANCHES="$LOCAL_BRANCHES $REMOTE_BRANCHES"
|
||||
|
||||
# run command
|
||||
. "$GITFLOW_DIR/git-flow-$BTYPE"
|
||||
|
||||
if ! declare -f cmd_$ACTION >/dev/null; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# fail if a command failes
|
||||
set -e
|
||||
|
||||
# run command
|
||||
cmd_$ACTION "$@"
|
||||
}
|
||||
|
||||
gitflow_check_clean_working_tree() {
|
||||
if [ "$(git status 2>/dev/null | tail -n1)" != "nothing to commit (working directory clean)" ]; then
|
||||
die "Working directory is dirty. Only use gitflow in clean working directories for your own safety."
|
||||
if ! git diff --no-ext-diff --ignore-submodules --quiet --exit-code; then
|
||||
die "Working tree contains unstaged changes. Aborting ..."
|
||||
fi
|
||||
if ! git diff-index --cached --quiet --ignore-submodules HEAD --; then
|
||||
die "Index contains uncommited changes. Aborting ..."
|
||||
fi
|
||||
}
|
||||
|
||||
gitflow_require_local_branch() {
|
||||
echo "$LOCAL_BRANCHES" | grep "^$1\$" 2>&1 >/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
if ! has $1 $LOCAL_BRANCHES; then
|
||||
die "Local branch '$1' does not exist and is required."
|
||||
fi
|
||||
}
|
||||
|
||||
gitflow_require_remote_branch() {
|
||||
echo "$REMOTE_BRANCHES" | grep "^$1\$" 2>&1 >/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
if ! has $1 $REMOTE_BRANCHES; then
|
||||
die "Remote branch '$1' does not exist and is required."
|
||||
fi
|
||||
}
|
||||
|
||||
gitflow_require_branch() {
|
||||
echo "$ALL_BRANCHES" | grep "^$1\$" 2>&1 >/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
if ! has $1 $ALL_BRANCHES; then
|
||||
die "Branch '$1' does not exist and is required."
|
||||
fi
|
||||
}
|
||||
|
||||
gitflow_require_branch_absent() {
|
||||
echo "$ALL_BRANCHES" | grep "^$1\$" 2>&1 >/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
if has $1 $ALL_BRANCHES; then
|
||||
die "Branch '$1' already exists. Pick another name."
|
||||
fi
|
||||
}
|
||||
|
@ -73,8 +116,6 @@ gitflow_test_branches_equal() {
|
|||
commit2=$(git rev-parse "$2")
|
||||
if [ "$commit1" != "$commit2" ]; then
|
||||
base=$(git merge-base "$commit1" "$commit2")
|
||||
short_base=$(git rev-parse --short "$base")
|
||||
|
||||
if [ "$commit1" = "$base" ]; then
|
||||
return 1
|
||||
elif [ "$commit2" = "$base" ]; then
|
||||
|
@ -94,7 +135,6 @@ gitflow_require_branches_equal() {
|
|||
status=$?
|
||||
if [ $status -gt 0 ]; then
|
||||
warn "Branches '$1' and '$2' have diverged."
|
||||
|
||||
if [ $status -eq 1 ]; then
|
||||
die "And branch '$1' may be fast-forwarded."
|
||||
elif [ $status -eq 2 ]; then
|
||||
|
@ -106,3 +146,4 @@ gitflow_require_branches_equal() {
|
|||
fi
|
||||
}
|
||||
|
||||
main "$@"
|
155
git-flow-feature
Executable file
155
git-flow-feature
Executable file
|
@ -0,0 +1,155 @@
|
|||
#
|
||||
# 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 feature <name> [<base>]"
|
||||
echo " git flow finish feature <name> [<base>]"
|
||||
echo " git flow publish feature <name>"
|
||||
echo " git flow track feature <name>"
|
||||
# TODO
|
||||
#echo ""
|
||||
#echo "options:"
|
||||
#echo "--option Explanation"
|
||||
#echo ""
|
||||
#echo "start-only options:"
|
||||
#echo "--option Explanation"
|
||||
#echo ""
|
||||
#echo "finish-only options:"
|
||||
#echo "--rebase Rebases the feature branch on top of develop, instead of merging"
|
||||
#echo "--squash Squashes all commits of the feature branch into a single commit"
|
||||
#echo " on develop"
|
||||
#echo "--push Push to the origin repo when finished"
|
||||
}
|
||||
|
||||
parse_args() {
|
||||
NAME="$1"
|
||||
BASE="${2:-develop}"
|
||||
if [ "$NAME" = "" ]; then
|
||||
echo "Missing argument <name>."
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
BRANCH=feature/$NAME
|
||||
}
|
||||
|
||||
cmd_help() {
|
||||
usage
|
||||
exit 0
|
||||
}
|
||||
|
||||
cmd_start() {
|
||||
parse_args "$@"
|
||||
|
||||
# sanity checks
|
||||
gitflow_check_clean_working_tree
|
||||
gitflow_require_branch_absent $BRANCH
|
||||
if [ "$BASE" = "develop" ]; then
|
||||
git fetch origin develop
|
||||
gitflow_require_branches_equal develop origin/develop
|
||||
fi
|
||||
|
||||
# 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 "Now, start committing on your feature. When done, use:"
|
||||
echo ""
|
||||
echo " git flow finish feature $NAME"
|
||||
echo
|
||||
}
|
||||
|
||||
cmd_finish() {
|
||||
parse_args "$@"
|
||||
|
||||
# sanity checks
|
||||
gitflow_check_clean_working_tree
|
||||
gitflow_require_branch $BRANCH
|
||||
git fetch origin
|
||||
if has origin/$BRANCH $REMOTE_BRANCHES; then
|
||||
gitflow_require_branches_equal $BRANCH origin/$BRANCH
|
||||
fi
|
||||
if [ "$BASE" = "develop" ]; then
|
||||
gitflow_require_branches_equal develop origin/develop
|
||||
fi
|
||||
|
||||
# merge into BASE
|
||||
git checkout $BASE
|
||||
if [ "$(git rev-list -n2 $BASE..$BRANCH | wc -l)" = "1" ]; then
|
||||
git merge --ff $BRANCH
|
||||
else
|
||||
git merge --no-ff $BRANCH
|
||||
fi
|
||||
|
||||
# delete branch
|
||||
# TODO: How do we handle merge conflicts here??
|
||||
git push origin :refs/heads/$BRANCH
|
||||
git branch -d $BRANCH
|
||||
|
||||
echo
|
||||
echo "Summary of actions:"
|
||||
echo "- The feature branch '$BRANCH' was merged into '$BASE'"
|
||||
#echo "- Merge conflicts were resolved" # TODO: Add this line when it's supported
|
||||
echo "- Feature branch '$BRANCH' has been removed"
|
||||
echo "- You are now on branch '$BASE'"
|
||||
echo
|
||||
}
|
||||
|
||||
cmd_publish() {
|
||||
parse_args "$@"
|
||||
|
||||
# sanity checks
|
||||
gitflow_check_clean_working_tree
|
||||
gitflow_require_branch $BRANCH
|
||||
git fetch origin
|
||||
gitflow_require_branch_absent origin/$BRANCH
|
||||
|
||||
# create remote branch
|
||||
git push origin $BRANCH:refs/heads/$BRANCH
|
||||
git fetch origin
|
||||
|
||||
# configure remote tracking
|
||||
git config branch.$BRANCH.remote origin
|
||||
git config branch.$BRANCH.merge refs/heads/$BRANCH
|
||||
git checkout $BRANCH
|
||||
|
||||
echo
|
||||
echo "Summary of actions:"
|
||||
echo "- A new remote branch '$BRANCH' was created"
|
||||
echo "- The local branch '$BRANCH' was configured to track the remote branch"
|
||||
echo "- You are now on branch '$BRANCH'"
|
||||
echo
|
||||
}
|
||||
|
||||
cmd_track() {
|
||||
parse_args "$@"
|
||||
|
||||
# sanity checks
|
||||
gitflow_check_clean_working_tree
|
||||
gitflow_require_branch_absent $BRANCH
|
||||
git fetch origin
|
||||
gitflow_require_branch origin/$BRANCH
|
||||
|
||||
# create tracking branch
|
||||
git checkout -b $BRANCH origin/$BRANCH
|
||||
|
||||
echo
|
||||
echo "Summary of actions:"
|
||||
echo "- A new remote tracking branch '$BRANCH' was created"
|
||||
echo "- You are now on branch '$BRANCH'"
|
||||
echo
|
||||
}
|
110
git-flow-hotfix
Executable file
110
git-flow-hotfix
Executable file
|
@ -0,0 +1,110 @@
|
|||
#
|
||||
# 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}"
|
||||
if [ "$VERSION" = "" ]; then
|
||||
echo "Missing argument <version>."
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
BRANCH=hotfix/$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 origin/master
|
||||
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
|
||||
git fetch origin develop
|
||||
gitflow_require_branches_equal master origin/master
|
||||
gitflow_require_branches_equal develop origin/develop
|
||||
|
||||
# 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" ]; then
|
||||
git checkout develop
|
||||
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" ]; then
|
||||
echo "- Hotfix branch has been back-merged into 'develop'"
|
||||
fi
|
||||
echo "- Hotfix branch '$BRANCH' has been deleted"
|
||||
echo
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# gitflow -- A collection of Git wrapper scripts to provide high-level
|
||||
# repository operations for Vincent Driessen's branching model:
|
||||
|
@ -10,11 +9,12 @@
|
|||
# http://github.com/nvie/gitflow
|
||||
#
|
||||
# Copyright (c) 2010 by Vincent Driessen
|
||||
# Copyright (c) 2010 by Benedikt Böhm
|
||||
#
|
||||
|
||||
usage() {
|
||||
echo "usage: gitflow start release <release>"
|
||||
echo " gitflow finish release <release>"
|
||||
echo "usage: git flow start release <version>"
|
||||
echo " git flow finish release <version>"
|
||||
# TODO
|
||||
#echo ""
|
||||
#echo "options:"
|
||||
|
@ -29,68 +29,76 @@ usage() {
|
|||
}
|
||||
|
||||
parse_args() {
|
||||
RELEASE="$1"
|
||||
if [ "$RELEASE" = "" ]; then
|
||||
echo "Missing argument <release>"
|
||||
VERSION="$1"
|
||||
if [ "$VERSION" = "" ]; then
|
||||
echo "Missing argument <version>."
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
RELEASE_BRANCH="release-$RELEASE"
|
||||
BRANCH=release/$VERSION
|
||||
}
|
||||
|
||||
start() {
|
||||
cmd_help() {
|
||||
usage
|
||||
exit 0
|
||||
}
|
||||
|
||||
cmd_start() {
|
||||
parse_args "$@"
|
||||
|
||||
# Checks
|
||||
# sanity checks
|
||||
gitflow_check_clean_working_tree
|
||||
gitflow_require_branches_equal 'develop' 'origin/develop'
|
||||
gitflow_require_branch_absent "$RELEASE_BRANCH"
|
||||
git fetch origin
|
||||
gitflow_require_branches_equal develop origin/develop
|
||||
gitflow_require_branch_absent $BRANCH
|
||||
|
||||
# All checks passed, ready to roll
|
||||
git checkout -b "$RELEASE_BRANCH" develop
|
||||
# create branch
|
||||
git checkout -b $BRANCH develop
|
||||
|
||||
echo ""
|
||||
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 "- A new branch '$BRANCH' was created, based on 'develop'"
|
||||
echo "- You are now on branch '$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'"
|
||||
echo
|
||||
echo " git flow finish release '$VERSION'"
|
||||
echo
|
||||
}
|
||||
|
||||
finish() {
|
||||
cmd_finish() {
|
||||
parse_args "$@"
|
||||
|
||||
# Checks
|
||||
# sanity checks
|
||||
gitflow_check_clean_working_tree
|
||||
git fetch origin
|
||||
gitflow_require_branches_equal master origin/master
|
||||
gitflow_require_branches_equal develop origin/develop
|
||||
|
||||
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
|
||||
# merge into master
|
||||
git checkout master
|
||||
git merge --no-ff "$RELEASE_BRANCH"
|
||||
git tag "$RELEASE"
|
||||
git merge --no-ff $BRANCH
|
||||
git tag v$VERSION
|
||||
|
||||
# merge into develop
|
||||
git checkout develop
|
||||
git merge --no-ff "$RELEASE_BRANCH"
|
||||
git branch -d "$RELEASE_BRANCH"
|
||||
git merge --no-ff $BRANCH
|
||||
|
||||
# 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
|
||||
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 "- The release was tagged 'v$VERSION'"
|
||||
echo "- Release branch has been back-merged into 'develop'"
|
||||
echo "- Release branch '$RELEASE_BRANCH' has been deleted"
|
||||
echo ""
|
||||
echo "- Release branch '$BRANCH' has been deleted"
|
||||
echo
|
||||
}
|
||||
|
57
git-flow-support
Normal file
57
git-flow-support
Normal file
|
@ -0,0 +1,57 @@
|
|||
#
|
||||
# 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 support <version> [<base>]"
|
||||
}
|
||||
|
||||
parse_args() {
|
||||
VERSION="$1"
|
||||
BASE="${2:-v${VERSION}}"
|
||||
if [ "$VERSION" = "" ]; then
|
||||
echo "Missing argument <version>."
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
BRANCH=support/$VERSION
|
||||
}
|
||||
|
||||
cmd_help() {
|
||||
usage
|
||||
exit 0
|
||||
}
|
||||
|
||||
cmd_start() {
|
||||
parse_args "$@"
|
||||
|
||||
# sanity checks
|
||||
gitflow_check_clean_working_tree
|
||||
|
||||
# create branch
|
||||
git checkout -b $BRANCH $BASE
|
||||
|
||||
# publish branch
|
||||
git push origin $BRANCH:refs/heads/$BRANCH
|
||||
git fetch origin
|
||||
git config branch.$BRANCH.remote origin
|
||||
git config branch.$BRANCH.merge refs/heads/$BRANCH
|
||||
git co $BRANCH
|
||||
|
||||
echo
|
||||
echo "Summary of actions:"
|
||||
echo "- A new remote branch '$BRANCH' was created, based on '$BASE'"
|
||||
echo "- A new tracking branch '$BRANCH' was created"
|
||||
echo "- You are now on branch '$BRANCH'"
|
||||
echo
|
||||
}
|
57
gitflow
57
gitflow
|
@ -1,57 +0,0 @@
|
|||
#!/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|finish> <btype> <args>"
|
||||
echo ""
|
||||
echo "btype can be any of: \"feature\", \"release\", \"hotfix\""
|
||||
echo ""
|
||||
}
|
||||
|
||||
check_incoming() {
|
||||
if [ "$ACTION" != "start" -a "$ACTION" != "finish" ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$BTYPE" != "feature" -a "$BTYPE" != "release" -a "$BTYPE" != "hotfix" ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Set & check arguments
|
||||
export GITFLOW_DIR=$(dirname "$0")
|
||||
ACTION="$1"
|
||||
BTYPE="$2"
|
||||
shift 2
|
||||
check_incoming
|
||||
|
||||
# Now, $ACTION and $BTYPE are set
|
||||
# It's time to call the appropriate subcommand
|
||||
. "$GITFLOW_DIR/gitflow-sh-setup"
|
||||
. "$GITFLOW_DIR/gitflow-$BTYPE"
|
||||
|
||||
if [ "$ACTION" = "start" ]; then
|
||||
start "$@"
|
||||
elif [ "$ACTION" = "finish" ]; then
|
||||
finish "$@"
|
||||
else
|
||||
usage
|
||||
fi
|
|
@ -1,99 +0,0 @@
|
|||
#!/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 feature [<options>] <name> [<base>]"
|
||||
echo " gitflow finish feature [<options>] <name>"
|
||||
# TODO
|
||||
#echo ""
|
||||
#echo "options:"
|
||||
#echo "--option Explanation"
|
||||
#echo ""
|
||||
#echo "start-only options:"
|
||||
#echo "--option Explanation"
|
||||
#echo ""
|
||||
#echo "finish-only options:"
|
||||
#echo "--rebase Rebases the feature branch on top of develop, instead of merging"
|
||||
#echo "--squash Squashes all commits of the feature branch into a single commit"
|
||||
#echo " on develop"
|
||||
#echo "--push Push to the origin repo when finished"
|
||||
}
|
||||
|
||||
parse_args() {
|
||||
FEATURE="$1"
|
||||
if [ $# -eq 2 ]; then
|
||||
BASE="$2"
|
||||
else
|
||||
BASE="develop"
|
||||
fi
|
||||
if [ "$FEATURE" = "" ]; then
|
||||
echo "Missing argument <release>"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
parse_args "$@"
|
||||
|
||||
# Checks
|
||||
gitflow_check_clean_working_tree
|
||||
gitflow_require_branch_absent "$FEATURE"
|
||||
if [ "$BASE" = "develop" ]; then
|
||||
gitflow_require_branches_equal 'develop' 'origin/develop'
|
||||
fi
|
||||
|
||||
# All checks passed, ready to roll
|
||||
git checkout -b "$FEATURE" "$BASE"
|
||||
|
||||
echo ""
|
||||
echo "Summary of actions:"
|
||||
echo "- A new branch '$FEATURE' was created, based on '$BASE'"
|
||||
echo "- You are now on branch '$FEATURE'"
|
||||
echo ""
|
||||
echo "Now, start committing on your feature. When done, use:"
|
||||
echo ""
|
||||
echo " gitflow finish feature '$FEATURE'"
|
||||
}
|
||||
|
||||
finish() {
|
||||
parse_args "$@"
|
||||
|
||||
# Checks
|
||||
gitflow_check_clean_working_tree
|
||||
gitflow_require_branch "$FEATURE"
|
||||
gitflow_require_branches_equal 'develop' 'origin/develop'
|
||||
|
||||
# All checks passed, ready to roll
|
||||
git checkout develop
|
||||
|
||||
# In case there has been only a single commit in the feature branch, don't
|
||||
# use --no-ff, since it has no extra advantages
|
||||
FF_FLAG="--no-ff"
|
||||
if [ "$(git rev-list develop.."$FEATURE" | wc -l)" -eq 1 ]; then
|
||||
FF_FLAG="--ff"
|
||||
fi
|
||||
git merge "$FF_FLAG" "$FEATURE"
|
||||
# TODO: How do we handle merge conflicts here??
|
||||
git branch -d "$FEATURE"
|
||||
|
||||
echo ""
|
||||
echo "Summary of actions:"
|
||||
echo "- The feature branch '$FEATURE' was merged into 'develop'"
|
||||
#echo "- Merge conflicts were resolved" # TODO: Add this line when it's supported
|
||||
echo "- Feature branch '$FEATURE' has been removed"
|
||||
echo "- You are now on branch 'develop'"
|
||||
echo ""
|
||||
}
|
||||
|
|
@ -1,95 +0,0 @@
|
|||
#!/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 hotfix <release>"
|
||||
echo " gitflow finish hotfix <release>"
|
||||
# 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() {
|
||||
RELEASE="$1"
|
||||
if [ "$RELEASE" = "" ]; then
|
||||
echo "Missing argument <release>"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
HOTFIX_BRANCH="hotfix-$RELEASE"
|
||||
}
|
||||
|
||||
start() {
|
||||
parse_args "$@"
|
||||
|
||||
# Checks
|
||||
gitflow_check_clean_working_tree
|
||||
gitflow_require_branches_equal 'master' 'origin/master'
|
||||
gitflow_require_branch_absent "$HOTFIX_BRANCH"
|
||||
|
||||
# All checks passed, ready to roll
|
||||
git checkout -b "$HOTFIX_BRANCH" master
|
||||
|
||||
echo ""
|
||||
echo "Summary of actions:"
|
||||
echo "- A new branch '$HOTFIX_BRANCH' was created, based on 'master'"
|
||||
echo "- You are now on branch '$HOTFIX_BRANCH'"
|
||||
echo ""
|
||||
echo "Follow-up actions:"
|
||||
echo "- Bump the version number now!"
|
||||
echo "- Start committing your hot fixes"
|
||||
echo "- When done, run:"
|
||||
echo ""
|
||||
echo " gitflow finish hotfix '$HOTFIX_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 "$HOTFIX_BRANCH"
|
||||
git tag "$RELEASE"
|
||||
git checkout develop
|
||||
git merge --no-ff "$HOTFIX_BRANCH"
|
||||
git branch -d "$HOTFIX_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 'master'"
|
||||
echo "- The hotfix was tagged '$RELEASE'"
|
||||
echo "- Hotfix branch has been back-merged into 'develop'"
|
||||
echo "- Hotfix branch '$HOTFIX_BRANCH' has been deleted"
|
||||
echo ""
|
||||
}
|
||||
|
Loading…
Reference in a new issue