Skip to content

Commit

Permalink
ENH: Allow --no option for towncrier
Browse files Browse the repository at this point in the history
This allows to not delete files, which can be useful when
creating release note documents during a CI step, e.g. for
non-final documentation.

The `--yes` and `--no` options given both lead to `--no` right now,
although that seems not like a big issue.
  • Loading branch information
seberg committed Aug 6, 2019
1 parent 2c1fea2 commit 7414d09
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/towncrier/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,17 @@ def _get_date():
@click.option(
"--yes",
"answer_yes",
default=False,
default=None,
flag_value=True,
help="Do not ask for confirmation to remove news fragments.",
)
@click.option(
"--no",
"answer_yes",
default=None,
flag_value=False,
help="Do not remove news fragments and do not ask whether or not to remove.",
)
def _main(draft, directory, project_name, project_version, project_date, answer_yes):
return __main(
draft, directory, project_name, project_version, project_date, answer_yes
Expand Down
11 changes: 8 additions & 3 deletions src/towncrier/_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@ def remove_files(fragment_filenames, answer_yes):
if not fragment_filenames:
return

if answer_yes:
if answer_yes is None:
click.echo("I want to remove the following files:")
elif answer_yes:
click.echo("Removing the following files:")
else:
click.echo("I want to remove the following files:")
click.echo("Keeping the following files:")

for filename in fragment_filenames:
click.echo(filename)

if answer_yes or click.confirm("Is it okay if I remove those files?", default=True):
if answer_yes is None:
answer_yes = click.confirm("Is it okay if I remove those files?", default=True)

if answer_yes:
call(["git", "rm", "--quiet"] + fragment_filenames)


Expand Down

0 comments on commit 7414d09

Please sign in to comment.