Skip to content

Commit

Permalink
Issue-#17 fix: Different statements used for listing and deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmakkar08 committed Nov 18, 2016
1 parent 7e1f2e2 commit 933a9b7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions git_del_br.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,13 @@ def filter_prefix(branches, prefix):
return [branch for branch in branches if branch.startswith(prefix)]


def _print_branches(branches_to_remove, type_):
if len(branches_to_remove):
def _print_branches(branches_to_remove, type_, list_flag):
if len(branches_to_remove) and list_flag:
print(str(len(branches_to_remove)) + " " + type_ + " branches to be removed:\n- " +
'\n- '.join(branches_to_remove))
elif not list_flag and len(branches_to_remove):
print(str(len(branches_to_remove)) + " " + type_ + " branches removing:\n- " +
'\n- '.join(branches_to_remove))
else:
print("Your repository is clean. No branch to remove :)")

Expand All @@ -98,15 +101,15 @@ def view_and_delete_branches(list_flag, branch_name, prefix, suffix, remote_flag
time_to_remove, remote_flag)
if DEBUG:
logger.debug("Viewing remote %s delete flag %s", branches_to_remove, not list_flag)
_print_branches(branches_to_remove, "remote")
_print_branches(branches_to_remove, "remote", list_flag)
if not list_flag:
delete_remote_merged_branches(branches_to_remove)
if local_flag:
branches_to_remove = filter_time(
filter_suffix(filter_prefix(get_merged_branches(branch_name), prefix), suffix), time_to_remove, remote_flag)
if DEBUG:
logger.debug("Viewing local branches %s delete flag %s", branches_to_remove, not list_flag)
_print_branches(branches_to_remove, "local")
_print_branches(branches_to_remove, "local", list_flag)
if not list_flag:
delete_local_merged_branches(branches_to_remove)

Expand Down

0 comments on commit 933a9b7

Please sign in to comment.