Created
January 20, 2018 22:25
-
-
Save danie1k/e10ff590b4602b12c84320ff24501154 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
tarBranch=$(git branch -r --merged | grep -v master | grep -v develop | sed 's/origin\///') | |
for branch in $tarBranch | |
do | |
echo "Branch: $branch" | |
lastDate=$(git show -s --format=%ci origin/$branch) | |
convertDate=$(echo $lastDate | cut -d' ' -f 1) | |
Todate=$(date -d "$convertDate" +'%s') | |
current=$(date +'%s') | |
day=$(( ( $current - $Todate )/60/60/24 )) | |
echo " last commit on $branch branch was $day days ago" | |
if [ "$day" -gt 90 ]; then | |
echo " delete the old branch $branch" | |
git push origin :$branch | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment