| | #!/bin/bash
|
| |
|
| |
|
| |
|
| |
|
| | BOLD='\e[1m'
|
| | NOBOLD='\e[21m'
|
| |
|
| |
|
| | empty_lines() { printf '\n\n'; }
|
| | bold_echo() {
|
| | echo -e "${BOLD}$1${NOBOLD}"
|
| | }
|
| |
|
| | stop_on_fail() {
|
| |
|
| | set -e
|
| |
|
| | set -o pipefail
|
| | }
|
| |
|
| |
|
| | continue_on_fail() {
|
| | set +e
|
| | set +o pipefail
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| | prompt() {
|
| | if [ $with_prompts ]
|
| | then
|
| | if [ $2 = true ]
|
| | then
|
| | paren_text="(Y/n)"
|
| | else
|
| | paren_text="(y/N)"
|
| | fi
|
| |
|
| | while true; do
|
| | read -p "$1 $paren_text > " yn
|
| | case $yn in
|
| | [Yy]* ) prompt_result=true; break;;
|
| | [Nn]* ) prompt_result=false; break;;
|
| | * ) echo "Please answer yes or no.";;
|
| | esac
|
| | done
|
| | else
|
| |
|
| | prompt_result=$2;
|
| | fi
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| | pull_from_develop_fn() {
|
| | empty_lines
|
| | prompt "Do you want to pull from develop?" true
|
| | if [ $prompt_result = false ]
|
| | then
|
| | bold_echo "You don't want to pull from develop. Why are you running this script?"
|
| | exit
|
| | fi
|
| |
|
| | bold_echo "Pulling from Blockly's develop branch"
|
| | sleep .5
|
| |
|
| |
|
| | continue_on_fail
|
| | git pull https://github.com/google/blockly.git develop
|
| | stop_on_fail
|
| | }
|
| |
|
| |
|
| |
|
| | run_cleanup_fn() {
|
| | empty_lines
|
| | prompt "Ready to run cleanup.sh. Continue?" true
|
| | if [ $prompt_result = false ]
|
| | then
|
| | bold_echo "Skipping cleanup.sh"
|
| | prompt_for_merge_abort
|
| | empty_lines
|
| | bold_echo "Done"
|
| | exit
|
| | fi
|
| |
|
| | bold_echo "Running cleanup.sh"
|
| | sleep .5
|
| |
|
| | ./cleanup.sh
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| | prompt_for_merge_abort() {
|
| | empty_lines
|
| | prompt "Do you want to abort this merge?" false
|
| | if [ $prompt_result = false ]
|
| | then
|
| | bold_echo "Continuing with merge..."
|
| | else
|
| | bold_echo "Running git merge --abort"
|
| | git merge --abort
|
| | display_status_fn
|
| | bold_echo "Done"
|
| | exit
|
| | fi
|
| | }
|
| |
|
| |
|
| |
|
| | display_status_fn() {
|
| | empty_lines
|
| | prompt "Do you want to display the current status?" true
|
| | if [ $prompt_result = true ]
|
| | then
|
| |
|
| | bold_echo "Current status"
|
| | sleep .5
|
| | git status
|
| | else
|
| | bold_echo "Skipping status display."
|
| | fi
|
| | }
|
| |
|
| |
|
| |
|
| | finish_fn() {
|
| | prompt_for_merge_abort
|
| | bold_echo "Done. You may need to manually resolve conflicts."
|
| |
|
| | empty_lines
|
| | sleep .5
|
| | echo "Fix conflicts and run 'git commit'."
|
| | echo "Use 'git add <file>' to mark resolution."
|
| | echo "Use 'git merge --abort' to abort this merge."
|
| | }
|
| |
|
| |
|
| | with_prompts=$1
|
| |
|
| |
|
| | stop_on_fail
|
| | pull_from_develop_fn
|
| | run_cleanup_fn
|
| | display_status_fn
|
| | finish_fn
|
| |
|