Created
May 21, 2015 21:08
-
-
Save szymonskirgajllo/ae1bfd32913bf1f71e25 to your computer and use it in GitHub Desktop.
First version of the script to remove old branches in git
This file contains hidden or 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 | |
| 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