Created
December 29, 2015 19:55
-
-
Save bryanburgers/78bdd7b3a904342569b9 to your computer and use it in GitHub Desktop.
Take a selection of branches, merge them all together, and force-push them to a remote repo
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 | |
set -e | |
current_branch="$(git symbolic-ref HEAD 2>/dev/null)" | |
short_current_branch=${current_branch#refs/heads/} | |
date=$(date --iso-8601 --date="-1 month") | |
options=() | |
while IFS= read -r entry | |
do | |
eval $entry | |
shortref=${ref#refs/heads/} | |
refmod=$(git log -n 1 $shortref --date=short --format="%cd") | |
state="on" | |
if [[ $refmod < $date ]] | |
then | |
state="off" | |
fi | |
options+=($shortref "$refmod" $state) | |
echo ${options[@]} | |
done < <(git for-each-ref --sort=-committerdate --shell --format="ref=%(refname)" refs/heads) | |
echo ${options[@]} | |
cmd=(dialog --separate-output --checklist "Select options:" 22 76 16) | |
echo "${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty | |
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) | |
clear | |
temporary_branch="deploy-$(date +%Y%m%dT%H%M)-$(openssl rand -hex 2)" | |
git checkout -b $temporary_branch origin/master | |
git merge --no-ff -m "Combine for deploy" -m "${choices}" ${choices} | |
git push --force origin ${temporary_branch}:bryan | |
git checkout $short_current_branch | |
git branch -D $temporary_branch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment