Skip to content

Instantly share code, notes, and snippets.

@aolshevskiy
Created April 26, 2012 11:17
Show Gist options
  • Save aolshevskiy/2498893 to your computer and use it in GitHub Desktop.
Save aolshevskiy/2498893 to your computer and use it in GitHub Desktop.
#!/bin/bash
function filter_ignored_branches() {
local branches=$1
local ignored=$2
local result=""
for branch in $branches; do
if echo $ignored | grep -v $branch > /dev/null ; then
if [ "$INVERT" != "true" ]; then
result="$result $branch"
fi
else
if [ "$INVERT" == "true" ]; then
result="$result $branch"
fi
fi
done
echo $result
}
set -e
if [ "$1" == "-v" ]; then
INVERT=true
shift
else
INVERT=false
fi
USER=$1
shift
git fetch
git checkout master
git reset --hard origin/master
BRANCHES=""
for branch in $(git branch -r); do
if git log ${branch}^..${branch} | grep "$USER" > /dev/null ; then
branch=$(echo $branch | sed s/.*\\///)
BRANCHES="$BRANCHES $branch"
fi
done
IGNORED_BRANCHES="$@"
if [ "$IGNORED_BRANCHES" != "" ]; then
BRANCHES=$(filter_ignored_branches "$BRANCHES" "$IGNORED_BRANCHES")
fi
for branch in $BRANCHES; do echo $branch; done
read -p 'update[Y/n]:' -n1 UPDATE
if [ "$UPDATE" != "" ] && [ "$UPDATE" != "y" ]; then
exit 0
fi
for branch in $BRANCHES; do
git checkout $branch
git merge --no-edit master
git push origin $branch
git checkout master
git branch -d $branch
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment