Skip to content

Instantly share code, notes, and snippets.

@szymonskirgajllo
Created May 21, 2015 21:08
Show Gist options
  • Select an option

  • Save szymonskirgajllo/ae1bfd32913bf1f71e25 to your computer and use it in GitHub Desktop.

Select an option

Save szymonskirgajllo/ae1bfd32913bf1f71e25 to your computer and use it in GitHub Desktop.
First version of the script to remove old branches in git
#!/bin/bash
branch=develop
export partOfYourMail=skirgaj
export howLong=1
export type=weeks
echo "Type branch which you want to check -> "
read branch
echo "Type part of your email -> "
read partOfYourMail
git branch --all --merged $branch\
| grep -v "master"\
| grep -v "develop"\
| xargs -n 1 bash -c 'result=$(git show -s --format="%ae %cr" $0);\
splittedInfo=($result);\
authorMail=${splittedInfo[0]};\
howMany=${splittedInfo[1]};\
isWeek=${splittedInfo[2]};\
if [ "$isWeek" = "$type" ] && [[ "$authorMail" =~ "$partOfYourMail" ]];\
then\
if [ "$howMany" -gt "$howLong" ];\
then\
echo "this branch should be remove:" $0;
fi;\
fi;'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment