Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- from subprocess import getoutput
- import re
- def main():
- branches_dict = branches()
- save_nums = input('type branch numbers to NOT delete, seperated by spaces\n')
- save_nums = map(int, re.findall(r'\d+', save_nums))
- for num in save_nums:
- branches_dict.pop(num)
- for k, v in branches_dict.items():
- print(k, v)
- input('will delete these, press ctrl-c to stop, otherwise return...')
- for branch in branches_dict.values():
- getoutput('git branch -D ' + branch)
- return branches_dict
- def branches():
- branches = getoutput('git branch').split('\n')
- branches = [b for b in branches if 'master' not in b]
- return print_branches_return_dict(branches)
- def print_branches_return_dict(branches):
- branch_dict = {}
- for i, b in enumerate(branches):
- if i < 10:
- print(i, '', b)
- else:
- print(i, b)
- branch_dict[i] = b
- return branch_dict
- if __name__ == '__main__':
- main()
Add Comment
Please, Sign In to add comment