add --local/--no-local option to "clean" command

This commit is contained in:
Benjamin Dauvergne 2022-01-29 08:08:37 +01:00
parent a8a33fcbc7
commit ba755c27dc
1 changed files with 14 additions and 12 deletions

View File

@ -648,7 +648,8 @@ def set(project_id):
@redmine.command()
def clean():
@click.option('--local/--no-local', default=False)
def clean(local):
repo = get_repo()
repo.git.fetch(prune=True)
api = get_redmine_api()
@ -677,18 +678,19 @@ def clean():
issues_to_delete.append((issue.id, issue.subject))
temp_issues_to_branch = temp_issues_to_branch[30:]
for _id, _subject in issues_to_delete:
print('%5s | %60s | %s' % (_id, issues_to_branch[str(_id)][:60], _subject))
if issues_to_delete and click.confirm('Remove theses remote branches ?'):
if not local:
for _id, _subject in issues_to_delete:
ref = issues_to_branch[str(_id)]
click.echo('Deleting origin/%s... ' % ref, nl=False)
try:
origin.push(refspec=':%s' % ref)
except git.GitCommandError as e:
click.echo(click.style('Failed(%s).' % e, fg='red'))
else:
click.echo(click.style('Done.', fg='green'))
print('%5s | %60s | %s' % (_id, issues_to_branch[str(_id)][:60], _subject))
if issues_to_delete and click.confirm('Remove theses remote branches ?'):
for _id, _subject in issues_to_delete:
ref = issues_to_branch[str(_id)]
click.echo('Deleting origin/%s... ' % ref, nl=False)
try:
origin.push(refspec=':%s' % ref)
except git.GitCommandError as e:
click.echo(click.style('Failed(%s).' % e, fg='red'))
else:
click.echo(click.style('Done.', fg='green'))
issues_to_branch = {}
for ref in repo.branches: