Last active
December 5, 2018 12:55
-
-
Save erplsf/985a03a117738ae894d4897fae530c61 to your computer and use it in GitHub Desktop.
Update revisions.
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
function pbu() { | |
# save branch to go back later | |
(git rev-parse --abbrev-ref HEAD) | |
current_branch=$? | |
# check for changes to decide if we want to stash them | |
(git diff-index --quiet HEAD --) | |
changes_present=$? | |
if [[ $changes_present -ne 0 ]]; then | |
echo 'Detected work, stashing the changes' | |
git stash | |
fi | |
git checkout development && | |
git fetch && | |
git reset --hard origin/development && | |
bundle update | |
# detect if Gemfile.lock changed and therefore push is needed | |
if ! git diff-index --quiet HEAD -- Gemfile.lock; then | |
echo 'Detected changes in Gemfile.lock, will commit and push' | |
git add Gemfile.lock && | |
git commit -m "Update revisions" && | |
git push && | |
else | |
echo 'No changes after bundle update, nothing to push' | |
fi | |
git checkout $current_branch | |
if [[ $changes_present -ne 0 ]]; then | |
echo 'Restoring work from stash' | |
git stash pop | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment