2016-07-21 13:48:49 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-07-17 09:55:39 +00:00
|
|
|
set -o pipefail
|
|
|
|
set -e
|
|
|
|
|
2017-09-19 10:10:53 +00:00
|
|
|
source "${HOME}/bin/script_framework.sh"
|
2016-07-21 13:48:49 +00:00
|
|
|
|
2017-08-08 09:56:36 +00:00
|
|
|
step "Loading required keys to pull"
|
|
|
|
git loadkey
|
|
|
|
|
2016-07-21 13:48:49 +00:00
|
|
|
step "Fetching data from remote..."
|
|
|
|
for remote in $(git remote -v | awk '{print $1}' | sort | uniq); do
|
|
|
|
step "+++ Remote: '${remote}'"
|
2018-01-07 14:17:19 +00:00
|
|
|
git fetch -p ${remote} --tags
|
2016-07-21 13:48:49 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
step "Rebasing branch / updating submodules..."
|
|
|
|
git pull --rebase && git submodule update --init --recursive
|
|
|
|
|
|
|
|
step "Cleaning local branches..."
|
|
|
|
for branch in $(git branch --merged | grep -v '^*'); do
|
|
|
|
# Do not delete master as the main branch
|
|
|
|
if ( test "${branch}" != "master" ); then
|
|
|
|
git branch -d ${branch}
|
|
|
|
fi
|
|
|
|
done
|
2016-10-24 06:16:23 +00:00
|
|
|
|
|
|
|
step "Removing local branches where remote branch is gone..."
|
2016-11-30 11:43:28 +00:00
|
|
|
if ( git branch -vv | grep -q ': gone]' ); then
|
2016-10-24 06:20:44 +00:00
|
|
|
git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D
|
|
|
|
fi
|