Skip to content

Commit

Permalink
Feature to story, patch, task
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon-reeves committed Oct 9, 2015
1 parent 8e44315 commit fbcf9d2
Show file tree
Hide file tree
Showing 7 changed files with 1,747 additions and 123 deletions.
16 changes: 8 additions & 8 deletions git-flow-agile
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ esac
# Extra environment settings
if [ -f ~/.gitflow_export ]; then
if grep -E 'GITFLOW_FLAG_(SHOWCOMMANDS|INIT|FEATURE|HOTFIX|RELEASE|SUPPORT)' ~/.gitflow_export > /dev/null; then
echo "Using environment variables for \"showcommands\", \"init\", \"feature\", \"hotfix\", \"release\" and \"support\" in ~/.gitflow_export has deprecated, use git config instead."
echo "Using environment variables for \"showcommands\", \"init\", \"story\", \"task\", \"feature\", \"patch\", \"release\" and \"support\" in ~/.gitflow_export has deprecated, use git config instead."
echo ""
exit 1;
else
Expand Down Expand Up @@ -137,10 +137,10 @@ main() {
_prefix=$(git config --get gitflow.prefix.feature)
_short_branch_name=$(echo ${_current_branch#*${_prefix}})
else
if startswith "${_current_branch}" $(git config --get gitflow.prefix.hotfix); then
if startswith "${_current_branch}" $(git config --get gitflow.prefix.patch); then
SUBACTION="${SUBCOMMAND}"
SUBCOMMAND="hotfix"
_prefix=$(git config --get gitflow.prefix.hotfix)
SUBCOMMAND="patch"
_prefix=$(git config --get gitflow.prefix.patch)
_short_branch_name=$(echo ${_current_branch#*${_prefix}})
else
if startswith "${_current_branch}" $(git config --get gitflow.prefix.release); then
Expand All @@ -154,14 +154,14 @@ main() {
fi
fi

if [ ! -e "$GITFLOW_DIR/git-flow-tower-$SUBCOMMAND" ]; then
if [ ! -e "$GITFLOW_DIR/git-flow-agile-$SUBCOMMAND" ]; then
usage
exit 1
fi

# Run command
. "$GITFLOW_DIR/git-flow-tower-$SUBCOMMAND"
FLAGS_PARENT="git flow-tower $SUBCOMMAND"
. "$GITFLOW_DIR/git-flow-agile-$SUBCOMMAND"
FLAGS_PARENT="git flow-agile $SUBCOMMAND"

if [ -z "${SUBACTION}" ]; then
# If the first argument is a flag, it starts with '-', we interpret this
Expand Down Expand Up @@ -196,7 +196,7 @@ main() {
initialize
fi
if [ $SUBACTION != 'default' ]; then
FLAGS_PARENT="git flow-tower $SUBCOMMAND $SUBACTION"
FLAGS_PARENT="git flow-agile $SUBCOMMAND $SUBACTION"
fi

cmd_$SUBACTION "$@" "${_short_branch_name}"
Expand Down
29 changes: 22 additions & 7 deletions git-flow-agile-config
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,22 @@ file= Use given config file
output=$(git config $gitflow_config_option --get gitflow.branch.develop)
echo "Branch name for \"next release\" development: $output "


output=$(git config $gitflow_config_option --get gitflow.prefix.story)
echo "Story branch prefix: $output "

output=$(git config $gitflow_config_option --get gitflow.prefix.task)
echo "Task branch prefix: $output "

output=$(git config $gitflow_config_option --get gitflow.prefix.patch)
echo "Patch branch prefix: $output "

output=$(git config $gitflow_config_option --get gitflow.prefix.feature)
echo "Feature branch prefix: $output "

output=$(git config $gitflow_config_option --get gitflow.prefix.release)
echo "Release branch prefix: $output "

output=$(git config $gitflow_config_option --get gitflow.prefix.hotfix)
echo "Hotfix branch prefix: $output "

output=$(git config $gitflow_config_option --get gitflow.prefix.support)
echo "Support branch prefix: $output "

Expand Down Expand Up @@ -163,14 +170,22 @@ file= Use given config file
cfg_option="gitflow.branch.develop"
txt="Branch name for \"next release\" development"
;;
story)
cfg_option="gitflow.prefix.story"
txt="Story branch prefix"
;;
task)
cfg_option="gitflow.prefix.task"
txt="Task branch prefix"
;;
patch)
cfg_option="gitflow.prefix.patch"
txt="Patch branch prefix"
;;
feature)
cfg_option="gitflow.prefix.feature"
txt="Feature branch prefix"
;;
hotfix)
cfg_option="gitflow.prefix.hotfix"
txt="Hotfix branch prefix"
;;
release)
cfg_option="gitflow.prefix.release"
txt="Release branch prefix"
Expand Down
221 changes: 113 additions & 108 deletions git-flow-agile-feature
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ git flow feature finish
git flow feature publish
git flow feature track
git flow feature diff
git flow feature rebase
git flow feature checkout
git flow feature pull
git flow feature delete
Expand Down Expand Up @@ -335,6 +334,8 @@ no-ff! Never fast-forward during the merge
# merged into the local branch
if git_remote_branch_exists "$ORIGIN/$BRANCH"; then
git_fetch_branch "$ORIGIN" "$BRANCH"
else
cmd_publish "$NAME"
fi

# Update local branches with remote branches
Expand Down Expand Up @@ -373,21 +374,21 @@ no-ff! Never fast-forward during the merge
# Merge into BASE
git_do checkout "$BASE_BRANCH" || die "Could not check out branch '$BASE_BRANCH'."

if noflag squash; then
if flag no_ff; then
git_do merge --no-ff "$BRANCH"
else
if [ "$(git rev-list -n2 "$BASE_BRANCH..$BRANCH" | wc -l)" -eq 1 ]; then
git_do merge --ff "$BRANCH"
else
git_do merge --no-ff "$BRANCH"
fi
fi
else
git_do merge --squash "$BRANCH"
flag squash_info && gitflow_create_squash_message "Merged feature branch '$BRANCH'" "$BASE_BRANCH" "$BRANCH" > "$DOT_GIT_DIR/SQUASH_MSG"
git_do commit
fi
# if noflag squash; then
# if flag no_ff; then
# git_do merge --no-ff "$BRANCH"
# else
# if [ "$(git rev-list -n2 "$BASE_BRANCH..$BRANCH" | wc -l)" -eq 1 ]; then
# git_do merge --ff "$BRANCH"
# else
# git_do merge --no-ff "$BRANCH"
# fi
# fi
# else
# git_do merge --squash "$BRANCH"
# flag squash_info && gitflow_create_squash_message "Merged feature branch '$BRANCH'" "$BASE_BRANCH" "$BRANCH" > "$DOT_GIT_DIR/SQUASH_MSG"
# git_do commit
# fi

if [ $? -ne 0 ]; then
# Oops.. we have a merge conflict!
Expand All @@ -408,8 +409,12 @@ no-ff! Never fast-forward during the merge

run_post_hook "$NAME" "$ORIGIN" "$BRANCH"

PUSH_URL=$(git remote show origin | grep Push | grep -oh "github.com[\/:].*" | sed "s/github\.com\:/github.com\//g" | sed "s/\.git//g");
COMPARE_URL="https://$PUSH_URL/compare/$BASE_BRANCH...$BRANCH?expand=1";
open $COMPARE_URL;

# When no merge conflict is detected, just clean up the feature branch
gitflow_config_remove_base_branch "$BRANCH"
# gitflow_config_remove_base_branch "$BRANCH"
helper_finish_cleanup
}

