Commit 15aab264 authored by Jerome Baum's avatar Jerome Baum

Use git_do where appropriate

parent 5bca8d93
...@@ -204,7 +204,7 @@ cmd_start() { ...@@ -204,7 +204,7 @@ cmd_start() {
# update the local repo with remote changes, if asked # update the local repo with remote changes, if asked
if flag fetch; then if flag fetch; then
git fetch -q "$ORIGIN" "$DEVELOP_BRANCH" git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH"
fi fi
# if the origin branch counterpart exists, assert that the local branch # if the origin branch counterpart exists, assert that the local branch
...@@ -214,7 +214,7 @@ cmd_start() { ...@@ -214,7 +214,7 @@ cmd_start() {
fi fi
# create branch # create branch
if ! git checkout -b "$BRANCH" "$BASE"; then if ! git_do checkout -b "$BRANCH" "$BASE"; then
die "Could not create feature branch '$BRANCH'" die "Could not create feature branch '$BRANCH'"
fi fi
...@@ -287,8 +287,8 @@ cmd_finish() { ...@@ -287,8 +287,8 @@ cmd_finish() {
# update local repo with remote changes first, if asked # update local repo with remote changes first, if asked
if has "$ORIGIN/$BRANCH" $(git_remote_branches); then if has "$ORIGIN/$BRANCH" $(git_remote_branches); then
if flag fetch; then if flag fetch; then
git fetch -q "$ORIGIN" "$BRANCH" git_do fetch -q "$ORIGIN" "$BRANCH"
git fetch -q "$ORIGIN" "$DEVELOP_BRANCH" git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH"
fi fi
fi fi
...@@ -311,16 +311,16 @@ cmd_finish() { ...@@ -311,16 +311,16 @@ cmd_finish() {
fi fi
# merge into BASE # merge into BASE
git checkout "$DEVELOP_BRANCH" git_do checkout "$DEVELOP_BRANCH"
if [ "$(git rev-list -n2 "$DEVELOP_BRANCH..$BRANCH" | wc -l)" -eq 1 ]; then if [ "$(git rev-list -n2 "$DEVELOP_BRANCH..$BRANCH" | wc -l)" -eq 1 ]; then
git merge --ff "$BRANCH" git_do merge --ff "$BRANCH"
else else
if noflag squash; then if noflag squash; then
git merge --no-ff "$BRANCH" git_do merge --no-ff "$BRANCH"
else else
git merge --squash "$BRANCH" git_do merge --squash "$BRANCH"
git commit git_do commit
git merge "$BRANCH" git_do merge "$BRANCH"
fi fi
fi fi
...@@ -351,15 +351,15 @@ helper_finish_cleanup() { ...@@ -351,15 +351,15 @@ helper_finish_cleanup() {
# delete branch # delete branch
if flag fetch; then if flag fetch; then
git push "$ORIGIN" ":refs/heads/$BRANCH" git_do push "$ORIGIN" ":refs/heads/$BRANCH"
fi fi
if noflag keep; then if noflag keep; then
if flag force_delete; then if flag force_delete; then
git branch -D "$BRANCH" git_do branch -D "$BRANCH"
else else
git branch -d "$BRANCH" git_do branch -d "$BRANCH"
fi fi
fi fi
...@@ -383,17 +383,17 @@ cmd_publish() { ...@@ -383,17 +383,17 @@ cmd_publish() {
# sanity checks # sanity checks
require_clean_working_tree require_clean_working_tree
require_branch "$BRANCH" require_branch "$BRANCH"
git fetch -q "$ORIGIN" git_do fetch -q "$ORIGIN"
require_branch_absent "$ORIGIN/$BRANCH" require_branch_absent "$ORIGIN/$BRANCH"
# create remote branch # create remote branch
git push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH" git_do push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH"
git fetch -q "$ORIGIN" git_do fetch -q "$ORIGIN"
# configure remote tracking # configure remote tracking
git config "branch.$BRANCH.remote" "$ORIGIN" git_do config "branch.$BRANCH.remote" "$ORIGIN"
git config "branch.$BRANCH.merge" "refs/heads/$BRANCH" git_do config "branch.$BRANCH.merge" "refs/heads/$BRANCH"
git checkout "$BRANCH" git_do checkout "$BRANCH"
echo echo
echo "Summary of actions:" echo "Summary of actions:"
...@@ -410,11 +410,11 @@ cmd_track() { ...@@ -410,11 +410,11 @@ cmd_track() {
# sanity checks # sanity checks
require_clean_working_tree require_clean_working_tree
require_branch_absent "$BRANCH" require_branch_absent "$BRANCH"
git fetch -q "$ORIGIN" git_do fetch -q "$ORIGIN"
require_branch "$ORIGIN/$BRANCH" require_branch "$ORIGIN/$BRANCH"
# create tracking branch # create tracking branch
git checkout -b "$BRANCH" "$ORIGIN/$BRANCH" git_do checkout -b "$BRANCH" "$ORIGIN/$BRANCH"
echo echo
echo "Summary of actions:" echo "Summary of actions:"
...@@ -445,7 +445,7 @@ cmd_checkout() { ...@@ -445,7 +445,7 @@ cmd_checkout() {
if [ "$NAME" != "" ]; then if [ "$NAME" != "" ]; then
expand_nameprefix_arg expand_nameprefix_arg
git checkout "$BRANCH" git_do checkout "$BRANCH"
else else
die "Name a feature branch explicitly." die "Name a feature branch explicitly."
fi fi
...@@ -464,12 +464,12 @@ cmd_rebase() { ...@@ -464,12 +464,12 @@ cmd_rebase() {
require_clean_working_tree require_clean_working_tree
require_branch "$BRANCH" require_branch "$BRANCH"
git checkout -q "$BRANCH" git_do checkout -q "$BRANCH"
local OPTS= local OPTS=
if flag interactive; then if flag interactive; then
OPTS="$OPTS -i" OPTS="$OPTS -i"
fi fi
git rebase $OPTS "$DEVELOP_BRANCH" git_do rebase $OPTS "$DEVELOP_BRANCH"
} }
avoid_accidental_cross_branch_action() { avoid_accidental_cross_branch_action() {
...@@ -511,20 +511,20 @@ cmd_pull() { ...@@ -511,20 +511,20 @@ cmd_pull() {
# we already have a local branch called like this, so simply pull the # we already have a local branch called like this, so simply pull the
# remote changes in # remote changes in
if flag rebase; then if flag rebase; then
if ! git pull --rebase -q "$REMOTE" "$BRANCH"; 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." warn "Pull was aborted. There might be conflicts during rebase or '$REMOTE' might be inaccessible."
exit 1 exit 1
fi fi
else else
git pull -q "$REMOTE" "$BRANCH" || die "Failed to pull from remote '$REMOTE'." git_do pull -q "$REMOTE" "$BRANCH" || die "Failed to pull from remote '$REMOTE'."
fi fi
echo "Pulled $REMOTE's changes into $BRANCH." echo "Pulled $REMOTE's changes into $BRANCH."
else else
# setup the local branch clone for the first time # setup the local branch clone for the first time
git fetch -q "$REMOTE" "$BRANCH" || die "Fetch failed." # stores in FETCH_HEAD git_do fetch -q "$REMOTE" "$BRANCH" || die "Fetch failed." # stores in FETCH_HEAD
git branch --no-track "$BRANCH" FETCH_HEAD || die "Branch failed." git_do branch --no-track "$BRANCH" FETCH_HEAD || die "Branch failed."
git checkout -q "$BRANCH" || die "Checking out new local branch failed." git_do checkout -q "$BRANCH" || die "Checking out new local branch failed."
echo "Created local branch $BRANCH based on $REMOTE's $BRANCH." echo "Created local branch $BRANCH based on $REMOTE's $BRANCH."
fi fi
} }
...@@ -169,14 +169,14 @@ cmd_start() { ...@@ -169,14 +169,14 @@ cmd_start() {
require_branch_absent "$BRANCH" require_branch_absent "$BRANCH"
require_tag_absent "$VERSION_PREFIX$VERSION" require_tag_absent "$VERSION_PREFIX$VERSION"
if flag fetch; then if flag fetch; then
git fetch -q "$ORIGIN" "$MASTER_BRANCH" git_do fetch -q "$ORIGIN" "$MASTER_BRANCH"
fi fi
if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then
require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH" require_branches_equal "$MASTER_BRANCH" "$ORIGIN/$MASTER_BRANCH"
fi fi
# create branch # create branch
git checkout -b "$BRANCH" "$BASE" git_do checkout -b "$BRANCH" "$BASE"
echo echo
echo "Summary of actions:" echo "Summary of actions:"
...@@ -199,17 +199,17 @@ cmd_publish() { ...@@ -199,17 +199,17 @@ cmd_publish() {
# sanity checks # sanity checks
require_clean_working_tree require_clean_working_tree
require_branch "$BRANCH" require_branch "$BRANCH"
git fetch -q "$ORIGIN" git_do fetch -q "$ORIGIN"
require_branch_absent "$ORIGIN/$BRANCH" require_branch_absent "$ORIGIN/$BRANCH"
# create remote branch # create remote branch
git push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH" git_do push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH"
git fetch -q "$ORIGIN" git_do fetch -q "$ORIGIN"
# configure remote tracking # configure remote tracking
git config "branch.$BRANCH.remote" "$ORIGIN" git config "branch.$BRANCH.remote" "$ORIGIN"
git config "branch.$BRANCH.merge" "refs/heads/$BRANCH" git config "branch.$BRANCH.merge" "refs/heads/$BRANCH"
git checkout "$BRANCH" git_do checkout "$BRANCH"
echo echo
echo "Summary of actions:" echo "Summary of actions:"
...@@ -226,11 +226,11 @@ cmd_track() { ...@@ -226,11 +226,11 @@ cmd_track() {
# sanity checks # sanity checks
require_clean_working_tree require_clean_working_tree
require_branch_absent "$BRANCH" require_branch_absent "$BRANCH"
git fetch -q "$ORIGIN" git_do fetch -q "$ORIGIN"
require_branch "$ORIGIN/$BRANCH" require_branch "$ORIGIN/$BRANCH"
# create tracking branch # create tracking branch
git checkout -b "$BRANCH" "$ORIGIN/$BRANCH" git_do checkout -b "$BRANCH" "$ORIGIN/$BRANCH"
echo echo
echo "Summary of actions:" echo "Summary of actions:"
...@@ -260,9 +260,9 @@ cmd_finish() { ...@@ -260,9 +260,9 @@ cmd_finish() {
require_branch "$BRANCH" require_branch "$BRANCH"
require_clean_working_tree require_clean_working_tree
if flag fetch; then if flag fetch; then
git fetch -q "$ORIGIN" "$MASTER_BRANCH" || \ git_do fetch -q "$ORIGIN" "$MASTER_BRANCH" || \
die "Could not fetch $MASTER_BRANCH from $ORIGIN." die "Could not fetch $MASTER_BRANCH from $ORIGIN."
git fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \ git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \
die "Could not fetch $DEVELOP_BRANCH from $ORIGIN." die "Could not fetch $DEVELOP_BRANCH from $ORIGIN."
fi fi
if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then
...@@ -276,9 +276,9 @@ cmd_finish() { ...@@ -276,9 +276,9 @@ cmd_finish() {
# in case a previous attempt to finish this release branch has failed, # in case a previous attempt to finish this release branch has failed,
# but the merge into master was successful, we skip it now # but the merge into master was successful, we skip it now
if ! git_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then if ! git_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then
git checkout "$MASTER_BRANCH" || \ git_do checkout "$MASTER_BRANCH" || \
die "Could not check out $MASTER_BRANCH." die "Could not check out $MASTER_BRANCH."
git merge --no-ff "$BRANCH" || \ git_do merge --no-ff "$BRANCH" || \
die "There were merge conflicts." die "There were merge conflicts."
# TODO: What do we do now? # TODO: What do we do now?
fi fi
...@@ -294,7 +294,7 @@ cmd_finish() { ...@@ -294,7 +294,7 @@ cmd_finish() {
[ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'" [ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'"
[ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'" [ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'"
[ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'" [ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'"
eval git tag $opts "$VERSION_PREFIX$VERSION" "$BRANCH" || \ eval git_do tag $opts "$VERSION_PREFIX$VERSION" "$BRANCH" || \
die "Tagging failed. Please run finish again to retry." die "Tagging failed. Please run finish again to retry."
fi fi
fi fi
...@@ -303,28 +303,28 @@ cmd_finish() { ...@@ -303,28 +303,28 @@ cmd_finish() {
# in case a previous attempt to finish this release branch has failed, # in case a previous attempt to finish this release branch has failed,
# but the merge into develop was successful, we skip it now # but the merge into develop was successful, we skip it now
if ! git_is_branch_merged_into "$BRANCH" "$DEVELOP_BRANCH"; then if ! git_is_branch_merged_into "$BRANCH" "$DEVELOP_BRANCH"; then
git checkout "$DEVELOP_BRANCH" || \ git_do checkout "$DEVELOP_BRANCH" || \
die "Could not check out $DEVELOP_BRANCH." die "Could not check out $DEVELOP_BRANCH."
# TODO: Actually, accounting for 'git describe' pays, so we should # TODO: Actually, accounting for 'git describe' pays, so we should
# ideally git merge --no-ff $tagname here, instead! # ideally git merge --no-ff $tagname here, instead!
git merge --no-ff "$BRANCH" || \ git_do merge --no-ff "$BRANCH" || \
die "There were merge conflicts." die "There were merge conflicts."
# TODO: What do we do now? # TODO: What do we do now?
fi fi
# delete branch # delete branch
if noflag keep; then if noflag keep; then
git branch -d "$BRANCH" git_do branch -d "$BRANCH"
fi fi
if flag push; then if flag push; then
git push "$ORIGIN" "$DEVELOP_BRANCH" || \ git_do push "$ORIGIN" "$DEVELOP_BRANCH" || \
die "Could not push to $DEVELOP_BRANCH from $ORIGIN." die "Could not push to $DEVELOP_BRANCH from $ORIGIN."
git push "$ORIGIN" "$MASTER_BRANCH" || \ git_do push "$ORIGIN" "$MASTER_BRANCH" || \
die "Could not push to $MASTER_BRANCH from $ORIGIN." die "Could not push to $MASTER_BRANCH from $ORIGIN."
if noflag notag; then if noflag notag; then
git push --tags "$ORIGIN" || \ git_do push --tags "$ORIGIN" || \
die "Could not push tags to $ORIGIN." die "Could not push tags to $ORIGIN."
fi fi
fi fi
......
...@@ -53,7 +53,7 @@ cmd_default() { ...@@ -53,7 +53,7 @@ cmd_default() {
parse_args "$@" parse_args "$@"
if ! git rev-parse --git-dir >/dev/null 2>&1; then if ! git rev-parse --git-dir >/dev/null 2>&1; then
git init git_do init
else else
# assure that we are not working in a repo with local changes # assure that we are not working in a repo with local changes
git_repo_is_headless || require_clean_working_tree git_repo_is_headless || require_clean_working_tree
...@@ -121,14 +121,14 @@ cmd_default() { ...@@ -121,14 +121,14 @@ cmd_default() {
# name exists, checkout that branch and use it for master # name exists, checkout that branch and use it for master
if ! git_local_branch_exists "$master_branch" && \ if ! git_local_branch_exists "$master_branch" && \
git_remote_branch_exists "origin/$master_branch"; then git_remote_branch_exists "origin/$master_branch"; then
git branch "$master_branch" "origin/$master_branch" >/dev/null 2>&1 git_do branch "$master_branch" "origin/$master_branch" >/dev/null 2>&1
elif ! git_local_branch_exists "$master_branch"; then elif ! git_local_branch_exists "$master_branch"; then
die "Local branch '$master_branch' does not exist." die "Local branch '$master_branch' does not exist."
fi fi
fi fi
# store the name of the master branch # store the name of the master branch
git config gitflow.branch.master "$master_branch" git_do config gitflow.branch.master "$master_branch"
fi fi
# add a develop branch if no such branch exists yet # add a develop branch if no such branch exists yet
...@@ -185,7 +185,7 @@ cmd_default() { ...@@ -185,7 +185,7 @@ cmd_default() {
fi fi
# store the name of the develop branch # store the name of the develop branch
git config gitflow.branch.develop "$develop_branch" git_do config gitflow.branch.develop "$develop_branch"
fi fi
# Creation of HEAD # Creation of HEAD
...@@ -194,8 +194,8 @@ cmd_default() { ...@@ -194,8 +194,8 @@ cmd_default() {
# it to be able to create new branches. # it to be able to create new branches.
local created_gitflow_branch=0 local created_gitflow_branch=0
if ! git rev-parse --quiet --verify HEAD >/dev/null 2>&1; then if ! git rev-parse --quiet --verify HEAD >/dev/null 2>&1; then
git symbolic-ref HEAD "refs/heads/$master_branch" git_do symbolic-ref HEAD "refs/heads/$master_branch"
git commit --allow-empty --quiet -m "Initial commit" git_do commit --allow-empty --quiet -m "Initial commit"
created_gitflow_branch=1 created_gitflow_branch=1
fi fi
...@@ -213,9 +213,9 @@ cmd_default() { ...@@ -213,9 +213,9 @@ cmd_default() {
# the develop branch now in that case (we base it on master, of course) # the develop branch now in that case (we base it on master, of course)
if ! git_local_branch_exists "$develop_branch"; then if ! git_local_branch_exists "$develop_branch"; then
if git_remote_branch_exists "origin/$develop_branch"; then if git_remote_branch_exists "origin/$develop_branch"; then
git branch "$develop_branch" "origin/$develop_branch" >/dev/null 2>&1 git_do branch "$develop_branch" "origin/$develop_branch" >/dev/null 2>&1
else else
git branch --no-track "$develop_branch" "$master_branch" git_do branch --no-track "$develop_branch" "$master_branch"
fi fi
created_gitflow_branch=1 created_gitflow_branch=1
fi fi
...@@ -225,7 +225,7 @@ cmd_default() { ...@@ -225,7 +225,7 @@ cmd_default() {
# switch to develop branch if its newly created # switch to develop branch if its newly created
if [ $created_gitflow_branch -eq 1 ]; then if [ $created_gitflow_branch -eq 1 ]; then
git checkout -q "$develop_branch" git_do checkout -q "$develop_branch"
fi fi
# finally, ask the user for naming conventions (branch and tag prefixes) # finally, ask the user for naming conventions (branch and tag prefixes)
...@@ -251,7 +251,7 @@ cmd_default() { ...@@ -251,7 +251,7 @@ cmd_default() {
printf "\n" printf "\n"
fi fi
[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
git config gitflow.prefix.feature "$prefix" git_do config gitflow.prefix.feature "$prefix"
fi fi
# Release branches # Release branches
...@@ -264,7 +264,7 @@ cmd_default() { ...@@ -264,7 +264,7 @@ cmd_default() {
printf "\n" printf "\n"
fi fi
[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
git config gitflow.prefix.release "$prefix" git_do config gitflow.prefix.release "$prefix"
fi fi
...@@ -278,7 +278,7 @@ cmd_default() { ...@@ -278,7 +278,7 @@ cmd_default() {
printf "\n" printf "\n"
fi fi
[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
git config gitflow.prefix.hotfix "$prefix" git_do config gitflow.prefix.hotfix "$prefix"
fi fi
...@@ -292,7 +292,7 @@ cmd_default() { ...@@ -292,7 +292,7 @@ cmd_default() {
printf "\n" printf "\n"
fi fi
[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
git config gitflow.prefix.support "$prefix" git_do config gitflow.prefix.support "$prefix"
fi fi
...@@ -306,7 +306,7 @@ cmd_default() { ...@@ -306,7 +306,7 @@ cmd_default() {
printf "\n" printf "\n"
fi fi
[ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion} [ "$answer" = "-" ] && prefix= || prefix=${answer:-$default_suggestion}
git config gitflow.prefix.versiontag "$prefix" git_do config gitflow.prefix.versiontag "$prefix"
fi fi
......
...@@ -136,7 +136,7 @@ require_version_arg() { ...@@ -136,7 +136,7 @@ require_version_arg() {
} }
require_base_is_on_develop() { require_base_is_on_develop() {
if ! git branch --no-color --contains "$BASE" 2>/dev/null \ if ! git_do branch --no-color --contains "$BASE" 2>/dev/null \
| sed 's/[* ] //g' \ | sed 's/[* ] //g' \
| grep -q "^$DEVELOP_BRANCH\$"; then | grep -q "^$DEVELOP_BRANCH\$"; then
die "fatal: Given base '$BASE' is not a valid commit on '$DEVELOP_BRANCH'." die "fatal: Given base '$BASE' is not a valid commit on '$DEVELOP_BRANCH'."
...@@ -164,14 +164,14 @@ cmd_start() { ...@@ -164,14 +164,14 @@ cmd_start() {
require_branch_absent "$BRANCH" require_branch_absent "$BRANCH"
require_tag_absent "$VERSION_PREFIX$VERSION" require_tag_absent "$VERSION_PREFIX$VERSION"
if flag fetch; then if flag fetch; then
git fetch -q "$ORIGIN" "$DEVELOP_BRANCH" git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH"
fi fi
if has "$ORIGIN/$DEVELOP_BRANCH" $(git_remote_branches); then if has "$ORIGIN/$DEVELOP_BRANCH" $(git_remote_branches); then
require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH" require_branches_equal "$DEVELOP_BRANCH" "$ORIGIN/$DEVELOP_BRANCH"
fi fi
# create branch # create branch
git checkout -b "$BRANCH" "$BASE" git_do checkout -b "$BRANCH" "$BASE"
echo echo
echo "Summary of actions:" echo "Summary of actions:"
...@@ -210,9 +210,9 @@ cmd_finish() { ...@@ -210,9 +210,9 @@ cmd_finish() {
require_branch "$BRANCH" require_branch "$BRANCH"
require_clean_working_tree require_clean_working_tree
if flag fetch; then if flag fetch; then
git fetch -q "$ORIGIN" "$MASTER_BRANCH" || \ git_do fetch -q "$ORIGIN" "$MASTER_BRANCH" || \
die "Could not fetch $MASTER_BRANCH from $ORIGIN." die "Could not fetch $MASTER_BRANCH from $ORIGIN."
git fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \ git_do fetch -q "$ORIGIN" "$DEVELOP_BRANCH" || \
die "Could not fetch $DEVELOP_BRANCH from $ORIGIN." die "Could not fetch $DEVELOP_BRANCH from $ORIGIN."
fi fi
if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then if has "$ORIGIN/$MASTER_BRANCH" $(git_remote_branches); then
...@@ -226,16 +226,16 @@ cmd_finish() { ...@@ -226,16 +226,16 @@ cmd_finish() {
# in case a previous attempt to finish this release branch has failed, # in case a previous attempt to finish this release branch has failed,
# but the merge into master was successful, we skip it now # but the merge into master was successful, we skip it now
if ! git_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then if ! git_is_branch_merged_into "$BRANCH" "$MASTER_BRANCH"; then
git checkout "$MASTER_BRANCH" || \ git_do checkout "$MASTER_BRANCH" || \
die "Could not check out $MASTER_BRANCH." die "Could not check out $MASTER_BRANCH."
if noflag squash; then if noflag squash; then
git merge --no-ff "$BRANCH" || \ git_do merge --no-ff "$BRANCH" || \
die "There were merge conflicts." die "There were merge conflicts."
# TODO: What do we do now? # TODO: What do we do now?
else else
git merge --squash "$BRANCH" || \ git_do merge --squash "$BRANCH" || \
die "There were merge conflicts." die "There were merge conflicts."
git commit git_do commit
fi fi
fi fi
...@@ -250,7 +250,7 @@ cmd_finish() { ...@@ -250,7 +250,7 @@ cmd_finish() {
[ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'" [ "$FLAGS_signingkey" != "" ] && opts="$opts -u '$FLAGS_signingkey'"
[ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'" [ "$FLAGS_message" != "" ] && opts="$opts -m '$FLAGS_message'"
[ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'" [ "$FLAGS_messagefile" != "" ] && opts="$opts -F '$FLAGS_messagefile'"
eval git tag $opts "$tagname" "$BRANCH" || \ eval git_do tag $opts "$tagname" "$BRANCH" || \
die "Tagging failed. Please run finish again to retry." die "Tagging failed. Please run finish again to retry."
fi fi
fi fi
...@@ -259,41 +259,41 @@ cmd_finish() { ...@@ -259,41 +259,41 @@ cmd_finish() {
# in case a previous attempt to finish this release branch has failed, # in case a previous attempt to finish this release branch has failed,
# but the merge into develop was successful, we skip it now # but the merge into develop was successful, we skip it now
if ! git_is_branch_merged_into "$BRANCH" "$DEVELOP_BRANCH"; then if ! git_is_branch_merged_into "$BRANCH" "$DEVELOP_BRANCH"; then
git checkout "$DEVELOP_BRANCH" || \ git_do checkout "$DEVELOP_BRANCH" || \
die "Could not check out $DEVELOP_BRANCH." die "Could not check out $DEVELOP_BRANCH."
# TODO: Actually, accounting for 'git describe' pays, so we should # TODO: Actually, accounting for 'git describe' pays, so we should
# ideally git merge --no-ff $tagname here, instead! # ideally git merge --no-ff $tagname here, instead!
if noflag squash; then if noflag squash; then
git merge --no-ff "$BRANCH" || \ git_do merge --no-ff "$BRANCH" || \
die "There were merge conflicts." die "There were merge conflicts."
# TODO: What do we do now? # TODO: What do we do now?
else else
git merge --squash "$BRANCH" || \ git_do merge --squash "$BRANCH" || \
die "There were merge conflicts." die "There were merge conflicts."
# TODO: What do we do now? # TODO: What do we do now?
git commit git_do commit
fi fi
fi fi
# delete branch # delete branch
if noflag keep; then if noflag keep; then
if [ "$BRANCH" = "$(git_current_branch)" ]; then if [ "$BRANCH" = "$(git_current_branch)" ]; then
git checkout "$MASTER_BRANCH" git_do checkout "$MASTER_BRANCH"
fi fi
git branch -d "$BRANCH" git_do branch -d "$BRANCH"
fi fi
if flag push; then if flag push; then
git push "$ORIGIN" "$DEVELOP_BRANCH" || \ git_do push "$ORIGIN" "$DEVELOP_BRANCH" || \
die "Could not push to $DEVELOP_BRANCH from $ORIGIN." die "Could not push to $DEVELOP_BRANCH from $ORIGIN."
git push "$ORIGIN" "$MASTER_BRANCH" || \ git_do push "$ORIGIN" "$MASTER_BRANCH" || \
die "Could not push to $MASTER_BRANCH from $ORIGIN." die "Could not push to $MASTER_BRANCH from $ORIGIN."
if noflag notag; then if noflag notag; then
git push --tags "$ORIGIN" || \ git_do push --tags "$ORIGIN" || \
die "Could not push tags to $ORIGIN." die "Could not push tags to $ORIGIN."
fi fi
git push "$ORIGIN" :"$BRANCH" || \ git_do push "$ORIGIN" :"$BRANCH" || \
die "Could not delete the remote $BRANCH in $ORIGIN." die "Could not delete the remote $BRANCH in $ORIGIN."
fi fi
...@@ -324,17 +324,17 @@ cmd_publish() { ...@@ -324,17 +324,17 @@ cmd_publish() {
# sanity checks # sanity checks
require_clean_working_tree require_clean_working_tree
require_branch "$BRANCH" require_branch "$BRANCH"
git fetch -q "$ORIGIN" git_do fetch -q "$ORIGIN"
require_branch_absent "$ORIGIN/$BRANCH" require_branch_absent "$ORIGIN/$BRANCH"
# create remote branch # create remote branch
git push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH" git_do push "$ORIGIN" "$BRANCH:refs/heads/$BRANCH"
git fetch -q "$ORIGIN" git_do fetch -q "$ORIGIN"
# configure remote tracking # configure remote tracking
git config "branch.$BRANCH.remote" "$ORIGIN" git_do config "branch.$BRANCH.remote" "$ORIGIN"
git config "branch.$BRANCH.merge" "refs/heads/$BRANCH" git_do config "branch.$BRANCH.merge" "refs/heads/$BRANCH"
git checkout "$BRANCH" git_do checkout "$BRANCH"
echo echo
echo "Summary of actions:" echo "Summary of actions:"
...@@ -351,11 +351,11 @@ cmd_track() { ...@@ -351,11 +351,11 @@ cmd_track() {
# sanity checks # sanity checks
require_clean_working_tree require_clean_working_tree
require_branch_absent "$BRANCH" require_branch_absent "$BRANCH"
git fetch -q "$ORIGIN" git_do fetch -q "$ORIGIN"
require_branch "$ORIGIN/$BRANCH" require_branch "$ORIGIN/$BRANCH"
# create tracking branch # create tracking branch
git checkout -b "$BRANCH" "$ORIGIN/$BRANCH" git_do checkout -b "$BRANCH" "$ORIGIN/$BRANCH"
echo echo
echo "Summary of actions:" echo "Summary of actions:"
......
...@@ -169,12 +169,12 @@ cmd_start() { ...@@ -169,12 +169,12 @@ cmd_start() {
# fetch remote changes # fetch remote changes
if flag fetch; then if flag fetch; then
git fetch -q "$ORIGIN" "$BASE" git_do fetch -q "$ORIGIN" "$BASE"
fi fi
require_branch_absent "$BRANCH" require_branch_absent "$BRANCH"
# create branch # create branch
git checkout -b "$BRANCH" "$BASE" git_do checkout -b "$BRANCH" "$BASE"
echo echo
echo "Summary of actions:" echo "Summary of actions:"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment