Created
May 24, 2012 11:47
-
-
Save abtris/2780984 to your computer and use it in GitHub Desktop.
Remove old git branches
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
#!/usr/bin/env php | |
<?php | |
$local = exec("git branch | xargs $1"); | |
$lines = explode(" ", $local); | |
$limit = strtotime("-2 week"); | |
$exclude = array("*", "master"); | |
foreach ($exclude as $i) { | |
$k = array_search($i, $lines); | |
unset($lines[$k]); | |
} | |
$k = 0; | |
foreach ($lines as $line) { | |
$output[$k]['name'] = $line; | |
$output[$k]['time'] = exec('git log '.$line.' --pretty=format:"%at" -1'); | |
if ($limit>$output[$k]['time']) { | |
echo "This branch should be deleted $line\n"; | |
exec("git branch -d $line"); | |
} | |
$k++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment