Created
April 26, 2019 17:12
-
-
Save erinxocon/6f6e1f61dcdbce108b9f5c7b93266368 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
import delegator | |
c = delegator.run('git branch -r --merged').pipe('grep -v -E "HEAD|store|stage"') | |
merged_branches = c.out.splitlines()[:-1] | |
for i in merged_branches: | |
stripped = i.strip() | |
replaced = stripped.replace('origin/', '') | |
try: | |
c = delegator.run('git show --format="%ci %cr %an" {0}'.format(stripped)).pipe('head -n 1') | |
except BrokenPipeError as e: | |
print(stripped) | |
delegator.run('git push origin --delete {0}'.format(replaced)) | |
with open('removed.txt', mode='a', encoding='utf-8') as f: | |
f.write('{0} {1}\n'.format(c.out.strip(), stripped)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment