Skip to content

Commit

Permalink
Reflect expectation that a non-existent directory is honored and trea…
Browse files Browse the repository at this point in the history
…ted like an empty directory. Closes #538.
  • Loading branch information
jaraco committed Oct 24, 2023
1 parent 7494cb4 commit 857df10
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
5 changes: 3 additions & 2 deletions docs/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ The following options can be passed to all of the commands that explained below:
Build the combined news file from news fragments.
``build`` is also assumed if no command is passed.

If there are no news fragments (including an empty fragments directory), a
notice of "no significant changes" will be added to the news file.
If there are no news fragments (including an empty fragments directory or a
non-existent directory), a notice of "no significant changes" will be added to
the news file.

By default, the processed news fragments are removed using ``git``, which will
also remove the fragments directory if now empty.
Expand Down
10 changes: 2 additions & 8 deletions src/towncrier/_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@

import os
import textwrap
import traceback

from collections import defaultdict
from typing import Any, DefaultDict, Iterable, Iterator, Mapping, Sequence

from jinja2 import Template

from ._settings import ConfigError


def strip_if_integer_string(s: str) -> str:
try:
Expand Down Expand Up @@ -102,11 +99,8 @@ def find_fragments(

try:
files = os.listdir(section_dir)
except FileNotFoundError as e:
message = "Failed to list the news fragment files.\n{}".format(
"".join(traceback.format_exception_only(type(e), e)),
)
raise ConfigError(message)
except FileNotFoundError:
files = []

file_content = {}

Expand Down
4 changes: 2 additions & 2 deletions src/towncrier/test/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ def test_no_newsfragment_directory(self, runner):

result = runner.invoke(_main, ["--draft", "--date", "01-01-2001"])

self.assertEqual(1, result.exit_code, result.output)
self.assertIn("Failed to list the news fragment files.\n", result.output)
self.assertEqual(0, result.exit_code)
self.assertIn("No significant changes.\n", result.output)

def test_no_newsfragments_draft(self):
"""
Expand Down

0 comments on commit 857df10

Please sign in to comment.