Skip to content

Commit

Permalink
Better abstraction for "git test pass steps" Refs #6725
Browse files Browse the repository at this point in the history
  • Loading branch information
martyngigg committed Mar 18, 2013
1 parent e36fc7c commit 1620e4b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 12 deletions.
19 changes: 7 additions & 12 deletions Code/Tools/Workflow/git/git-test
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ start_testing() {
exit 1
fi

# Ensure we have everything from the remote
git_halt_on_error fetch -p

# Is the name correct
remote_branch_exists ${TEST_BRANCH}
if [ $? -eq 0 ]; then
Expand Down Expand Up @@ -176,15 +179,10 @@ end_testing() {
read publish
done
if [ "${publish}" = "y" ]; then
# Publish
git_halt_on_error push origin ${PRODUCTION_BRANCH}
# Delete branch on the remote
git_halt_on_error push origin :${testbranch}
# Delete local branch if there
local_branch_exists ${testbranch}
if [ $? -eq 1 ]; then
git_halt_on_error branch -D ${testbranch}
fi
update_branch_from_remote ${PRODUCTION_BRANCH}
publish_branch ${PRODUCTION_BRANCH}
delete_remote_branch ${testbranch}
delete_local_branch ${testbranch}
else
echo "Warning: Branch is still merged locally but has NOT been pushed to the remote."
exit 0
Expand Down Expand Up @@ -227,9 +225,6 @@ main() {
exit 1
fi

# Ensure we have everything from the remote
git_halt_on_error fetch -p

if [ $START_MODE -eq 1 ]; then
start_testing
elif [ $RESULT_MODE -eq 1 ]; then
Expand Down
47 changes: 47 additions & 0 deletions Code/Tools/Workflow/git/gitworkflow-helpers
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,50 @@ merge_in_progress() {
fi
return $retval
}

# Publish given branch
publish_branch() {
if [ ! $# -eq 1 ]; then
echo "publish_branch requires a single local branchname argument"
exit 1
fi

git_halt_on_error push origin $1
}

# Update given local branch to remote
# Essentially
# git fetch -p
# git rebase --preserve-merges origin/<branchname>
update_branch_from_remote() {
if [ ! $# -eq 1 ]; then
echo "update_branch_from_remote requires a single local branchname argument"
exit 1
fi

git_halt_on_error fetch -p
git_halt_on_error rebase --preserve-merges origin/$1
}

# Delete branch on remote
delete_remote_branch() {
if [ ! $# -eq 1 ]; then
echo "delete_remote_branch requires a single local branchname argument"
exit 1
fi
# Delete branch on the remote
git_halt_on_error push origin :$1
}

# Delete branch locally
delete_local_branch() {
if [ ! $# -eq 1 ]; then
echo "delete_local_branch requires a single local branchname argument"
exit 1
fi
# Delete local branch if there
local_branch_exists $1
if [ $? -eq 1 ]; then
git_halt_on_error branch -D $1
fi
}

0 comments on commit 1620e4b

Please sign in to comment.