From af7204418f50caa9a7d62033189c4179ab5502ad Mon Sep 17 00:00:00 2001 From: Mikhail Goncharov Date: Mon, 29 Jun 2020 11:41:48 +0200 Subject: [PATCH] error handling --- scripts/cleanup_branches.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/cleanup_branches.py b/scripts/cleanup_branches.py index e8b6122..f420f63 100755 --- a/scripts/cleanup_branches.py +++ b/scripts/cleanup_branches.py @@ -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) if committed_date < max_age and _has_pattern_match(reference.name, branch_patterns): print(reference.name, flush=True) - del_count += 1 if not dry_run: try: remote.push(refspec=':{}'.format(reference.remote_head)) - except git.GitCommandError: - print('ERROR: Failed to delete {}.'.format(reference.name), flush=True) + del_count += 1 + except git.GitCommandError as err: + print('ERROR: Failed to delete "{}": {}'.format(reference.name, err), flush=True) fail_count += 1 print('Deleted {} branches.'.format(del_count)) if fail_count > 0: