Created
June 19, 2019 12:14
-
-
Save rcbop/fb45181b9d403bffc0170e62d4d624fe to your computer and use it in GitHub Desktop.
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 | |
DRY_RUN=${DRY_RUN:-"true"} | |
ECHO='echo ' | |
OLDPWD=$(pwd) | |
cd ${GITHUB_DIR?:'yo man, provide a damn github root dir'} | |
for dir in $(find . -maxdepth 1 -type d | tail -n +2); do | |
for branch in $(git branch -a | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'master$'); do | |
if [[ "$(git log $branch --since "2 months ago" | wc -l)" -eq 0 ]]; then | |
if [[ "$DRY_RUN" = "false" ]]; then | |
ECHO="" | |
fi | |
local_branch_name=$(echo "$branch" | sed 's/remotes\/origin\///') | |
$ECHO git branch -d $local_branch_name | |
$ECHO git push origin --delete $local_branch_name | |
fi | |
done | |
done | |
cd $OLDPWD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment