git workflow tools

This commit is contained in:
Haak Saxberg 2014-06-26 00:12:52 -07:00
parent 0eb01fd8ba
commit 99a1b2bb39
6 changed files with 150 additions and 3 deletions

View file

@ -84,7 +84,7 @@ alias kp="ps auxwww"
# general path munging
PATH=~/pg/yelp-main/tools:$PATH
PATH=~/local/bin:$PATH
PATH=~/local/bin:~/dotfiles/bin:$PATH
if [ -f /opt/local/etc/bash_completion.d/git ]; then
source /opt/local/etc/bash_completion.d/git

51
bin/cf_certify_push Executable file
View file

@ -0,0 +1,51 @@
#!/bin/bash
set -e
. /nail/workflow/pushlib.sh
main() {
PUSHBRANCH=$1
git fetch
git checkout "$PUSHBRANCH"
git reset --hard "origin/$PUSHBRANCH"
separator
MASTER_SHA=`git rev-parse --short origin/master`
git log --graph --oneline --color origin/master^..HEAD | sed "/$MASTER_SHA/q"
separator
echo "*** push this deploy branch into master?"
if yesno; then
push-to-master $PUSHBRANCH
cleanup-deploy-branch $PUSHBRANCH
fi
}
yesno() {
local answer
read -p 'y/n? ' answer
if [[ "$answer" == "y" ]]; then
return 0
elif [[ "$answer" == "n" ]]; then
return 1
else
yesno
fi
}
push-to-master() {
PUSHBRANCH=$1
colorize git checkout master
git pull origin master
colorize git merge --no-ff "$PUSHBRANCH"
git push origin master
}
cleanup-deploy-branch() {
PUSHBRANCH=$1
colorize git push origin :"$PUSHBRANCH"
colorize git branch -d $PUSHBRANCH
}
main $@

61
bin/cf_merge_branches Executable file
View file

@ -0,0 +1,61 @@
#!/bin/bash
set -e
. /nail/workflow/pushlib.sh
usage() {
echo "$0 <branch1> <branch2> ..."
exit 1
}
main() {
BRANCH_NAMES=${@:1}
BRANCH_BASE="origin/master"
TARGET="$(git-branch-name)"
colorize git fetch origin
colorize git reset --hard $BRANCH_BASE
merge-branches $TARGET $BRANCH_NAMES
separator
list-pushplans $TARGET $BRANCH_BASE
}
merge-branches() {
DEPLOY=$1
BRANCH_NAMES=${@:2}
for BRANCH_NAME in $BRANCH_NAMES
do
separator
if ! colorize git merge --no-ff --no-commit "origin/$BRANCH_NAME"; then
echo -e "${RED}Unable to merge $BRANCH_NAME.${NORMAL}"
git diff
reset_branch_and_abort $DEPLOY
fi
git merge --abort
colorize git merge --no-ff "origin/$BRANCH_NAME"
done
}
list-pushplans() {
TARGET=$1
BASE=$2
echo -e "${PURPLE}Pushplans present in this deploy:${NORMAL}"
git diff --name-only "$(git merge-base "$TARGET" "$BASE")..$TARGET" -- pushplans
}
reset-branch-and-abort() {
RESET_TARGET=$1
RESET_SHA="$(git rev-parse "$RESET_TARGET")"
separator
git reset --hard "$RESET_SHA"
make clean
separator
echo -e "Aborted."
exit 1
}
main $@

35
bin/cf_prepare_for_push Executable file
View file

@ -0,0 +1,35 @@
#!/bin/bash
set -e
usage() {
echo "$0 <deploy-branch-name>"
exit 1
}
main() {
if [ -z "$TESTING" ]; then
CHANNEL="platform"
else
CHANNEL="haaktest"
fi
USERNAME=$USER
DEPLOY_BRANCH="$1"
if [ -z $DEPLOY_BRANCH ]; then
usage
fi
nodebot $CHANNEL "push starting; ping $USERNAME with branch name if you want in."
setup_deploy_branch "$DEPLOY_BRANCH"
}
setup_deploy_branch() {
DEPLOY_BRANCH_NAME=$1
git fetch origin
git checkout -b $DEPLOY_BRANCH_NAME origin/master
}
main $@

@ -1 +1 @@
Subproject commit eafd5f325208421b82a770e57441dd1063eb5745
Subproject commit 3913106b2e7127d396f27b652df812340ec0c871

View file

@ -52,7 +52,7 @@ source $ZSH/oh-my-zsh.sh
#
alias vim="~/local/bin/vim"
export PATH=~/local/bin:$PATH
export PATH=~/local/bin:~/dotfiles/bin:$PATH
export EDITOR=vim
function branch_prompt {