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