git workflow tools
This commit is contained in:
parent
0eb01fd8ba
commit
99a1b2bb39
6 changed files with 150 additions and 3 deletions
51
bin/cf_certify_push
Executable file
51
bin/cf_certify_push
Executable 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
61
bin/cf_merge_branches
Executable 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
35
bin/cf_prepare_for_push
Executable 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 $@
|
||||
Loading…
Add table
Add a link
Reference in a new issue