1
0
Fork 0

error handling

This commit is contained in:
Mikhail Goncharov 2020-06-29 11:41:48 +02:00
parent 9a2a236dd0
commit af7204418f

View file

@ -47,12 +47,12 @@ def delete_old_branches(repo_path: str, max_age: datetime.datetime, branch_patte
committed_date = datetime.datetime.fromtimestamp(reference.commit.committed_date) committed_date = datetime.datetime.fromtimestamp(reference.commit.committed_date)
if committed_date < max_age and _has_pattern_match(reference.name, branch_patterns): if committed_date < max_age and _has_pattern_match(reference.name, branch_patterns):
print(reference.name, flush=True) print(reference.name, flush=True)
del_count += 1
if not dry_run: if not dry_run:
try: try:
remote.push(refspec=':{}'.format(reference.remote_head)) remote.push(refspec=':{}'.format(reference.remote_head))
except git.GitCommandError: del_count += 1
print('ERROR: Failed to delete {}.'.format(reference.name), flush=True) except git.GitCommandError as err:
print('ERROR: Failed to delete "{}": {}'.format(reference.name, err), flush=True)
fail_count += 1 fail_count += 1
print('Deleted {} branches.'.format(del_count)) print('Deleted {} branches.'.format(del_count))
if fail_count > 0: if fail_count > 0: