| 149 | |
| 150 | |
| 151 | def _do_delete(delete_b, repo): |
| 152 | errors_found = False |
| 153 | |
| 154 | for b_name in delete_b: |
| 155 | try: |
| 156 | b = helpers.get_branch(b_name, repo) |
| 157 | |
| 158 | branch_str = 'Branch {0} will be removed'.format(b.branch_name) |
| 159 | remote_str = '' |
| 160 | if isinstance(b, core.RemoteBranch): |
| 161 | remote_str = ' from remote repository {0}'.format(b.remote_name) |
| 162 | if not pprint.conf_dialog('{0}{1}'.format(branch_str, remote_str)): |
| 163 | pprint.msg('Aborted: removal of branch {0}'.format(b)) |
| 164 | continue |
| 165 | |
| 166 | b.delete() |
| 167 | pprint.ok('Branch {0} removed successfully'.format(b)) |
| 168 | except ValueError as e: |
| 169 | pprint.err(e) |
| 170 | errors_found = True |
| 171 | except core.BranchIsCurrentError as e: |
| 172 | pprint.err(e) |
| 173 | pprint.err_exp( |
| 174 | 'do gl branch b to create or switch to another branch b and then ' |
| 175 | 'gl branch -d {0} to remove branch {0}'.format(b)) |
| 176 | errors_found = True |
| 177 | |
| 178 | return not errors_found |
| 179 | |
| 180 | |
| 181 | def _do_set_upstream(upstream, repo): |