twisted / towncrier

Manage the release notes for your project.

Home Page:https://towncrier.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

_git.py:remove_files does not react to git's fatal error if newsfragment is untracked by git

fleetingbytes opened this issue · comments

I created some news fragments for towncrier to build me my new changelog and after that I inteded to commit the changes to the git repo. So the news fragments themselves were not tracked by git at the time of the changelog generation. When towncrier asked if it is ok to remove the news fragments I said yes and this was the result:

Is it okay if I remove those files? [Y/n]: y
fatal: pathspec '<REDACTED_PATH>\changelog.d\11.improved.md' did not match any files

This error should be expected and handled here

    if answer_yes or click.confirm("Is it okay if I remove those files?", default=True):
        call(["git", "rm", "--quiet"] + fragment_filenames)

it could look something like this:

    if answer_yes or click.confirm("Is it okay if I remove those files?", default=True):
        try:
            subprocess.run(["git", "rm", "--quiet"] + fragment_filenames, check=True)
        except subprocess.CalledProcessError as err:
            ... # handle git's errors here