Expand All @@ -420,61 +425,61 @@ helper_finish_cleanup() {
require_branch "$BRANCH"
require_clean_working_tree

remotebranchdeleted=$FLAGS_FALSE
localbranchdeleted=$FLAGS_FALSE

if noflag keep; then

# Always delete remote first
if noflag keepremote;then
if git_remote_branch_exists "$ORIGIN/$BRANCH"; then
git_remote_branch_delete "$BRANCH" && remotebranchdeleted=$FLAGS_TRUE
fi
fi

# Delete local after remote to avoid warnings
if noflag keeplocal; then
if [ "$BRANCH" = "$(git_current_branch)" ]; then
git_do checkout "$BASE_BRANCH" || die "Could not check out branch '$BASE_BRANCH'."
fi
if flag force_delete; then
git_do branch -D "$BRANCH" && localbranchdeleted=$FLAGS_TRUE
else
if noflag squash; then
git_do branch -d "$BRANCH" && localbranchdeleted=$FLAGS_TRUE
else
git_do branch -D "$BRANCH" && localbranchdeleted=$FLAGS_TRUE
fi
fi
fi

# no more branches: we can safely remove config section
if ! git_remote_branch_exists "$ORIGIN/$BRANCH" -a ! git_local_branch_exists "$BRANCH"; then
gitflow_config_remove_base_section "$BRANCH"
fi
fi
# remotebranchdeleted=$FLAGS_FALSE
# localbranchdeleted=$FLAGS_FALSE

# if noflag keep; then

# # Always delete remote first
# if noflag keepremote;then
# if git_remote_branch_exists "$ORIGIN/$BRANCH"; then
# git_remote_branch_delete "$BRANCH" && remotebranchdeleted=$FLAGS_TRUE
# fi
# fi

# # Delete local after remote to avoid warnings
# if noflag keeplocal; then
# if [ "$BRANCH" = "$(git_current_branch)" ]; then
# git_do checkout "$BASE_BRANCH" || die "Could not check out branch '$BASE_BRANCH'."
# fi
# if flag force_delete; then
# git_do branch -D "$BRANCH" && localbranchdeleted=$FLAGS_TRUE
# else
# if noflag squash; then
# git_do branch -d "$BRANCH" && localbranchdeleted=$FLAGS_TRUE
# else
# git_do branch -D "$BRANCH" && localbranchdeleted=$FLAGS_TRUE
# fi
# fi
# fi

# # no more branches: we can safely remove config section
# if ! git_remote_branch_exists "$ORIGIN/$BRANCH" -a ! git_local_branch_exists "$BRANCH"; then
# gitflow_config_remove_base_section "$BRANCH"
# fi
# fi

echo
echo "Summary of actions:"
echo "- The feature branch '$BRANCH' was merged into '$BASE_BRANCH'"
echo "- The feature branch '$BRANCH' was pull requested into '$BASE_BRANCH'"
#echo "- Merge conflicts were resolved" # TODO: Add this line when it's supported
if noflag keep; then
if [ $localbranchdeleted -eq $FLAGS_TRUE ]; then
keepmsg="has been locally deleted"
else
keepmsg="is still locally available"
fi
if [ $remotebranchdeleted -eq $FLAGS_TRUE ]; then
keepmsg=$keepmsg"; it has been remotely deleted from '$ORIGIN'"
elif git_remote_branch_exists "$ORIGIN/$BRANCH"; then
keepmsg=$keepmsg"; it is still remotely available on '$ORIGIN'"
fi
else
# if noflag keep; then
# if [ $localbranchdeleted -eq $FLAGS_TRUE ]; then
# keepmsg="has been locally deleted"
# else
# keepmsg="is still locally available"
# fi
# if [ $remotebranchdeleted -eq $FLAGS_TRUE ]; then
# keepmsg=$keepmsg"; it has been remotely deleted from '$ORIGIN'"
# elif git_remote_branch_exists "$ORIGIN/$BRANCH"; then
# keepmsg=$keepmsg"; it is still remotely available on '$ORIGIN'"
# fi
# else
keepmsg="is still locally available"
if git_remote_branch_exists "$ORIGIN/$BRANCH"; then
keepmsg=$keepmsg"; it is still remotely available on '$ORIGIN'"
fi
fi
# fi
echo "- Feature branch '$BRANCH' "$keepmsg
echo "- You are now on branch '$(git_current_branch)'"
echo
Expand Down Expand Up @@ -610,50 +615,50 @@ cmd_co() {
cmd_checkout "$@"
}

cmd_rebase() {
OPTIONS_SPEC="\
git flow feature rebase [-h] [-i] [-p] [<name|nameprefix>]

Rebase <name> on <base_branch>
--
h,help! Show this help
showcommands! Show git commands while executing them
i,[no]interactive Do an interactive rebase
p,[no]preserve-merges Preserve merges
"
local opts

# Define flags
DEFINE_boolean 'interactive' false 'do an interactive rebase' i
DEFINE_boolean 'preserve-merges' false 'try to recreate merges' p

# Override defaults with values from config
gitflow_override_flag_boolean "feature.rebase.interactive" "interactive"
gitflow_override_flag_boolean "feature.rebase.preserve-merges" "preserve_merges"

# Parse arguments
parse_args "$@"

gitflow_expand_nameprefix_arg_or_current 'feature'

BASE_BRANCH=$(gitflow_config_get_base_branch $BRANCH)
BASE_BRANCH=${BASE_BRANCH:-$DEVELOP_BRANCH}

warn "Will try to rebase '$NAME' which is based on '$BASE_BRANCH'..."
require_clean_working_tree
require_branch "$BRANCH"

git_local_branch_exists "$BASE_BRANCH" || die "The base '$BASE_BRANCH' doesn't exists locally or is not a branch. Can't finish the feature branch '$BRANCH'."

git_do checkout -q "$BRANCH" || die "Could not check out branch '$BRANCH'."
if flag interactive; then
opts="$opts -i"
fi
if flag preserve_merges; then
opts="$opts -p"
fi
git_do rebase $opts "$BASE_BRANCH"
}
# cmd_rebase() {
# OPTIONS_SPEC="\
# git flow feature rebase [-h] [-i] [-p] [<name|nameprefix>]

# Rebase <name> on <base_branch>
# --
# h,help! Show this help
# showcommands! Show git commands while executing them
# i,[no]interactive Do an interactive rebase
# p,[no]preserve-merges Preserve merges
# "
# local opts

# # Define flags
# DEFINE_boolean 'interactive' false 'do an interactive rebase' i
# DEFINE_boolean 'preserve-merges' false 'try to recreate merges' p

# # Override defaults with values from config
# gitflow_override_flag_boolean "feature.rebase.interactive" "interactive"
# gitflow_override_flag_boolean "feature.rebase.preserve-merges" "preserve_merges"

# # Parse arguments
# parse_args "$@"

# gitflow_expand_nameprefix_arg_or_current 'feature'

# BASE_BRANCH=$(gitflow_config_get_base_branch $BRANCH)
# BASE_BRANCH=${BASE_BRANCH:-$DEVELOP_BRANCH}

# warn "Will try to rebase '$NAME' which is based on '$BASE_BRANCH'..."
# require_clean_working_tree
# require_branch "$BRANCH"

# git_local_branch_exists "$BASE_BRANCH" || die "The base '$BASE_BRANCH' doesn't exists locally or is not a branch. Can't finish the feature branch '$BRANCH'."

# git_do checkout -q "$BRANCH" || die "Could not check out branch '$BRANCH'."
# if flag interactive; then
# opts="$opts -i"
# fi
# if flag preserve_merges; then
# opts="$opts -p"
# fi
# git_do rebase $opts "$BASE_BRANCH"
# }

avoid_accidental_cross_branch_action() {
local current_branch
Expand Down
File renamed without changes.
Loading

0 comments on commit fbcf9d2

Please sign in to comment.