2016-12-12 15:57:39 +00:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
|
|
|
STEP_COLOR="\033[0;36m"
|
|
|
|
NO_COLOR="\033[0m"
|
|
|
|
|
|
|
|
function step {
|
|
|
|
echo -e ${STEP_COLOR}[$(date +%H:%M:%S)] $1${NO_COLOR}
|
|
|
|
}
|
|
|
|
|
|
|
|
### Determine what to push
|
|
|
|
|
|
|
|
step "Collect refs to push to origin"
|
2016-07-21 13:48:49 +00:00
|
|
|
|
2016-11-12 18:18:49 +00:00
|
|
|
CURRENT_BRANCH=$(git branch --list | awk '/^\*/{print $2}')
|
2016-12-12 15:57:39 +00:00
|
|
|
REQUIRED=$(git show-ref --tags | grep -v -F "$(git ls-remote --tags origin | grep -v '\^{}' | cut -f 2)" | cut -d '/' -f 3 | xargs)
|
|
|
|
|
|
|
|
if ( test "$(git show-ref refs/heads/${CURRENT_BRANCH} | cut -d ' ' -f 1)" != "$(git show-ref refs/remotes/origin/${CURRENT_BRANCH} | cut -d ' ' -f 1)" ); then
|
|
|
|
REQUIRED="${REQUIRED} ${CURRENT_BRANCH}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${REQUIRED}" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
step "Execute pre-push auto-hook"
|
|
|
|
git autohook pre-push
|
|
|
|
|
|
|
|
step "Execute pushes..."
|
|
|
|
for ref in ${REQUIRED}; do
|
|
|
|
git push origin ${ref}
|
|
|
|
done
|
2016-07-21 13:48:49 +00:00
|
|
|
|
2016-12-12 15:57:39 +00:00
|
|
|
step "Execute post-push auto-hook"
|
|
|
|
git autohook post-push
|