| 1234567891011121314151617181920212223 |
- #!/usr/bin/env python3
- import pathlib
- import subprocess
- import sys
- def main() -> None:
- branches = sys.argv[1:]
- if has_branchless():
- run(['git', 'hide'] + ['draft()::' + branch for branch in branches])
- else:
- run(['git', 'branch', '-d'] + branches)
- run(['git', 'push', 'origin'] + [':' + branch for branch in branches])
- def has_branchless() -> bool:
- repo_root = run(['git', 'rev-parse', '--show-toplevel'], capture_output=True, text=True).stdout.rstrip('\n')
- return pathlib.Path(repo_root, '.git/branchless/config').is_file()
- def run(cmd, capture_output=False, text=None):
- return subprocess.run(cmd, capture_output=capture_output, check=True, text=text)
- if __name__ == '__main__':
- main()
|