diff --git a/bash-files/bashrc b/bash-files/bashrc index eab3815..71d68e2 100644 --- a/bash-files/bashrc +++ b/bash-files/bashrc @@ -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 diff --git a/bin/cf_certify_push b/bin/cf_certify_push new file mode 100755 index 0000000..9f1a806 --- /dev/null +++ b/bin/cf_certify_push @@ -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 $@ diff --git a/bin/cf_merge_branches b/bin/cf_merge_branches new file mode 100755 index 0000000..b70dbbf --- /dev/null +++ b/bin/cf_merge_branches @@ -0,0 +1,61 @@ +#!/bin/bash + +set -e +. /nail/workflow/pushlib.sh + +usage() { + echo "$0 ..." + 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 $@ diff --git a/bin/cf_prepare_for_push b/bin/cf_prepare_for_push new file mode 100755 index 0000000..42dcef6 --- /dev/null +++ b/bin/cf_prepare_for_push @@ -0,0 +1,35 @@ +#!/bin/bash + +set -e + +usage() { + echo "$0 " + 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 $@ diff --git a/zsh-files/oh-my-zsh b/zsh-files/oh-my-zsh index eafd5f3..3913106 160000 --- a/zsh-files/oh-my-zsh +++ b/zsh-files/oh-my-zsh @@ -1 +1 @@ -Subproject commit eafd5f325208421b82a770e57441dd1063eb5745 +Subproject commit 3913106b2e7127d396f27b652df812340ec0c871 diff --git a/zsh-files/zshrc b/zsh-files/zshrc index 55eebd0..df0fae7 100644 --- a/zsh-files/zshrc +++ b/zsh-files/zshrc @@ -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 {