diff --git a/git-flow-feature b/git-flow-feature deleted file mode 100644 index 55198ad..0000000 --- a/git-flow-feature +++ /dev/null @@ -1,530 +0,0 @@ -# -# git-flow -- A collection of Git extensions to provide high-level -# repository operations for Vincent Driessen's branching model. -# -# Original blog post presenting this model is found at: -# http://nvie.com/git-model -# -# Feel free to contribute to this project at: -# http://github.com/nvie/gitflow -# -# Copyright 2010 Vincent Driessen. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -# EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# The views and conclusions contained in the software and documentation are -# those of the authors and should not be interpreted as representing official -# policies, either expressed or implied, of Vincent Driessen. -# - -init() { - require_git_repo - require_gitflow_initialized - gitflow_load_settings - PREFIX=$(git config --get gitflow.prefix.feature) -} - -usage() { - echo "usage: git flow feature [list] [-v]" - echo " git flow feature start [-F] []" - echo " git flow feature finish [-rFkDS] []" - echo " git flow feature publish " - echo " git flow feature track " - echo " git flow feature diff []" - echo " git flow feature rebase [-i] []" - echo " git flow feature checkout []" - echo " git flow feature pull [-r] []" -} - -cmd_default() { - cmd_list "$@" -} - -cmd_list() { - DEFINE_boolean verbose false 'verbose (more) output' v - parse_args "$@" - - local feature_branches - local current_branch - local short_names - feature_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX") - if [ -z "$feature_branches" ]; then - warn "No feature branches exist." - warn "" - warn "You can start a new feature branch:" - warn "" - warn " git flow feature start []" - warn "" - exit 0 - fi - current_branch=$(git branch --no-color | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g') - short_names=$(echo "$feature_branches" | sed "s ^$PREFIX g") - - # determine column width first - local width=0 - local branch - for branch in $short_names; do - local len=${#branch} - width=$(max $width $len) - done - width=$(($width+3)) - - local branch - for branch in $short_names; do - local fullname=$PREFIX$branch - local base=$(git merge-base "$fullname" "$DEVELOP_BRANCH") - local develop_sha=$(git rev-parse "$DEVELOP_BRANCH") - local branch_sha=$(git rev-parse "$fullname") - if [ "$fullname" = "$current_branch" ]; then - printf "* " - else - printf " " - fi - if flag verbose; then - printf "%-${width}s" "$branch" - if [ "$branch_sha" = "$develop_sha" ]; then - printf "(no commits yet)" - elif [ "$base" = "$branch_sha" ]; then - printf "(is behind develop, may ff)" - elif [ "$base" = "$develop_sha" ]; then - printf "(based on latest develop)" - else - printf "(may be rebased)" - fi - else - printf "%s" "$branch" - fi - echo - done -} - -cmd_help() { - usage - exit 0 -} - -require_name_arg() { - if [ "$NAME" = "" ]; then - warn "Missing argument " - usage - exit 1 - fi -} - -expand_nameprefix_arg() { - require_name_arg - - local expanded_name - local exitcode - expanded_name=$(gitflow_resolve_nameprefix "$NAME" "$PREFIX") - exitcode=$? - case $exitcode in - 0) NAME=$expanded_name - BRANCH=$PREFIX$NAME - ;; - *) exit 1 ;; - esac -} - -use_current_feature_branch_name() { - local current_branch=$(git_current_branch) - if startswith "$current_branch" "$PREFIX"; then - BRANCH=$current_branch - NAME=${BRANCH#$PREFIX} - else - warn "The current HEAD is no feature branch." - warn "Please specify a argument." - exit 1 - fi -} - -expand_nameprefix_arg_or_current() { - if [ "$NAME" != "" ]; then - expand_nameprefix_arg - require_branch "$PREFIX$NAME" - else - use_current_feature_branch_name - fi -} - -name_or_current() { - if [ -z "$NAME" ]; then - use_current_feature_branch_name - fi -} - -parse_args() { - # parse options - FLAGS "$@" || exit $? - eval set -- "${FLAGS_ARGV}" - - # read arguments into global variables - NAME=$1 - BRANCH=$PREFIX$NAME -} - -parse_remote_name() { - # parse options - FLAGS "$@" || exit $? - eval set -- "${FLAGS_ARGV}" - - # read arguments into global variables - REMOTE=$1 - NAME=$2 - BRANCH=$PREFIX$NAME -} - -cmd_start() { - DEFINE_boolean fetch false 'fetch from origin before performing local operation' F - parse_args "$@" - BASE=${2:-$DEVELOP_BRANCH} - require_name_arg - - # sanity checks - require_branch_absent "$BRANCH" - - # update the local repo with remote changes, if asked - if flag fetch; then - git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH" - fi - - # if the origin branch counterpart exists, assert that the local branch - # isn't behind it (to avoid unnecessary rebasing) - if git_branch_exists "$ORIGIN/$DEVELOP_BRANCH"; then - require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH" - fi - - # create branch - if ! git_do checkout -b "$BRANCH" "$BASE"; then - die "Could not create feature branch '$BRANCH'" - fi - - 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 feature finish $NAME" - echo -} - -cmd_finish() { - DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F - DEFINE_boolean rebase false "rebase instead of merge" r - DEFINE_boolean keep false "keep branch after performing finish" k - DEFINE_boolean force_delete false "force delete feature branch after finish" D - DEFINE_boolean squash false "squash feature during merge" S - parse_args "$@" - expand_nameprefix_arg_or_current - - # sanity checks - require_branch "$BRANCH" - - # detect if we're restoring from a merge conflict - if [ -f "$DOT_GIT_DIR/.gitflow/MERGE_BASE" ]; then - # - # TODO: detect that we're working on the correct branch here! - # The user need not necessarily have given the same $NAME twice here - # (although he/she should). - # - - # TODO: git_is_clean_working_tree() should provide an alternative - # exit code for "unmerged changes in working tree", which we should - # actually be testing for here - if git_is_clean_working_tree; then - FINISH_BASE=$(cat "$DOT_GIT_DIR/.gitflow/MERGE_BASE") - - # Since the working tree is now clean, either the user did a - # succesfull merge manually, or the merge was cancelled. - # We detect this using git_is_branch_merged_into() - if git_is_branch_merged_into "$BRANCH" "$FINISH_BASE"; then - rm -f "$DOT_GIT_DIR/.gitflow/MERGE_BASE" - helper_finish_cleanup - exit 0 - else - # If the user cancelled the merge and decided to wait until later, - # that's fine. But we have to acknowledge this by removing the - # MERGE_BASE file and continuing normal execution of the finish - rm -f "$DOT_GIT_DIR/.gitflow/MERGE_BASE" - fi - else - echo - echo "Merge conflicts not resolved yet, use:" - echo " git mergetool" - echo " git commit" - echo - echo "You can then complete the finish by running it again:" - echo " git flow feature finish $NAME" - echo - exit 1 - fi - fi - - # sanity checks - require_clean_working_tree - - # update local repo with remote changes first, if asked - if has "$ORIGIN/$BRANCH" $(git_remote_branches); then - if flag fetch; then - git_do fetch -q "$ORIGIN" "$BRANCH" - git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH" - fi - fi - - if has "$ORIGIN/$BRANCH" $(git_remote_branches); then - require_branches_equal "$BRANCH" "$ORIGIN/$BRANCH" - fi - if has "$ORIGIN/$DEVELOP_BRANCH" $(git_remote_branches); then - require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH" - fi - - # if the user wants to rebase, do that first - if flag rebase; then - if ! git flow feature rebase "$NAME" "$DEVELOP_BRANCH"; then - warn "Finish was aborted due to conflicts during rebase." - warn "Please finish the rebase manually now." - warn "When finished, re-run:" - warn " git flow feature finish '$NAME' '$DEVELOP_BRANCH'" - exit 1 - fi - fi - - # merge into BASE - git_do checkout "$DEVELOP_BRANCH" - if [ "$(git rev-list -n2 "$DEVELOP_BRANCH..$BRANCH" | wc -l)" -eq 1 ]; then - git_do merge --ff "$BRANCH" - else - if noflag squash; then - git_do merge --no-ff "$BRANCH" - else - git_do merge --squash "$BRANCH" - git_do commit - git_do merge "$BRANCH" - fi - fi - - if [ $? -ne 0 ]; then - # oops.. we have a merge conflict! - # write the given $DEVELOP_BRANCH to a temporary file (we need it later) - mkdir -p "$DOT_GIT_DIR/.gitflow" - echo "$DEVELOP_BRANCH" > "$DOT_GIT_DIR/.gitflow/MERGE_BASE" - echo - echo "There were merge conflicts. To resolve the merge conflict manually, use:" - echo " git mergetool" - echo " git commit" - echo - echo "You can then complete the finish by running it again:" - echo " git flow feature finish $NAME" - echo - exit 1 - fi - - # when no merge conflict is detected, just clean up the feature branch - helper_finish_cleanup -} - -helper_finish_cleanup() { - # sanity checks - require_branch "$BRANCH" - require_clean_working_tree - - # delete branch - if flag fetch; then - git_do push "$ORIGIN" ":refs/heads/$BRANCH" - fi - - - if noflag keep; then - if flag force_delete; then - git_do branch -D "$BRANCH" - else - git_do branch -d "$BRANCH" - fi - fi - - echo - echo "Summary of actions:" - echo "- The feature branch '$BRANCH' was merged into '$DEVELOP_BRANCH'" - #echo "- Merge conflicts were resolved" # TODO: Add this line when it's supported - if flag keep; then - echo "- Feature branch '$BRANCH' is still available" - else - echo "- Feature branch '$BRANCH' has been removed" - fi - echo "- You are now on branch '$DEVELOP_BRANCH'" - echo -} - -cmd_publish() { - parse_args "$@" - expand_nameprefix_arg - - # sanity checks - require_clean_working_tree - require_branch "$BRANCH" - git_do fetch -q "$ORIGIN" - require_branch_absent "$ORIGIN/$BRANCH" - - # create remote branch - git_do push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH" - git_do fetch -q "$ORIGIN" - - # configure remote tracking - git_do config "branch.$BRANCH.remote" "$ORIGIN" - git_do config "branch.$BRANCH.merge" "refs/heads/$BRANCH" - git_do 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 "$@" - require_name_arg - - # sanity checks - require_clean_working_tree - require_branch_absent "$BRANCH" - git_do fetch -q "$ORIGIN" - require_branch "$ORIGIN/$BRANCH" - - # create tracking branch - git_do 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 -} - -cmd_diff() { - parse_args "$@" - - if [ "$NAME" != "" ]; then - expand_nameprefix_arg - BASE=$(git merge-base "$DEVELOP_BRANCH" "$BRANCH") - git diff "$BASE..$BRANCH" - else - if ! git_current_branch | grep -q "^$PREFIX"; then - die "Not on a feature branch. Name one explicitly." - fi - - BASE=$(git merge-base "$DEVELOP_BRANCH" HEAD) - git diff "$BASE" - fi -} - -cmd_checkout() { - parse_args "$@" - - if [ "$NAME" != "" ]; then - expand_nameprefix_arg - git_do checkout "$BRANCH" - else - die "Name a feature branch explicitly." - fi -} - -cmd_co() { - # Alias for checkout - cmd_checkout "$@" -} - -cmd_rebase() { - DEFINE_boolean interactive false 'do an interactive rebase' i - parse_args "$@" - expand_nameprefix_arg_or_current - warn "Will try to rebase '$NAME'..." - require_clean_working_tree - require_branch "$BRANCH" - - git_do checkout -q "$BRANCH" - local OPTS= - if flag interactive; then - OPTS="$OPTS -i" - fi - git_do rebase $OPTS "$DEVELOP_BRANCH" -} - -avoid_accidental_cross_branch_action() { - local current_branch=$(git_current_branch) - if [ "$BRANCH" != "$current_branch" ]; then - warn "Trying to pull from '$BRANCH' while currently on branch '$current_branch'." - warn "To avoid unintended merges, git-flow aborted." - return 1 - fi - return 0 -} - -cmd_pull() { - #DEFINE_string prefix false 'alternative remote feature branch name prefix' p - DEFINE_boolean rebase false "pull with rebase" r - parse_remote_name "$@" - - if [ -z "$REMOTE" ]; then - die "Name a remote explicitly." - fi - name_or_current - - # To avoid accidentally merging different feature branches into each other, - # die if the current feature branch differs from the requested $NAME - # argument. - local current_branch=$(git_current_branch) - if startswith "$current_branch" "$PREFIX"; then - # we are on a local feature branch already, so $BRANCH must be equal to - # the current branch - avoid_accidental_cross_branch_action || die - fi - - require_clean_working_tree - - if git_branch_exists "$BRANCH"; then - # Again, avoid accidental merges - avoid_accidental_cross_branch_action || die - - # we already have a local branch called like this, so simply pull the - # remote changes in - if flag rebase; then - if ! git_do pull --rebase -q "$REMOTE" "$BRANCH"; then - warn "Pull was aborted. There might be conflicts during rebase or '$REMOTE' might be inaccessible." - exit 1 - fi - else - git_do pull -q "$REMOTE" "$BRANCH" || die "Failed to pull from remote '$REMOTE'." - fi - - echo "Pulled $REMOTE's changes into $BRANCH." - else - # setup the local branch clone for the first time - git_do fetch -q "$REMOTE" "$BRANCH" || die "Fetch failed." # stores in FETCH_HEAD - git_do branch --no-track "$BRANCH" FETCH_HEAD || die "Branch failed." - git_do checkout -q "$BRANCH" || die "Checking out new local branch failed." - echo "Created local branch $BRANCH based on $REMOTE's $BRANCH." - fi -} diff --git a/git-flow-init b/git-flow-init deleted file mode 100644 index 60eb7ba..0000000 --- a/git-flow-init +++ /dev/null @@ -1,347 +0,0 @@ -# -# git-flow -- A collection of Git extensions to provide high-level -# repository operations for Vincent Driessen's branching model. -# -# Original blog post presenting this model is found at: -# http://nvie.com/git-model -# -# Feel free to contribute to this project at: -# http://github.com/nvie/gitflow -# -# Copyright 2010 Vincent Driessen. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -# EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# The views and conclusions contained in the software and documentation are -# those of the authors and should not be interpreted as representing official -# policies, either expressed or implied, of Vincent Driessen. -# - -usage() { - echo "usage: git flow init [-fd]" -} - -parse_args() { - # parse options - FLAGS "$@" || exit $? - eval set -- "${FLAGS_ARGV}" -} - -# Default entry when no SUBACTION is given -cmd_default() { - DEFINE_boolean force false 'force setting of gitflow branches, even if already configured' f - DEFINE_boolean defaults false 'use default branch naming conventions' d - parse_args "$@" - - if ! git rev-parse --git-dir >/dev/null 2>&1; then - git_do init - else - # assure that we are not working in a repo with local changes - git_repo_is_headless || require_clean_working_tree - fi - - # running git flow init on an already initialized repo is fine - if gitflow_is_initialized && ! flag force; then - warn "Already initialized for gitflow." - warn "To force reinitialization, use: git flow init -f" - exit 0 - fi - - local branch_count - local answer - - if flag defaults; then - warn "Using default branch names." - fi - - # add a master branch if no such branch exists yet - local master_branch - if gitflow_has_master_configured && ! flag force; then - master_branch=$(git config --get gitflow.branch.master) - else - # Two cases are distinguished: - # 1. A fresh git repo (without any branches) - # We will create a new master/develop branch for the user - # 2. Some branches do already exist - # We will disallow creation of new master/develop branches and - # rather allow to use existing branches for git-flow. - local default_suggestion - local should_check_existence - branch_count=$(git_local_branches | wc -l) - if [ "$branch_count" -eq 0 ]; then - echo "No branches exist yet. Base branches must be created now." - should_check_existence=NO - default_suggestion=$(git config --get gitflow.branch.master || echo master) - else - echo - echo "Which branch should be used for bringing forth production releases?" - git_local_branches | sed 's/^.*$/ - &/g' - - should_check_existence=YES - default_suggestion= - for guess in $(git config --get gitflow.branch.master) \ - 'production' 'main' 'master'; do - if git_local_branch_exists "$guess"; then - default_suggestion="$guess" - break - fi - done - fi - - printf "Branch name for main development: [$default_suggestion] " - if noflag defaults; then - read answer - else - printf "\n" - fi - master_branch=${answer:-$default_suggestion} - - # check existence in case of an already existing repo - if [ "$should_check_existence" = "YES" ]; then - # if no local branch exists and a remote branch of the same - # name exists, checkout that branch and use it for master - if ! git_local_branch_exists "$master_branch" && \ - git_remote_branch_exists "origin/$master_branch"; then - git_do branch "$master_branch" "origin/$master_branch" >/dev/null 2>&1 - elif ! git_local_branch_exists "$master_branch"; then - die "Local branch '$master_branch' does not exist." - fi - fi - - # store the name of the master branch - git_do config gitflow.branch.master "$master_branch" - fi - - # add a develop branch if no such branch exists yet - local develop_branch - if gitflow_has_develop_configured && ! flag force; then - develop_branch=$(git config --get gitflow.branch.develop) - else - # Again, the same two cases as with the master selection are - # considered (fresh repo or repo that contains branches) - local default_suggestion - local should_check_existence - branch_count=$(git_local_branches | grep -v "^${master_branch}\$" | wc -l) - if [ "$branch_count" -eq 0 ]; then - should_check_existence=NO - default_suggestion=$(git config --get gitflow.branch.develop || echo develop) - else - echo - echo "Which branch should be used for integration of the \"next release\"?" - git_local_branches | grep -v "^${master_branch}\$" | sed 's/^.*$/ - &/g' - - should_check_existence=YES - default_suggestion= - for guess in $(git config --get gitflow.branch.develop) \ - 'develop' 'int' 'integration' 'master'; do - if git_local_branch_exists "$guess" && [ "$guess" != "$master_branch" ]; then - default_suggestion="$guess" - break - fi - done - - if [ -z $default_suggestion ]; then - should_check_existence=NO - default_suggestion=$(git config --get gitflow.branch.develop || echo develop) - fi - - fi - - printf "Branch name for \"legacy\" development: [qa] " - if noflag defaults; then - read answer - else - printf "\n" - fi - develop_branch=${answer:-$default_suggestion} - - if [ "$master_branch" = "$develop_branch" ]; then - die "Production and integration branches should differ." - fi - - # check existence in case of an already existing repo - if [ "$should_check_existence" = "YES" ]; then - git_local_branch_exists "$develop_branch" || \ - die "Local branch '$develop_branch' does not exist." - fi - - # store the name of the develop branch - git_do config gitflow.branch.develop "$develop_branch" - fi - - # Creation of HEAD - # ---------------- - # We create a HEAD now, if it does not exist yet (in a fresh repo). We need - # it to be able to create new branches. - local created_gitflow_branch=0 - if ! git rev-parse --quiet --verify HEAD >/dev/null 2>&1; then - git_do symbolic-ref HEAD "refs/heads/$master_branch" - git_do commit --allow-empty --quiet -m "Initial commit" - created_gitflow_branch=1 - fi - - # Creation of master - # ------------------ - # At this point, there always is a master branch: either it existed already - # (and was picked interactively as the production branch) or it has just - # been created in a fresh repo - - # Creation of develop - # ------------------- - # The develop branch possibly does not exist yet. This is the case when, - # in a git init'ed repo with one or more commits, master was picked as the - # default production branch and develop was "created". We should create - # the develop branch now in that case (we base it on master, of course) - if ! git_local_branch_exists "$develop_branch"; then - if git_remote_branch_exists "origin/$develop_branch"; then - git_do branch "$develop_branch" "origin/$develop_branch" >/dev/null 2>&1 - else - git_do branch --no-track "$develop_branch" "$master_branch" - fi - created_gitflow_branch=1 - fi - - # assert the gitflow repo has been correctly initialized - gitflow_is_initialized - - # switch to develop branch if its newly created - if [ $created_gitflow_branch -eq 1 ]; then - git_do checkout -q "$develop_branch" - fi - - # finally, ask the user for naming conventions (branch and tag prefixes) - if flag force || \ - ! git config --get gitflow.prefix.story >/dev/null 2>&1 || - ! git config --get gitflow.prefix.task >/dev/null 2>&1 || - ! git config --get gitflow.prefix.patch >/dev/null 2>&1 || - ! git config --get gitflow.prefix.feature >/dev/null 2>&1 || - ! git config --get gitflow.prefix.release >/dev/null 2>&1 || - ! git config --get gitflow.prefix.support >/dev/null 2>&1 || - ! git config --get gitflow.prefix.versiontag >/dev/null 2>&1; then - echo - echo "How to name your supporting branch prefixes?" - fi - - local prefix - - # Feature branches - if ! git config --get gitflow.prefix.feature >/dev/null 2>&1 || flag force; then - default_suggestion=$(git config --get gitflow.prefix.feature || echo feature/) - printf "Feature branches? [$default_suggestion] " - if noflag defaults; then - read answer - else - printf "\n" - fi - [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} - git_do config gitflow.prefix.feature "$prefix" - fi - - # Task branches - if ! git config --get gitflow.prefix.task >/dev/null 2>&1 || flag force; then - default_suggestion=$(git config --get gitflow.prefix.task || echo task/) - printf "Task branches? [$default_suggestion] " - if noflag defaults; then - read answer - else - printf "\n" - fi - [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} - git_do config gitflow.prefix.task "$prefix" - fi - - # Release branches - if ! git config --get gitflow.prefix.release >/dev/null 2>&1 || flag force; then - default_suggestion=$(git config --get gitflow.prefix.release || echo release/) - printf "Release branches? [$default_suggestion] " - if noflag defaults; then - read answer - else - printf "\n" - fi - [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} - git_do config gitflow.prefix.release "$prefix" - fi - - - # Patch branches - if ! git config --get gitflow.prefix.patch >/dev/null 2>&1 || flag force; then - default_suggestion=$(git config --get gitflow.prefix.patch || echo patch/) - printf "Patch branches? [$default_suggestion] " - if noflag defaults; then - read answer - else - printf "\n" - fi - [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} - git_do config gitflow.prefix.patch "$prefix" - fi - - # Story branches - if ! git config --get gitflow.prefix.story >/dev/null 2>&1 || flag force; then - default_suggestion=$(git config --get gitflow.prefix.story || echo story/) - printf "Story branches? [$default_suggestion] " - if noflag defaults; then - read answer - else - printf "\n" - fi - [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} - git_do config gitflow.prefix.story "$prefix" - fi - - - # Support branches - if ! git config --get gitflow.prefix.support >/dev/null 2>&1 || flag force; then - default_suggestion=$(git config --get gitflow.prefix.support || echo support/) - printf "Support branches? [$default_suggestion] " - if noflag defaults; then - read answer - else - printf "\n" - fi - [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} - git_do config gitflow.prefix.support "$prefix" - fi - - - # Version tag prefix - if ! git config --get gitflow.prefix.versiontag >/dev/null 2>&1 || flag force; then - default_suggestion=$(git config --get gitflow.prefix.versiontag || echo "") - printf "Version tag prefix? [$default_suggestion] " - if noflag defaults; then - read answer - else - printf "\n" - fi - [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} - git_do config gitflow.prefix.versiontag "$prefix" - fi - - - # TODO: what to do with origin? -} - -cmd_help() { - usage - exit 0 -} diff --git a/git-flow-patch b/git-flow-patch deleted file mode 100644 index 5c63187..0000000 --- a/git-flow-patch +++ /dev/null @@ -1,349 +0,0 @@ -# -# git-flow -- A collection of Git extensions to provide high-level -# repository operations for Vincent Driessen's branching model. -# -# Original blog post presenting this model is found at: -# http://nvie.com/git-model -# -# Feel free to contribute to this project at: -# http://github.com/nvie/gitflow -# -# Copyright 2010 Vincent Driessen. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -# EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# The views and conclusions contained in the software and documentation are -# those of the authors and should not be interpreted as representing official -# policies, either expressed or implied, of Vincent Driessen. -# - -init() { - require_git_repo - require_gitflow_initialized - gitflow_load_settings - VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`") - PREFIX=$(git config --get gitflow.prefix.patch) -} - -usage() { - echo "usage: git flow patch [list] [-v]" - echo " git flow patch start [-F] []" - echo " git flow patch finish [-Fsumpk] " - echo " git flow patch publish " - echo " git flow patch track " -} - -cmd_default() { - cmd_list "$@" -} - -cmd_list() { - DEFINE_boolean verbose false 'verbose (more) output' v - parse_args "$@" - - local patch_branches - local current_branch - local short_names - patch_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX") - if [ -z "$patch_branches" ]; then - warn "No Patch branches exist." - warn "" - warn "You can start a new Patch branch:" - warn "" - warn " git flow patch start []" - warn "" - exit 0 - fi - current_branch=$(git branch --no-color | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g') - short_names=$(echo "$patch_branches" | sed "s ^$PREFIX g") - - # determine column width first - local width=0 - local branch - for branch in $short_names; do - local len=${#branch} - width=$(max $width $len) - done - width=$(($width+3)) - - local branch - for branch in $short_names; do - local fullname=$PREFIX$branch - local base=$(git merge-base "$fullname" "$MASTER_BRANCH") - local master_sha=$(git rev-parse "$MASTER_BRANCH") - local branch_sha=$(git rev-parse "$fullname") - if [ "$fullname" = "$current_branch" ]; then - printf "* " - else - printf " " - fi - if flag verbose; then - printf "%-${width}s" "$branch" - if [ "$branch_sha" = "$master_sha" ]; then - printf "(no commits yet)" - else - local tagname=$(git name-rev --tags --no-undefined --name-only "$base") - local nicename - if [ "$tagname" != "" ]; then - nicename=$tagname - else - nicename=$(git rev-parse --short "$base") - fi - printf "(based on $nicename)" - fi - else - printf "%s" "$branch" - fi - echo - done -} - -cmd_help() { - usage - exit 0 -} - -parse_args() { - # parse options - FLAGS "$@" || exit $? - eval set -- "${FLAGS_ARGV}" - - # read arguments into global variables - VERSION=$1 - BRANCH=$PREFIX$VERSION -} - -require_version_arg() { - if [ "$VERSION" = "" ]; then - warn "Missing argument " - usage - exit 1 - fi -} - -require_base_is_on_master() { - if ! git branch --no-color --contains "$BASE" 2>/dev/null \ - | sed 's/[* ] //g' \ - | grep -q "^$MASTER_BRANCH\$"; then - die "fatal: Given base '$BASE' is not a valid commit on '$MASTER_BRANCH'." - fi -} - -require_no_existing_patch_branches() { - local patch_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX") - local first_branch=$(echo ${patch_branches} | head -n1) - first_branch=${first_branch#$PREFIX} - [ -z "$patch_branches" ] || \ - die "There is an existing Patch branch ($first_branch). Finish that one first." -} - -cmd_start() { - DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F - parse_args "$@" - BASE=${2:-$MASTER_BRANCH} - require_version_arg - require_base_is_on_master - require_no_existing_patch_branches - - # sanity checks - require_clean_working_tree - require_branch_absent "$BRANCH" - require_tag_absent "$VERSION_PREFIX$VERSION" - if flag fetch; then - git_do fetch -q "$ORIGIN" "$MASTER_BRANCH" - fi - if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then - require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH" - fi - - # create branch - git_do 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 patch finish '$VERSION'" - echo -} - -cmd_publish() { - parse_args "$@" - require_version_arg - - # sanity checks - require_clean_working_tree - require_branch "$BRANCH" - git_do fetch -q "$ORIGIN" - require_branch_absent "$ORIGIN/$BRANCH" - - # create remote branch - git_do push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH" - git_do fetch -q "$ORIGIN" - - # configure remote tracking - git config "branch.$BRANCH.remote" "$ORIGIN" - git config "branch.$BRANCH.merge" "refs/heads/$BRANCH" - git_do 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 "$@" - require_version_arg - - # sanity checks - require_clean_working_tree - require_branch_absent "$BRANCH" - git_do fetch -q "$ORIGIN" - require_branch "$ORIGIN/$BRANCH" - - # create tracking branch - git_do 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 -} - -cmd_finish() { - DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F - DEFINE_boolean sign false "sign the release tag cryptographically" s - DEFINE_string signingkey "" "use the given GPG-key for the digital signature (implies -s)" u - DEFINE_string message "" "use the given tag message" m - DEFINE_string messagefile "" "use the contents of the given file as tag message" f - DEFINE_boolean push false "push to $ORIGIN after performing finish" p - DEFINE_boolean keep false "keep branch after performing finish" k - DEFINE_boolean notag false "don't tag this release" n - parse_args "$@" - require_version_arg - - # handle flags that imply other flags - if [ "$FLAGS_signingkey" != "" ]; then - FLAGS_sign=$FLAGS_TRUE - fi - - # sanity checks - require_branch "$BRANCH" - require_clean_working_tree - if flag fetch; then - git_do fetch -q "$ORIGIN" "$MASTER_BRANCH" || \ - die "Could not fetch $MASTER_BRANCH from $ORIGIN." - git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \ - die "Could not fetch $DEVELOP_BRANCH from $ORIGIN." - fi - if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then - require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH" - fi - if has "$ORIGIN/$DEVELOP_BRANCH" $(git_remote_branches); then - require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH" - fi - - # try to merge into master - # in case a previous attempt to finish this release branch has failed, - # but the merge into master was successful, we skip it now - if ! git_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then - git_do checkout "$MASTER_BRANCH" || \ - die "Could not check out $MASTER_BRANCH." - git_do merge --no-ff "$BRANCH" || \ - die "There were merge conflicts." - # TODO: What do we do now? - fi - - if noflag notag; then - # try to tag the release - # in case a previous attempt to finish this release branch has failed, - # but the tag was set successful, we skip it now - local tagname=$VERSION_PREFIX$VERSION - if ! git_tag_exists "$tagname"; then - local opts="-a" - flag sign && opts="$opts -s" - [ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'" - [ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'" - [ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'" - eval git_do tag $opts "$VERSION_PREFIX$VERSION" "$BRANCH" || \ - die "Tagging failed. Please run finish again to retry." - fi - fi - - # try to merge into develop - # in case a previous attempt to finish this release branch has failed, - # but the merge into develop was successful, we skip it now - if ! git_is_branch_merged_into "$BRANCH" "$DEVELOP_BRANCH"; then - git_do checkout "$DEVELOP_BRANCH" || \ - die "Could not check out $DEVELOP_BRANCH." - - # TODO: Actually, accounting for 'git describe' pays, so we should - # ideally git merge --no-ff $tagname here, instead! - git_do merge --no-ff "$BRANCH" || \ - die "There were merge conflicts." - # TODO: What do we do now? - fi - - # delete branch - if noflag keep; then - git_do branch -d "$BRANCH" - fi - - if flag push; then - git_do push "$ORIGIN" "$DEVELOP_BRANCH" || \ - die "Could not push to $DEVELOP_BRANCH from $ORIGIN." - git_do push "$ORIGIN" "$MASTER_BRANCH" || \ - die "Could not push to $MASTER_BRANCH from $ORIGIN." - if noflag notag; then - git_do push --tags "$ORIGIN" || \ - die "Could not push tags to $ORIGIN." - fi - fi - - echo - echo "Summary of actions:" - echo "- Latest objects have been fetched from '$ORIGIN'" - echo "- Patch branch has been merged into '$MASTER_BRANCH'" - if noflag notag; then - echo "- The Patch was tagged '$VERSION_PREFIX$VERSION'" - fi - echo "- Patch branch has been back-merged into '$DEVELOP_BRANCH'" - if flag keep; then - echo "- Patch branch '$BRANCH' is still available" - else - echo "- Patch branch '$BRANCH' has been deleted" - fi - if flag push; then - echo "- '$DEVELOP_BRANCH', '$MASTER_BRANCH' and tags have been pushed to '$ORIGIN'" - fi - echo -} diff --git a/git-flow-release b/git-flow-release deleted file mode 100644 index cb95bd4..0000000 --- a/git-flow-release +++ /dev/null @@ -1,365 +0,0 @@ -# -# git-flow -- A collection of Git extensions to provide high-level -# repository operations for Vincent Driessen's branching model. -# -# Original blog post presenting this model is found at: -# http://nvie.com/git-model -# -# Feel free to contribute to this project at: -# http://github.com/nvie/gitflow -# -# Copyright 2010 Vincent Driessen. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -# EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# The views and conclusions contained in the software and documentation are -# those of the authors and should not be interpreted as representing official -# policies, either expressed or implied, of Vincent Driessen. -# - -init() { - require_git_repo - require_gitflow_initialized - gitflow_load_settings - VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`") - PREFIX=$(git config --get gitflow.prefix.release) -} - -usage() { - echo "usage: git flow release [list] [-v]" - echo " git flow release start [-F] []" - echo " git flow release finish [-FsumpkS] " - echo " git flow release publish " - echo " git flow release track " -} - -cmd_default() { - cmd_list "$@" -} - -cmd_list() { - DEFINE_boolean verbose false 'verbose (more) output' v - parse_args "$@" - - local release_branches - local current_branch - local short_names - release_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX") - if [ -z "$release_branches" ]; then - warn "No release branches exist." - warn "" - warn "You can start a new release branch:" - warn "" - warn " git flow release start []" - warn "" - exit 0 - fi - - current_branch=$(git branch --no-color | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g') - short_names=$(echo "$release_branches" | sed "s ^$PREFIX g") - - # determine column width first - local width=0 - local branch - for branch in $short_names; do - local len=${#branch} - width=$(max $width $len) - done - width=$(($width+3)) - - local branch - for branch in $short_names; do - local fullname=$PREFIX$branch - local base=$(git merge-base "$fullname" "$DEVELOP_BRANCH") - local develop_sha=$(git rev-parse "$DEVELOP_BRANCH") - local branch_sha=$(git rev-parse "$fullname") - if [ "$fullname" = "$current_branch" ]; then - printf "* " - else - printf " " - fi - if flag verbose; then - printf "%-${width}s" "$branch" - if [ "$branch_sha" = "$develop_sha" ]; then - printf "(no commits yet)" - else - local nicename=$(git rev-parse --short "$base") - printf "(based on $nicename)" - fi - else - printf "%s" "$branch" - fi - echo - done -} - -cmd_help() { - usage - exit 0 -} - -parse_args() { - # parse options - FLAGS "$@" || exit $? - eval set -- "${FLAGS_ARGV}" - - # read arguments into global variables - VERSION=$1 - BRANCH=$PREFIX$VERSION -} - -require_version_arg() { - if [ "$VERSION" = "" ]; then - warn "Missing argument " - usage - exit 1 - fi -} - -require_base_is_on_develop() { - if ! git_do branch --no-color --contains "$BASE" 2>/dev/null \ - | sed 's/[* ] //g' \ - | grep -q "^$DEVELOP_BRANCH\$"; then - die "fatal: Given base '$BASE' is not a valid commit on '$DEVELOP_BRANCH'." - fi -} - -require_no_existing_release_branches() { - local release_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX") - local first_branch=$(echo ${release_branches} | head -n1) - first_branch=${first_branch#$PREFIX} - [ -z "$release_branches" ] || \ - die "There is an existing release branch ($first_branch). Finish that one first." -} - -cmd_start() { - DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F - parse_args "$@" - BASE=${2:-$DEVELOP_BRANCH} - require_version_arg - require_base_is_on_develop - require_no_existing_release_branches - - # sanity checks - require_clean_working_tree - require_branch_absent "$BRANCH" - require_tag_absent "$VERSION_PREFIX$VERSION" - if flag fetch; then - git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH" - fi - if has "$ORIGIN/$DEVELOP_BRANCH" $(git_remote_branches); then - require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH" - fi - - # create branch - git_do 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 last-minute fixes in preparing your release" - echo "- When done, run:" - echo - echo " git flow release finish '$VERSION'" - echo -} - -cmd_finish() { - DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F - DEFINE_boolean sign false "sign the release tag cryptographically" s - DEFINE_string signingkey "" "use the given GPG-key for the digital signature (implies -s)" u - DEFINE_string message "" "use the given tag message" m - DEFINE_string messagefile "" "use the contents of the given file as a tag message" f - DEFINE_boolean push false "push to $ORIGIN after performing finish" p - DEFINE_boolean keep false "keep branch after performing finish" k - DEFINE_boolean notag false "don't tag this release" n - DEFINE_boolean squash false "squash release during merge" S - - parse_args "$@" - require_version_arg - - # handle flags that imply other flags - if [ "$FLAGS_signingkey" != "" ]; then - FLAGS_sign=$FLAGS_TRUE - fi - - # sanity checks - require_branch "$BRANCH" - require_clean_working_tree - if flag fetch; then - git_do fetch -q "$ORIGIN" "$MASTER_BRANCH" || \ - die "Could not fetch $MASTER_BRANCH from $ORIGIN." - git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \ - die "Could not fetch $DEVELOP_BRANCH from $ORIGIN." - fi - if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then - require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH" - fi - if has "$ORIGIN/$DEVELOP_BRANCH" $(git_remote_branches); then - require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH" - fi - - # try to merge into master - # in case a previous attempt to finish this release branch has failed, - # but the merge into master was successful, we skip it now - if ! git_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then - git_do checkout "$MASTER_BRANCH" || \ - die "Could not check out $MASTER_BRANCH." - if noflag squash; then - git_do merge --no-ff "$BRANCH" || \ - die "There were merge conflicts." - # TODO: What do we do now? - else - git_do merge --squash "$BRANCH" || \ - die "There were merge conflicts." - git_do commit - fi - fi - - if noflag notag; then - # try to tag the release - # in case a previous attempt to finish this release branch has failed, - # but the tag was set successful, we skip it now - local tagname=$VERSION_PREFIX$VERSION - if ! git_tag_exists "$tagname"; then - local opts="-a" - flag sign && opts="$opts -s" - [ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'" - [ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'" - [ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'" - eval git_do tag $opts "$tagname" "$BRANCH" || \ - die "Tagging failed. Please run finish again to retry." - fi - fi - - # try to merge into develop - # in case a previous attempt to finish this release branch has failed, - # but the merge into develop was successful, we skip it now - if ! git_is_branch_merged_into "$BRANCH" "$DEVELOP_BRANCH"; then - git_do checkout "$DEVELOP_BRANCH" || \ - die "Could not check out $DEVELOP_BRANCH." - - # TODO: Actually, accounting for 'git describe' pays, so we should - # ideally git merge --no-ff $tagname here, instead! - if noflag squash; then - git_do merge --no-ff "$BRANCH" || \ - die "There were merge conflicts." - # TODO: What do we do now? - else - git_do merge --squash "$BRANCH" || \ - die "There were merge conflicts." - # TODO: What do we do now? - git_do commit - fi - fi - - # delete branch - if noflag keep; then - if [ "$BRANCH" = "$(git_current_branch)" ]; then - git_do checkout "$MASTER_BRANCH" - fi - git_do branch -d "$BRANCH" - fi - - if flag push; then - git_do push "$ORIGIN" "$DEVELOP_BRANCH" || \ - die "Could not push to $DEVELOP_BRANCH from $ORIGIN." - git_do push "$ORIGIN" "$MASTER_BRANCH" || \ - die "Could not push to $MASTER_BRANCH from $ORIGIN." - if noflag notag; then - git_do push --tags "$ORIGIN" || \ - die "Could not push tags to $ORIGIN." - fi - git_do push "$ORIGIN" :"$BRANCH" || \ - die "Could not delete the remote $BRANCH in $ORIGIN." - fi - - echo - echo "Summary of actions:" - echo "- Latest objects have been fetched from '$ORIGIN'" - echo "- Release branch has been merged into '$MASTER_BRANCH'" - if noflag notag; then - echo "- The release was tagged '$tagname'" - fi - echo "- Release branch has been back-merged into '$DEVELOP_BRANCH'" - if flag keep; then - echo "- Release branch '$BRANCH' is still available" - else - echo "- Release branch '$BRANCH' has been deleted" - fi - if flag push; then - echo "- '$DEVELOP_BRANCH', '$MASTER_BRANCH' and tags have been pushed to '$ORIGIN'" - echo "- Release branch '$BRANCH' in '$ORIGIN' has been deleted." - fi - echo -} - -cmd_publish() { - parse_args "$@" - require_version_arg - - # sanity checks - require_clean_working_tree - require_branch "$BRANCH" - git_do fetch -q "$ORIGIN" - require_branch_absent "$ORIGIN/$BRANCH" - - # create remote branch - git_do push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH" - git_do fetch -q "$ORIGIN" - - # configure remote tracking - git_do config "branch.$BRANCH.remote" "$ORIGIN" - git_do config "branch.$BRANCH.merge" "refs/heads/$BRANCH" - git_do 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 "$@" - require_version_arg - - # sanity checks - require_clean_working_tree - require_branch_absent "$BRANCH" - git_do fetch -q "$ORIGIN" - require_branch "$ORIGIN/$BRANCH" - - # create tracking branch - git_do 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 -} diff --git a/git-flow-standard b/git-flow-standard deleted file mode 100755 index 79db1b0..0000000 --- a/git-flow-standard +++ /dev/null @@ -1,129 +0,0 @@ -#!/bin/sh -# -# git-flow -- A collection of Git extensions to provide high-level -# repository operations for Vincent Driessen's branching model. -# -# Original blog post presenting this model is found at: -# http://nvie.com/git-model -# -# Feel free to contribute to this project at: -# http://github.com/nvie/gitflow -# -# Copyright 2010 Vincent Driessen. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -# EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# The views and conclusions contained in the software and documentation are -# those of the authors and should not be interpreted as representing official -# policies, either expressed or implied, of Vincent Driessen. -# - -# set this to workaround expr problems in shFlags on freebsd -if uname -s | egrep -iq 'bsd'; then export EXPR_COMPAT=1; fi - -# enable debug mode -if [ "$DEBUG" = "yes" ]; then - set -x -fi - -# The sed expression here replaces all backslashes by forward slashes. -# This helps our Windows users, while not bothering our Unix users. -export GITFLOW_DIR=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')") - -usage() { - echo "usage: git flow " - echo - echo "Current Agile Subcommands Are:" - echo " init Initialize a new git repo with support for the branching model." - echo " story Manage your story branches." - echo " task Manage your task branches." - echo " patch Manage your patch branches." - echo "" - echo "Legacy Subcommands Are:" - echo " feature Manage your feature branches." - echo "" - echo "Other Subcommands Are:" - echo " release Manage your release branches." - echo " support Manage your support branches." - echo " version Shows version information." - echo - echo "Try 'git flow help' for details." -} - -main() { - if [ $# -lt 1 ]; then - usage - exit 1 - fi - - # load common functionality - . "$GITFLOW_DIR/gitflow-common" - - # This environmental variable fixes non-POSIX getopt style argument - # parsing, effectively breaking git-flow subcommand parsing on several - # Linux platforms. - export POSIXLY_CORRECT=1 - - # use the shFlags project to parse the command line arguments - . "$GITFLOW_DIR/gitflow-shFlags" - FLAGS_PARENT="git flow" - - # allow user to request git action logging - DEFINE_boolean show_commands false 'show actions taken (git commands)' g - - # do actual parsing - FLAGS "$@" || exit $? - eval set -- "${FLAGS_ARGV}" - - # sanity checks - SUBCOMMAND="$1"; shift - - if [ ! -e "$GITFLOW_DIR/git-flow-$SUBCOMMAND" ]; then - usage - exit 1 - fi - - # run command - . "$GITFLOW_DIR/git-flow-$SUBCOMMAND" - FLAGS_PARENT="git flow $SUBCOMMAND" - - # test if the first argument is a flag (i.e. starts with '-') - # in that case, we interpret this arg as a flag for the default - # command - SUBACTION="default" - if [ "$1" != "" ] && { ! echo "$1" | grep -q "^-"; } then - SUBACTION="$1"; shift - fi - if ! type "cmd_$SUBACTION" >/dev/null 2>&1; then - warn "Unknown subcommand: '$SUBACTION'" - usage - exit 1 - fi - - # run the specified action - if [ $SUBACTION != "help" ] && [ $SUBCOMMAND != "init" ] ; then - init - fi - cmd_$SUBACTION "$@" -} - -main "$@" diff --git a/git-flow-story b/git-flow-story deleted file mode 100644 index c768d27..0000000 --- a/git-flow-story +++ /dev/null @@ -1,348 +0,0 @@ -# -# git-flow -- A collection of Git extensions to provide high-level -# repository operations for Vincent Driessen's branching model. -# -# Original blog post presenting this model is found at: -# http://nvie.com/git-model -# -# Feel free to contribute to this project at: -# http://github.com/nvie/gitflow -# -# Copyright 2010 Vincent Driessen. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -# EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# The views and conclusions contained in the software and documentation are -# those of the authors and should not be interpreted as representing official -# policies, either expressed or implied, of Vincent Driessen. -# - -init() { - require_git_repo - require_gitflow_initialized - gitflow_load_settings - VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`") - PREFIX=$(git config --get gitflow.prefix.story) -} - -usage() { - echo "usage: git flow story [list] [-v]" - echo " git flow story start [-F] []" - echo " git flow story finish [-Fsumpk] " - echo " git flow story publish " - echo " git flow story track " -} - -cmd_default() { - cmd_list "$@" -} - -cmd_list() { - DEFINE_boolean verbose false 'verbose (more) output' v - parse_args "$@" - - local story_branches - local current_branch - local short_names - story_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX") - if [ -z "$story_branches" ]; then - warn "No Story branches exist." - warn "" - warn "You can start a new Story branch:" - warn "" - warn " git flow story start []" - warn "" - exit 0 - fi - current_branch=$(git branch --no-color | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g') - short_names=$(echo "$story_branches" | sed "s ^$PREFIX g") - - # determine column width first - local width=0 - local branch - for branch in $short_names; do - local len=${#branch} - width=$(max $width $len) - done - width=$(($width+3)) - - local branch - for branch in $short_names; do - local fullname=$PREFIX$branch - local base=$(git merge-base "$fullname" "$MASTER_BRANCH") - local master_sha=$(git rev-parse "$MASTER_BRANCH") - local branch_sha=$(git rev-parse "$fullname") - if [ "$fullname" = "$current_branch" ]; then - printf "* " - else - printf " " - fi - if flag verbose; then - printf "%-${width}s" "$branch" - if [ "$branch_sha" = "$master_sha" ]; then - printf "(no commits yet)" - else - local tagname=$(git name-rev --tags --no-undefined --name-only "$base") - local nicename - if [ "$tagname" != "" ]; then - nicename=$tagname - else - nicename=$(git rev-parse --short "$base") - fi - printf "(based on $nicename)" - fi - else - printf "%s" "$branch" - fi - echo - done -} - -cmd_help() { - usage - exit 0 -} - -parse_args() { - # parse options - FLAGS "$@" || exit $? - eval set -- "${FLAGS_ARGV}" - - # read arguments into global variables - VERSION=$1 - BRANCH=$PREFIX$VERSION -} - -require_version_arg() { - if [ "$VERSION" = "" ]; then - warn "Missing argument " - usage - exit 1 - fi -} - -require_base_is_on_master() { - if ! git branch --no-color --contains "$BASE" 2>/dev/null \ - | sed 's/[* ] //g' \ - | grep -q "^$MASTER_BRANCH\$"; then - die "fatal: Given base '$BASE' is not a valid commit on '$MASTER_BRANCH'." - fi -} - -require_no_existing_story_branches() { - local story_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX") - local first_branch=$(echo ${story_branches} | head -n1) - first_branch=${first_branch#$PREFIX} - [ -z "$story_branches" ] || \ - die "There is an existing Story branch ($first_branch). Finish that one first." -} - -cmd_start() { - DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F - parse_args "$@" - BASE=${2:-$MASTER_BRANCH} - require_version_arg - require_base_is_on_master - - # sanity checks - require_clean_working_tree - require_branch_absent "$BRANCH" - require_tag_absent "$VERSION_PREFIX$VERSION" - if flag fetch; then - git_do fetch -q "$ORIGIN" "$MASTER_BRANCH" - fi - if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then - require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH" - fi - - # create branch - git_do 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 story finish '$VERSION'" - echo -} - -cmd_publish() { - parse_args "$@" - require_version_arg - - # sanity checks - require_clean_working_tree - require_branch "$BRANCH" - git_do fetch -q "$ORIGIN" - require_branch_absent "$ORIGIN/$BRANCH" - - # create remote branch - git_do push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH" - git_do fetch -q "$ORIGIN" - - # configure remote tracking - git config "branch.$BRANCH.remote" "$ORIGIN" - git config "branch.$BRANCH.merge" "refs/heads/$BRANCH" - git_do 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 "$@" - require_version_arg - - # sanity checks - require_clean_working_tree - require_branch_absent "$BRANCH" - git_do fetch -q "$ORIGIN" - require_branch "$ORIGIN/$BRANCH" - - # create tracking branch - git_do 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 -} - -cmd_finish() { - DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F - DEFINE_boolean sign false "sign the release tag cryptographically" s - DEFINE_string signingkey "" "use the given GPG-key for the digital signature (implies -s)" u - DEFINE_string message "" "use the given tag message" m - DEFINE_string messagefile "" "use the contents of the given file as tag message" f - DEFINE_boolean push false "push to $ORIGIN after performing finish" p - DEFINE_boolean keep false "keep branch after performing finish" k - DEFINE_boolean notag false "don't tag this release" n - parse_args "$@" - require_version_arg - - # handle flags that imply other flags - if [ "$FLAGS_signingkey" != "" ]; then - FLAGS_sign=$FLAGS_TRUE - fi - - # sanity checks - require_branch "$BRANCH" - require_clean_working_tree - if flag fetch; then - git_do fetch -q "$ORIGIN" "$MASTER_BRANCH" || \ - die "Could not fetch $MASTER_BRANCH from $ORIGIN." - git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \ - die "Could not fetch $DEVELOP_BRANCH from $ORIGIN." - fi - if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then - require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH" - fi - if has "$ORIGIN/$DEVELOP_BRANCH" $(git_remote_branches); then - require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH" - fi - - # try to merge into master - # in case a previous attempt to finish this release branch has failed, - # but the merge into master was successful, we skip it now - if ! git_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then - git_do checkout "$MASTER_BRANCH" || \ - die "Could not check out $MASTER_BRANCH." - git_do merge --no-ff "$BRANCH" || \ - die "There were merge conflicts." - # TODO: What do we do now? - fi - - if noflag notag; then - # try to tag the release - # in case a previous attempt to finish this release branch has failed, - # but the tag was set successful, we skip it now - local tagname=$VERSION_PREFIX$VERSION - if ! git_tag_exists "$tagname"; then - local opts="-a" - flag sign && opts="$opts -s" - [ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'" - [ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'" - [ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'" - eval git_do tag $opts "$VERSION_PREFIX$VERSION" "$BRANCH" || \ - die "Tagging failed. Please run finish again to retry." - fi - fi - - # try to merge into develop - # in case a previous attempt to finish this release branch has failed, - # but the merge into develop was successful, we skip it now - if ! git_is_branch_merged_into "$BRANCH" "$DEVELOP_BRANCH"; then - git_do checkout "$DEVELOP_BRANCH" || \ - die "Could not check out $DEVELOP_BRANCH." - - # TODO: Actually, accounting for 'git describe' pays, so we should - # ideally git merge --no-ff $tagname here, instead! - git_do merge --no-ff "$BRANCH" || \ - die "There were merge conflicts." - # TODO: What do we do now? - fi - - # delete branch - if noflag keep; then - git_do branch -d "$BRANCH" - fi - - if flag push; then - git_do push "$ORIGIN" "$DEVELOP_BRANCH" || \ - die "Could not push to $DEVELOP_BRANCH from $ORIGIN." - git_do push "$ORIGIN" "$MASTER_BRANCH" || \ - die "Could not push to $MASTER_BRANCH from $ORIGIN." - if noflag notag; then - git_do push --tags "$ORIGIN" || \ - die "Could not push tags to $ORIGIN." - fi - fi - - echo - echo "Summary of actions:" - echo "- Latest objects have been fetched from '$ORIGIN'" - echo "- Story branch has been merged into '$MASTER_BRANCH'" - if noflag notag; then - echo "- The Story was tagged '$VERSION_PREFIX$VERSION'" - fi - echo "- Story branch has been back-merged into '$DEVELOP_BRANCH'" - if flag keep; then - echo "- Story branch '$BRANCH' is still available" - else - echo "- Story branch '$BRANCH' has been deleted" - fi - if flag push; then - echo "- '$DEVELOP_BRANCH', '$MASTER_BRANCH' and tags have been pushed to '$ORIGIN'" - fi - echo -} diff --git a/git-flow-support b/git-flow-support deleted file mode 100644 index cdbfc71..0000000 --- a/git-flow-support +++ /dev/null @@ -1,184 +0,0 @@ -# -# git-flow -- A collection of Git extensions to provide high-level -# repository operations for Vincent Driessen's branching model. -# -# Original blog post presenting this model is found at: -# http://nvie.com/git-model -# -# Feel free to contribute to this project at: -# http://github.com/nvie/gitflow -# -# Copyright 2010 Vincent Driessen. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -# EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# The views and conclusions contained in the software and documentation are -# those of the authors and should not be interpreted as representing official -# policies, either expressed or implied, of Vincent Driessen. -# - -init() { - require_git_repo - require_gitflow_initialized - gitflow_load_settings - VERSION_PREFIX=$(eval "echo `git config --get gitflow.prefix.versiontag`") - PREFIX=$(git config --get gitflow.prefix.support) -} - -warn "note: The support subcommand is still very EXPERIMENTAL!" -warn "note: DO NOT use it in a production situation." - -usage() { - echo "usage: git flow support [list] [-v]" - echo " git flow support start [-F] " -} - -cmd_default() { - cmd_list "$@" -} - -cmd_list() { - DEFINE_boolean verbose false 'verbose (more) output' v - parse_args "$@" - - local support_branches - local current_branch - local short_names - support_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX") - if [ -z "$support_branches" ]; then - warn "No support branches exist." - warn "" - warn "You can start a new support branch:" - warn "" - warn " git flow support start " - warn "" - exit 0 - fi - current_branch=$(git branch --no-color | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g') - short_names=$(echo "$support_branches" | sed "s ^$PREFIX g") - - # determine column width first - local width=0 - local branch - for branch in $short_names; do - local len=${#branch} - width=$(max $width $len) - done - width=$(($width+3)) - - local branch - for branch in $short_names; do - local fullname=$PREFIX$branch - local base=$(git merge-base "$fullname" "$MASTER_BRANCH") - local master_sha=$(git rev-parse "$MASTER_BRANCH") - local branch_sha=$(git rev-parse "$fullname") - if [ "$fullname" = "$current_branch" ]; then - printf "* " - else - printf " " - fi - if flag verbose; then - printf "%-${width}s" "$branch" - if [ "$branch_sha" = "$master_sha" ]; then - printf "(no commits yet)" - else - local tagname=$(git name-rev --tags --no-undefined --name-only "$base") - local nicename - if [ "$tagname" != "" ]; then - nicename=$tagname - else - nicename=$(git rev-parse --short "$base") - fi - printf "(based on $nicename)" - fi - else - printf "%s" "$branch" - fi - echo - done -} - -cmd_help() { - usage - exit 0 -} - -parse_args() { - # parse options - FLAGS "$@" || exit $? - eval set -- "${FLAGS_ARGV}" - - # read arguments into global variables - VERSION=$1 - BASE=$2 - BRANCH=$PREFIX$VERSION -} - -require_version_arg() { - if [ "$VERSION" = "" ]; then - warn "Missing argument " - usage - exit 1 - fi -} - -require_base_arg() { - if [ "$BASE" = "" ]; then - warn "Missing argument " - usage - exit 1 - fi -} - -require_base_is_on_master() { - if ! git branch --no-color --contains "$BASE" 2>/dev/null \ - | sed 's/[* ] //g' \ - | grep -q "^$MASTER_BRANCH\$"; then - die "fatal: Given base '$BASE' is not a valid commit on '$MASTER_BRANCH'." - fi -} - -cmd_start() { - DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F - parse_args "$@" - require_version_arg - require_base_arg - require_base_is_on_master - - # sanity checks - require_clean_working_tree - - # fetch remote changes - if flag fetch; then - git_do fetch -q "$ORIGIN" "$BASE" - fi - require_branch_absent "$BRANCH" - - # create branch - git_do 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 -} diff --git a/git-flow-task b/git-flow-task deleted file mode 100644 index f561622..0000000 --- a/git-flow-task +++ /dev/null @@ -1,540 +0,0 @@ -# -# git-flow -- A collection of Git extensions to provide high-level -# repository operations for Vincent Driessen's branching model. -# -# Original blog post presenting this model is found at: -# http://nvie.com/git-model -# -# Feel free to contribute to this project at: -# http://github.com/nvie/gitflow -# -# Copyright 2010 Vincent Driessen. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -# EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# The views and conclusions contained in the software and documentation are -# those of the authors and should not be interpreted as representing official -# policies, either expressed or implied, of Vincent Driessen. -# - -init() { - require_git_repo - require_gitflow_initialized - gitflow_load_settings - PREFIX=$(git config --get gitflow.prefix.task) - STORY_PREFIX=$(git config --get gitflow.prefix.story) -} - -usage() { - echo "usage: git flow task [list] [-v]" - echo " git flow task start [-F] " - echo " git flow task finish [-rFkDS] []" - echo " git flow task publish " - echo " git flow task track " - echo " git flow task diff []" - echo " git flow task rebase [-i] []" - echo " git flow task checkout []" - echo " git flow task pull [-r] []" -} - -cmd_default() { - cmd_list "$@" -} - -cmd_list() { - DEFINE_boolean verbose false 'verbose (more) output' v - parse_args "$@" - - local task_branches - local current_branch - local short_names - task_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX") - if [ -z "$task_branches" ]; then - warn "No Task branches exist." - warn "" - warn "You can start a new Task branch:" - warn "" - warn " git flow task start " - warn "" - exit 0 - fi - current_branch=$(git branch --no-color | grep '^\* ' | grep -v 'no branch' | sed 's/^* //g') - short_names=$(echo "$task_branches" | sed "s ^$PREFIX g") - - # determine column width first - local width=0 - local branch - for branch in $short_names; do - local len=${#branch} - width=$(max $width $len) - done - width=$(($width+3)) - - local branch - for branch in $short_names; do - local fullname=$PREFIX$branch - local base=$(git merge-base "$fullname" "$DEVELOP_BRANCH") - local develop_sha=$(git rev-parse "$DEVELOP_BRANCH") - local branch_sha=$(git rev-parse "$fullname") - if [ "$fullname" = "$current_branch" ]; then - printf "* " - else - printf " " - fi - if flag verbose; then - printf "%-${width}s" "$branch" - if [ "$branch_sha" = "$develop_sha" ]; then - printf "(no commits yet)" - elif [ "$base" = "$branch_sha" ]; then - printf "(is behind develop, may ff)" - elif [ "$base" = "$develop_sha" ]; then - printf "(based on latest develop)" - else - printf "(may be rebased)" - fi - else - printf "%s" "$branch" - fi - echo - done -} - -cmd_help() { - usage - exit 0 -} - -require_name_arg() { - if [ "$NAME" = "" ]; then - warn "Missing argument " - usage - exit 1 - fi -} -require_story_arg() { - if [ "$STORY" = "" ]; then - warn "Missing argument " - usage - exit 1 - fi -} - -expand_nameprefix_arg() { - require_name_arg - - local expanded_name - local exitcode - expanded_name=$(gitflow_resolve_nameprefix "$NAME" "$PREFIX") - exitcode=$? - case $exitcode in - 0) NAME=$expanded_name - BRANCH=$PREFIX$NAME - ;; - *) exit 1 ;; - esac -} - -use_current_task_branch_name() { - local current_branch=$(git_current_branch) - if startswith "$current_branch" "$PREFIX"; then - BRANCH=$current_branch - NAME=${BRANCH#$PREFIX} - else - warn "The current HEAD is no Task branch." - warn "Please specify a argument." - exit 1 - fi -} - -expand_nameprefix_arg_or_current() { - if [ "$NAME" != "" ]; then - expand_nameprefix_arg - require_branch "$PREFIX$NAME" - else - use_current_task_branch_name - fi -} - -name_or_current() { - if [ -z "$NAME" ]; then - use_current_task_branch_name - fi -} - -parse_args() { - # parse options - FLAGS "$@" || exit $? - eval set -- "${FLAGS_ARGV}" - - # read arguments into global variables - NAME=$1 - BRANCH=$PREFIX$NAME -} - -parse_remote_name() { - # parse options - FLAGS "$@" || exit $? - eval set -- "${FLAGS_ARGV}" - - # read arguments into global variables - REMOTE=$1 - NAME=$2 - BRANCH=$PREFIX$NAME -} - -cmd_start() { - DEFINE_boolean fetch false 'fetch from origin before performing local operation' F - parse_args "$@" - STORY=${2} - BASE=$STORY_PREFIX$STORY - require_name_arg - require_story_arg - - # sanity checks - require_branch_absent "$BRANCH" - - # update the local repo with remote changes, if asked - if flag fetch; then - git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH" - fi - - # if the origin branch counterpart exists, assert that the local branch - # isn't behind it (to avoid unnecessary rebasing) - if git_branch_exists "$ORIGIN/$DEVELOP_BRANCH"; then - require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH" - fi - - # create branch - if ! git_do checkout -b "$BRANCH" "$BASE"; then - die "Could not create Task branch '$BRANCH'" - fi - - 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 task. When done, use:" - echo "" - echo " git flow task finish $NAME" - echo -} - -cmd_finish() { - DEFINE_boolean fetch false "fetch from $ORIGIN before performing finish" F - DEFINE_boolean rebase false "rebase instead of merge" r - DEFINE_boolean keep false "keep branch after performing finish" k - DEFINE_boolean force_delete false "force delete Task branch after finish" D - DEFINE_boolean squash false "squash task during merge" S - parse_args "$@" - expand_nameprefix_arg_or_current - - # sanity checks - require_branch "$BRANCH" - - # detect if we're restoring from a merge conflict - if [ -f "$DOT_GIT_DIR/.gitflow/MERGE_BASE" ]; then - # - # TODO: detect that we're working on the correct branch here! - # The user need not necessarily have given the same $NAME twice here - # (although he/she should). - # - - # TODO: git_is_clean_working_tree() should provide an alternative - # exit code for "unmerged changes in working tree", which we should - # actually be testing for here - if git_is_clean_working_tree; then - FINISH_BASE=$(cat "$DOT_GIT_DIR/.gitflow/MERGE_BASE") - - # Since the working tree is now clean, either the user did a - # succesfull merge manually, or the merge was cancelled. - # We detect this using git_is_branch_merged_into() - if git_is_branch_merged_into "$BRANCH" "$FINISH_BASE"; then - rm -f "$DOT_GIT_DIR/.gitflow/MERGE_BASE" - helper_finish_cleanup - exit 0 - else - # If the user cancelled the merge and decided to wait until later, - # that's fine. But we have to acknowledge this by removing the - # MERGE_BASE file and continuing normal execution of the finish - rm -f "$DOT_GIT_DIR/.gitflow/MERGE_BASE" - fi - else - echo - echo "Merge conflicts not resolved yet, use:" - echo " git mergetool" - echo " git commit" - echo - echo "You can then complete the finish by running it again:" - echo " git flow task finish $NAME" - echo - exit 1 - fi - fi - - # sanity checks - require_clean_working_tree - - # update local repo with remote changes first, if asked - if has "$ORIGIN/$BRANCH" $(git_remote_branches); then - if flag fetch; then - git_do fetch -q "$ORIGIN" "$BRANCH" - git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH" - fi - fi - - if has "$ORIGIN/$BRANCH" $(git_remote_branches); then - require_branches_equal "$BRANCH" "$ORIGIN/$BRANCH" - fi - if has "$ORIGIN/$DEVELOP_BRANCH" $(git_remote_branches); then - require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH" - fi - - # if the user wants to rebase, do that first - if flag rebase; then - if ! git flow task rebase "$NAME" "$DEVELOP_BRANCH"; then - warn "Finish was aborted due to conflicts during rebase." - warn "Please finish the rebase manually now." - warn "When finished, re-run:" - warn " git flow task finish '$NAME' '$DEVELOP_BRANCH'" - exit 1 - fi - fi - - # merge into BASE - git_do checkout "$DEVELOP_BRANCH" - if [ "$(git rev-list -n2 "$DEVELOP_BRANCH..$BRANCH" | wc -l)" -eq 1 ]; then - git_do merge --ff "$BRANCH" - else - if noflag squash; then - git_do merge --no-ff "$BRANCH" - else - git_do merge --squash "$BRANCH" - git_do commit - git_do merge "$BRANCH" - fi - fi - - if [ $? -ne 0 ]; then - # oops.. we have a merge conflict! - # write the given $DEVELOP_BRANCH to a temporary file (we need it later) - mkdir -p "$DOT_GIT_DIR/.gitflow" - echo "$DEVELOP_BRANCH" > "$DOT_GIT_DIR/.gitflow/MERGE_BASE" - echo - echo "There were merge conflicts. To resolve the merge conflict manually, use:" - echo " git mergetool" - echo " git commit" - echo - echo "You can then complete the finish by running it again:" - echo " git flow task finish $NAME" - echo - exit 1 - fi - - # when no merge conflict is detected, just clean up the Task branch - helper_finish_cleanup -} - -helper_finish_cleanup() { - # sanity checks - require_branch "$BRANCH" - require_clean_working_tree - - # delete branch - if flag fetch; then - git_do push "$ORIGIN" ":refs/heads/$BRANCH" - fi - - - if noflag keep; then - if flag force_delete; then - git_do branch -D "$BRANCH" - else - git_do branch -d "$BRANCH" - fi - fi - - echo - echo "Summary of actions:" - echo "- The Task branch '$BRANCH' was merged into '$DEVELOP_BRANCH'" - #echo "- Merge conflicts were resolved" # TODO: Add this line when it's supported - if flag keep; then - echo "- Task branch '$BRANCH' is still available" - else - echo "- Task branch '$BRANCH' has been removed" - fi - echo "- You are now on branch '$DEVELOP_BRANCH'" - echo -} - -cmd_publish() { - parse_args "$@" - expand_nameprefix_arg - - # sanity checks - require_clean_working_tree - require_branch "$BRANCH" - git_do fetch -q "$ORIGIN" - require_branch_absent "$ORIGIN/$BRANCH" - - # create remote branch - git_do push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH" - git_do fetch -q "$ORIGIN" - - # configure remote tracking - git_do config "branch.$BRANCH.remote" "$ORIGIN" - git_do config "branch.$BRANCH.merge" "refs/heads/$BRANCH" - git_do 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 "$@" - require_name_arg - - # sanity checks - require_clean_working_tree - require_branch_absent "$BRANCH" - git_do fetch -q "$ORIGIN" - require_branch "$ORIGIN/$BRANCH" - - # create tracking branch - git_do 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 -} - -cmd_diff() { - parse_args "$@" - - if [ "$NAME" != "" ]; then - expand_nameprefix_arg - BASE=$(git merge-base "$DEVELOP_BRANCH" "$BRANCH") - git diff "$BASE..$BRANCH" - else - if ! git_current_branch | grep -q "^$PREFIX"; then - die "Not on a Task branch. Name one explicitly." - fi - - BASE=$(git merge-base "$DEVELOP_BRANCH" HEAD) - git diff "$BASE" - fi -} - -cmd_checkout() { - parse_args "$@" - - if [ "$NAME" != "" ]; then - expand_nameprefix_arg - git_do checkout "$BRANCH" - else - die "Name a Task branch explicitly." - fi -} - -cmd_co() { - # Alias for checkout - cmd_checkout "$@" -} - -cmd_rebase() { - DEFINE_boolean interactive false 'do an interactive rebase' i - parse_args "$@" - expand_nameprefix_arg_or_current - warn "Will try to rebase '$NAME'..." - require_clean_working_tree - require_branch "$BRANCH" - - git_do checkout -q "$BRANCH" - local OPTS= - if flag interactive; then - OPTS="$OPTS -i" - fi - git_do rebase $OPTS "$DEVELOP_BRANCH" -} - -avoid_accidental_cross_branch_action() { - local current_branch=$(git_current_branch) - if [ "$BRANCH" != "$current_branch" ]; then - warn "Trying to pull from '$BRANCH' while currently on branch '$current_branch'." - warn "To avoid unintended merges, git-flow aborted." - return 1 - fi - return 0 -} - -cmd_pull() { - #DEFINE_string prefix false 'alternative remote Task branch name prefix' p - DEFINE_boolean rebase false "pull with rebase" r - parse_remote_name "$@" - - if [ -z "$REMOTE" ]; then - die "Name a remote explicitly." - fi - name_or_current - - # To avoid accidentally merging different Task branches into each other, - # die if the current Task branch differs from the requested $NAME - # argument. - local current_branch=$(git_current_branch) - if startswith "$current_branch" "$PREFIX"; then - # we are on a local Task branch already, so $BRANCH must be equal to - # the current branch - avoid_accidental_cross_branch_action || die - fi - - require_clean_working_tree - - if git_branch_exists "$BRANCH"; then - # Again, avoid accidental merges - avoid_accidental_cross_branch_action || die - - # we already have a local branch called like this, so simply pull the - # remote changes in - if flag rebase; then - if ! git_do pull --rebase -q "$REMOTE" "$BRANCH"; then - warn "Pull was aborted. There might be conflicts during rebase or '$REMOTE' might be inaccessible." - exit 1 - fi - else - git_do pull -q "$REMOTE" "$BRANCH" || die "Failed to pull from remote '$REMOTE'." - fi - - echo "Pulled $REMOTE's changes into $BRANCH." - else - # setup the local branch clone for the first time - git_do fetch -q "$REMOTE" "$BRANCH" || die "Fetch failed." # stores in FETCH_HEAD - git_do branch --no-track "$BRANCH" FETCH_HEAD || die "Branch failed." - git_do checkout -q "$BRANCH" || die "Checking out new local branch failed." - echo "Created local branch $BRANCH based on $REMOTE's $BRANCH." - fi -} diff --git a/git-flow-updater.sh b/git-flow-updater.sh deleted file mode 100755 index b8a33f3..0000000 --- a/git-flow-updater.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# Pull-Request git-flow for Tower updater - -killall Tower - -# Change App back to user -REALUSER=$(whoami) -sudo chown -R $REALUSER:staff /Applications/Tower.app -sudo chown -R $REALUSER:staff /Applications/Tower.app/Contents/Resources - -# Update git -ls /Applications/Tower.app/Contents/Resources/git-flow/.git; -if [[ $? -ne 0 ]]; then - rm -R /Applications/Tower.app/Contents/Resources/git-flow/ - git clone https://github.com/brandon-reeves/tower-git-flow-github-pull-requests.git /Applications/Tower.app/Contents/Resources/git-flow/ -else - cd /Applications/Tower.app/Contents/Resources/git-flow; - git stash save; - git pull origin master; - git checkout master; -fi -# if [[ $? -eq 0 ]]; then -# ls .git; -# if [[ $? -ne 0 ]]; then -# git init; -# git remote add origin https://github.com/brandon-reeves/tower-git-flow-github-pull-requests.git; -# fi -# git fetch origin; -# git stash save; -# git checkout -b master --track origin/master; -# git reset origin/master; -# fi diff --git a/git-flow-version b/git-flow-version deleted file mode 100644 index 8c31499..0000000 --- a/git-flow-version +++ /dev/null @@ -1,52 +0,0 @@ -# -# git-flow -- A collection of Git extensions to provide high-level -# repository operations for Vincent Driessen's branching model. -# -# Original blog post presenting this model is found at: -# http://nvie.com/git-model -# -# Feel free to contribute to this project at: -# http://github.com/nvie/gitflow -# -# Copyright 2010 Vincent Driessen. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY VINCENT DRIESSEN ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -# EVENT SHALL VINCENT DRIESSEN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -# The views and conclusions contained in the software and documentation are -# those of the authors and should not be interpreted as representing official -# policies, either expressed or implied, of Vincent Driessen. -# - -GITFLOW_VERSION=0.4.2-pre - -usage() { - echo "usage: git flow version" -} - -cmd_default() { - echo "$GITFLOW_VERSION" -} - -cmd_help() { - usage - exit 0 -}