Created
June 30, 2016 07:31
-
-
Save OleksandrKucherenko/0999d809a05a9589536d7ac3c47b4102 to your computer and use it in GitHub Desktop.
Get Latest version of the source code from Upstream Master and rebase own branch against it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# wait for Enter key | |
function pause(){ | |
read -p "$*" | |
} | |
MASTER=master | |
BRANCH_NAME="$(git rev-parse --abbrev-ref HEAD)" | |
CHANGED_FILES="$(git status --porcelain --untracked-files=no | wc -l)" | |
echo '' | |
echo 'This script will REBASE current branch against "master". Current branch is:' $BRANCH_NAME | |
echo 'If its "master" already than we just update the branch to latest' | |
echo 'Detected changed file(s):' $CHANGED_FILES | |
echo '' | |
if [ $CHANGED_FILES -gt 0 ]; then | |
pause 'Press [Enter] to stash the changes' | |
# save current changes to STASH | |
git stash | |
fi | |
echo '' | |
pause 'Press [Enter] to start the pull...' | |
# don't checkout master if we already in it | |
if [ "$BRANCH_NAME" != "$MASTER" ]; then | |
# switch git to MASTER branch | |
git checkout master | |
fi | |
# get updates of the MASTER | |
git pull --rebase upstream master | |
# update submodules and reset them to initial state | |
git pull --recurse-submodules | |
git submodule update --init --recursive | |
# if branch NOT a master than checkout it | |
if [ "$BRANCH_NAME" != "$MASTER" ]; then | |
# return back to our branch | |
git checkout $BRANCH_NAME | |
else | |
echo "We are the MASTER's of the world..." | |
fi | |
echo '' | |
pause 'Press [Enter] to start merge...' | |
# Can be used MERGE operation instead of REBASE | |
#git merge master | |
# let's reduce the complexity of the PULL REQUEST's by using the REBASE | |
git rebase master | |
# http://www.gitguys.com/topics/merging-with-a-gui/ | |
echo '' | |
echo 'In case of conflicts resolving needs, use:' | |
echo ':: git mergetool -t kdiff3' | |
echo '' | |
# if we have changes before we start, than recover them | |
if [ $CHANGED_FILES -gt 0 ]; then | |
pause 'Press [Enter] to apply stash...' | |
# apply changes and remove stash | |
git stash pop | |
else | |
echo "No changes in STASH that we have to apply. Good work, keep it clean!" | |
fi | |
if whiptail --yesno "Run submodules fix?" 10 30 ;then | |
./git-fix-submodules.sh | |
else | |
echo "We are lucky, no submodules issues." | |
fi | |
if whiptail --yesno "Run the cleanup?" 10 30 ;then | |
./gradlew clean | |
./gradlew --stop | |
rm -rf .gradle | |
else | |
echo "No cleanup, maybe next time we will do that." | |
fi | |
echo '' | |
echo All Done. Goodbye. | |
exit 0 |
Author
OleksandrKucherenko
commented
Nov 18, 2019
- https://medium.com/@tamirsuliman/getting-started-building-linux-bash-graphical-ui-scripts-447cee97c167
- https://en.wikibooks.org/wiki/Bash_Shell_Scripting/Whiptail
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment