Last active
January 24, 2018 12:47
-
-
Save MorrisJobke/e42359494ddd633cb18e9a844b67b4c8 to your computer and use it in GitHub Desktop.
Deletes all branches in a git repo of which the last commit is not authored by Morris
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
<?php | |
$branchesOutput = shell_exec('git branch | egrep -v "^\\*"'); | |
$branches = explode("\n", $branchesOutput); | |
foreach ($branches as $branch) { | |
$branch = trim($branch); | |
if ($branch === '') { | |
continue; | |
} | |
$output = shell_exec("git show $branch | head -n 2 | grep 'Author:' | grep -v Morris -q && git branch -D $branch"); | |
if (!empty($output)) { | |
echo $output; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment