Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow wildcards in "ignore" configuration option #642

Closed
eigenbrot opened this issue Aug 1, 2024 · 4 comments · Fixed by #644
Closed

Allow wildcards in "ignore" configuration option #642

eigenbrot opened this issue Aug 1, 2024 · 4 comments · Fixed by #644

Comments

@eigenbrot
Copy link
Contributor

Since version 24.7.0 (and PR #622) there is an "ignore" configuration option that allows users to specify files that are known to have "wrong" filenames but still belong in the fragments directory.

It would be very helpful if this "ignore" option supported wildcards in filenames. For example:

[tool.towncrier]
    ignore = [".gitempty", "useful_file_num*.ext"]

Thanks!

@adiroiban
Copy link
Member

Hi Arthur

Thanks for the report.

Can you please add more information about your feature request.

What other files belong to the newsfragment directory ?


I am happy to review and approve a PR that implementes simple glob expressions.

@eigenbrot
Copy link
Contributor Author

Hi @adiroiban, thanks for the quick response.

In our use case we maintain two separate changelogs files for two different audiences; one that captures change to the codebase itself and one that reports on any scientific changes to the output of that code. We do this by maintaining two configuration TOML files that build the two changelogs, each with their own fragment types. We keep all of our fragments in the same "changelog" directory and so when running towncrier check for one changelog it now complains about the fragments from the other changelog.

As I'm writing that I'm realizing that we could also sidestep this issue by having two separate fragment directories, but that feels a bit more cumbersome than setting the ignore option to include "*.other_changelog_fragment_name.rst". I also suspect that someone else will want wildcards at some point for a different reason.

@adiroiban
Copy link
Member

The changes in towncrier check were design to detect non-fragment files from being created in the news fragment directory.

I would say that using 2 separate news fragment directories is the best way here.


To implement globbing the changes needs to go here

for basename in files:
if basename.lower() in ignored_files:
continue

Instead of doing a simple string comparision, we should use https://docs.python.org/3/library/fnmatch.html#fnmatch.fnmatch for each member of the ignore list


If you have time, please consider creating a PR and I would be happy to review.

Thanks

@eigenbrot
Copy link
Contributor Author

@adiroiban, thanks for pointing me in the right direction! PR #644 should be ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants