Skip to content

Commit

Permalink
Merge branch 'feature/fix-gitflow-function-prefixes' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
nvie committed Feb 22, 2010
2 parents 677334c + 6ee6223 commit f10a48b
Show file tree
Hide file tree
Showing 6 changed files with 188 additions and 177 deletions.
58 changes: 29 additions & 29 deletions git-flow-feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# Copyright (c) 2010 by Benedikt Böhm
#

gitflow_require_git_repo
gitflow_require_initialized
require_git_repo
require_gitflow_initialized
gitflow_load_settings
PREFIX=$(git config --get gitflow.prefix.feature)

Expand All @@ -38,7 +38,7 @@ cmd_list() {
local feature_branches
local current_branch
local short_names
feature_branches=$(echo "$(gitflow_local_branches)" | grep "^$PREFIX")
feature_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX")
if [ -z "$feature_branches" ]; then
warn "No feature branches exist."
exit 0
Expand Down Expand Up @@ -102,7 +102,7 @@ expand_nameprefix_arg() {

local expanded_name
local exitcode
expanded_name=$(resolve_nameprefix "$NAME" "$PREFIX")
expanded_name=$(gitflow_resolve_nameprefix "$NAME" "$PREFIX")
exitcode=$?
case $exitcode in
0) NAME=$expanded_name
Expand All @@ -115,9 +115,9 @@ expand_nameprefix_arg() {
expand_nameprefix_arg_or_current() {
if [ "$NAME" != "" ]; then
expand_nameprefix_arg
gitflow_require_branch "$PREFIX$NAME"
require_branch "$PREFIX$NAME"
else
local current_branch=$(gitflow_current_branch)
local current_branch=$(git_current_branch)
if startswith "$current_branch" "$PREFIX"; then
BRANCH=$current_branch
NAME=${BRANCH#$PREFIX}
Expand Down Expand Up @@ -149,16 +149,16 @@ cmd_start() {

# sanity checks
if noflag force; then
gitflow_require_clean_working_tree
require_clean_working_tree
fi
gitflow_require_branch_absent "$BRANCH"
require_branch_absent "$BRANCH"

# update the local repo with remote changes, if asked
if flag fetch; then
git fetch -q "$ORIGIN" "$DEVELOP_BRANCH"
fi

gitflow_require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"

# create branch
if ! git checkout -b "$BRANCH" "$BASE"; then
Expand All @@ -184,7 +184,7 @@ cmd_finish() {
expand_nameprefix_arg

# sanity checks
gitflow_require_branch "$BRANCH"
require_branch "$BRANCH"

# detect if we're restoring from a merge conflict
if [ -f "$DOT_GIT_DIR/.gitflow/MERGE_BASE" ]; then
Expand All @@ -194,16 +194,16 @@ cmd_finish() {
# (although he/she should).
#

# TODO: gitflow_test_clean_working_tree() should provide an alternative
# 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 gitflow_test_clean_working_tree; then
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 gitflow_is_branch_merged_into()
if gitflow_is_branch_merged_into "$BRANCH" "$FINISH_BASE"; then
# 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
Expand All @@ -227,17 +227,17 @@ cmd_finish() {
fi

# sanity checks
gitflow_require_clean_working_tree
require_clean_working_tree

# update local repo with remote changes first, if asked
if flag fetch; then
git fetch -q "$ORIGIN" "$BRANCH"
fi

if has "$ORIGIN/$BRANCH" "$(gitflow_remote_branches)"; then
gitflow_require_branches_equal "$BRANCH" "$ORIGIN/$BRANCH"
if has "$ORIGIN/$BRANCH" "$(git_remote_branches)"; then
require_branches_equal "$BRANCH" "$ORIGIN/$BRANCH"
fi
gitflow_require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"

# if the user wants to rebase, do that first
if flag rebase; then
Expand Down Expand Up @@ -280,8 +280,8 @@ cmd_finish() {

helper_finish_cleanup() {
# sanity checks
gitflow_require_branch "$BRANCH"
gitflow_require_clean_working_tree
require_branch "$BRANCH"
require_clean_working_tree

# delete branch
if flag fetch; then
Expand All @@ -303,10 +303,10 @@ cmd_publish() {
expand_nameprefix_arg

# sanity checks
gitflow_require_clean_working_tree
gitflow_require_branch "$BRANCH"
require_clean_working_tree
require_branch "$BRANCH"
git fetch -q "$ORIGIN"
gitflow_require_branch_absent "$ORIGIN/$BRANCH"
require_branch_absent "$ORIGIN/$BRANCH"

# create remote branch
git push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH"
Expand All @@ -330,10 +330,10 @@ cmd_track() {
require_name_arg

# sanity checks
gitflow_require_clean_working_tree
gitflow_require_branch_absent "$BRANCH"
require_clean_working_tree
require_branch_absent "$BRANCH"
git fetch -q "$ORIGIN"
gitflow_require_branch "$ORIGIN/$BRANCH"
require_branch "$ORIGIN/$BRANCH"

# create tracking branch
git checkout -b "$BRANCH" "$ORIGIN/$BRANCH"
Expand All @@ -353,7 +353,7 @@ cmd_diff() {
BASE=$(git merge-base "$DEVELOP_BRANCH" "$BRANCH")
git diff "$BASE..$BRANCH"
else
if ! gitflow_current_branch | grep -q "^$PREFIX"; then
if ! git_current_branch | grep -q "^$PREFIX"; then
die "Not on a feature branch. Name one explicitly."
fi

Expand All @@ -367,8 +367,8 @@ cmd_rebase() {
parse_args "$@"
expand_nameprefix_arg_or_current
warn "Will try to rebase '$NAME'..."
gitflow_require_clean_working_tree
gitflow_require_branch "$BRANCH"
require_clean_working_tree
require_branch "$BRANCH"

git checkout -q "$BRANCH"
local OPTS=
Expand Down
30 changes: 15 additions & 15 deletions git-flow-hotfix
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# Copyright (c) 2010 by Benedikt Böhm
#

gitflow_require_git_repo
gitflow_require_initialized
require_git_repo
require_gitflow_initialized
gitflow_load_settings
VERSION_PREFIX=$(git config --get gitflow.prefix.versiontag)
PREFIX=$(git config --get gitflow.prefix.hotfix)
Expand All @@ -35,7 +35,7 @@ cmd_list() {
local hotfix_branches
local current_branch
local short_names
hotfix_branches=$(echo "$(gitflow_local_branches)" | grep "^$PREFIX")
hotfix_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX")
if [ -z "$hotfix_branches" ]; then
warn "No hotfix branches exist."
exit 0
Expand Down Expand Up @@ -116,7 +116,7 @@ require_base_is_on_master() {
}

require_no_existing_hotfix_branches() {
local hotfix_branches=$(echo "$(gitflow_local_branches)" | grep "^$PREFIX")
local hotfix_branches=$(echo "$(git_local_branches)" | grep "^$PREFIX")
local first_branch=$(echo ${hotfix_branches} | head -n1)
first_branch=${first_branch#$PREFIX}
[ -z "$hotfix_branches" ] || \
Expand All @@ -132,13 +132,13 @@ cmd_start() {
require_no_existing_hotfix_branches

# sanity checks
gitflow_require_clean_working_tree
gitflow_require_branch_absent "$BRANCH"
gitflow_require_tag_absent "$VERSION_PREFIX$VERSION"
require_clean_working_tree
require_branch_absent "$BRANCH"
require_tag_absent "$VERSION_PREFIX$VERSION"
if flag fetch; then
git fetch -q "$ORIGIN" "$MASTER_BRANCH"
fi
gitflow_require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH"
require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH"

# create branch
git checkout -b "$BRANCH" "$BASE"
Expand Down Expand Up @@ -172,21 +172,21 @@ cmd_finish() {
fi

# sanity checks
gitflow_require_branch "$BRANCH"
gitflow_require_clean_working_tree
require_branch "$BRANCH"
require_clean_working_tree
if flag fetch; then
git fetch -q "$ORIGIN" "$MASTER_BRANCH" || \
die "Could not fetch $MASTER_BRANCH from $ORIGIN."
git fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \
die "Could not fetch $DEVELOP_BRANCH from $ORIGIN."
fi
gitflow_require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH"
gitflow_require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH"
require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"

# 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 ! gitflow_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then
if ! git_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then
git checkout "$MASTER_BRANCH" || \
die "Could not check out $MASTER_BRANCH."
git merge --no-ff "$BRANCH" || \
Expand All @@ -198,7 +198,7 @@ cmd_finish() {
# 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 ! gitflow_tag_exists "$tagname"; then
if ! git_tag_exists "$tagname"; then
local opts="-a"
flag sign && opts="$opts -s"
[ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'"
Expand All @@ -210,7 +210,7 @@ cmd_finish() {
# 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 ! gitflow_is_branch_merged_into "$BRANCH" "$DEVELOP_BRANCH"; then
if ! git_is_branch_merged_into "$BRANCH" "$DEVELOP_BRANCH"; then
git checkout "$DEVELOP_BRANCH" || \
die "Could not check out $DEVELOP_BRANCH."

Expand Down
20 changes: 10 additions & 10 deletions git-flow-init
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ cmd_default() {
git init
else
# assure that we are not working in a repo with local changes
git_repo_is_headless || gitflow_require_clean_working_tree
git_repo_is_headless || require_clean_working_tree
fi

# running git flow init on an already initialized repo is fine
Expand All @@ -57,20 +57,20 @@ cmd_default() {
# rather allow to use existing branches for git-flow.
local default_suggestion
local should_check_existence
branch_count=$(gitflow_local_branches | wc -l)
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=master
else
echo
echo "Which branch should be used for bringing forth production releases?"
gitflow_local_branches | sed 's/^.*$/ - &/g'
git_local_branches | sed 's/^.*$/ - &/g'

should_check_existence=YES
default_suggestion=
for guess in 'production' 'main' 'master'; do
if gitflow_local_branch_exists "$guess"; then
if git_local_branch_exists "$guess"; then
default_suggestion="$guess"
break
fi
Expand All @@ -83,7 +83,7 @@ cmd_default() {

# check existence in case of an already existing repo
if [ "$should_check_existence" = "YES" ]; then
gitflow_local_branch_exists "$master_branch" || \
git_local_branch_exists "$master_branch" || \
die "Local branch '$master_branch' does not exist."
fi

Expand All @@ -100,19 +100,19 @@ cmd_default() {
# considered (fresh repo or repo that contains branches)
local default_suggestion
local should_check_existence
branch_count=$(gitflow_local_branches | grep -v "^${master_branch}\$" | wc -l)
branch_count=$(git_local_branches | grep -v "^${master_branch}\$" | wc -l)
if [ "$branch_count" -eq 0 ]; then
should_check_existence=NO
default_suggestion=develop
else
echo
echo "Which branch should be used for integration of the \"next release\"?"
gitflow_local_branches | grep -v "^${master_branch}\$" | sed 's/^.*$/ - &/g'
git_local_branches | grep -v "^${master_branch}\$" | sed 's/^.*$/ - &/g'

should_check_existence=YES
default_suggestion=
for guess in 'develop' 'int' 'integration' 'master'; do
if gitflow_local_branch_exists "$guess"; then
if git_local_branch_exists "$guess"; then
default_suggestion="$guess"
break
fi
Expand All @@ -129,7 +129,7 @@ cmd_default() {

# check existence in case of an already existing repo
if [ "$should_check_existence" = "YES" ]; then
gitflow_local_branch_exists "$develop_branch" || \
git_local_branch_exists "$develop_branch" || \
die "Local branch '$develop_branch' does not exist."
fi

Expand Down Expand Up @@ -160,7 +160,7 @@ cmd_default() {
# 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 ! gitflow_local_branch_exists "$develop_branch"; then
if ! git_local_branch_exists "$develop_branch"; then
git branch "$develop_branch" "$master_branch"
created_gitflow_branch=1
fi
Expand Down
Loading

0 comments on commit f10a48b

Please sign in to comment.