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

Make check subcommand detect if only configured news file has changed #174

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/towncrier/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,15 @@ def __main(comparewith, directory, config):
try:
files_changed = (
_run(
["git", "diff", "--name-only", comparewith + "..."], cwd=base_directory
["git",
"diff",
"--name-only",
# Only show files that were Added (A), Copied (C), Modified (M)
# or Renamed (R).
"--diff-filter=ACMR",
comparewith + "..."
],
cwd=base_directory
)
.decode(getattr(sys.stdout, "encoding", "utf8"))
.strip()
Expand All @@ -48,10 +56,14 @@ def __main(comparewith, directory, config):
click.echo("On trunk, or no diffs, so no newsfragment required.")
sys.exit(0)

if files_changed == config["filename"]:
click.echo("Only the configured news file has changed.")
sys.exit(0)

files = set(
map(
lambda x: os.path.join(base_directory, x),
files_changed.strip().split(os.linesep),
files_changed.split(os.linesep),
)
)

Expand Down
6 changes: 6 additions & 0 deletions src/towncrier/newsfragments/174.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Make the ``check`` subcommand detect if only the configured news file has
changed.

This should enable the ``check`` subcommand to be used as a CI lint step and
not fail when a pull request only modifies the configured news file (i.e. when
the news file is being assembled for the next release).