-
Notifications
You must be signed in to change notification settings - Fork 123
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 #296
Changes from all commits
fda2c9e
d33ba70
ad2e3ea
27983ec
c227ce9
a0db430
a980b0a
cc986c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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). |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,6 +3,7 @@ | |||||
|
||||||
import os | ||||||
import sys | ||||||
from textwrap import dedent | ||||||
|
||||||
from twisted.trial.unittest import TestCase | ||||||
from click.testing import CliRunner | ||||||
|
@@ -13,7 +14,11 @@ | |||||
|
||||||
def create_project(pyproject_path): | ||||||
with open(pyproject_path, "w") as f: | ||||||
f.write("[tool.towncrier]\n" 'package = "foo"\n') | ||||||
f.write(dedent("""\ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that we should disable the linter warning for this type of indentation... and maybe just use black :) I feel that dedent here has no technical merit, and is just added to please a tool :) |
||||||
[tool.towncrier] | ||||||
package = "foo" | ||||||
filename = "NEWS.rst" | ||||||
""")) | ||||||
os.mkdir("foo") | ||||||
with open("foo/__init__.py", "w") as f: | ||||||
f.write('__version__ = "1.2.3"\n') | ||||||
|
@@ -22,6 +27,9 @@ def create_project(pyproject_path): | |||||
with open(fragment_path, "w") as f: | ||||||
f.write("Adds levitation") | ||||||
|
||||||
with open("NEWS.rst", "w") as f: | ||||||
f.write("added on default branch") | ||||||
|
||||||
call(["git", "init"]) | ||||||
call(["git", "config", "user.name", "user"]) | ||||||
call(["git", "config", "user.email", "user@example.com"]) | ||||||
|
@@ -148,3 +156,24 @@ def test_none_stdout_encoding_works(self): | |||||
|
||||||
self.assertEqual(0, proc.returncode) | ||||||
self.assertEqual(b"", stderr) | ||||||
|
||||||
def test_newsfile_modified(self): | ||||||
""" | ||||||
A modified newsfile satisfies the check. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
""" | ||||||
runner = CliRunner() | ||||||
|
||||||
with runner.isolated_filesystem(): | ||||||
create_project("pyproject.toml") | ||||||
|
||||||
newsfile_path = "NEWS.rst" | ||||||
|
||||||
with open(newsfile_path, "w") as f: | ||||||
f.write("on other branch") | ||||||
call(["git", "add", newsfile_path]) | ||||||
call(["git", "commit", "-m", "modify NEWS.rst"]) | ||||||
|
||||||
result = runner.invoke(_main, ["--compare-with", "master"]) | ||||||
|
||||||
self.assertEqual(result.output, 'Only the configured news file has changed.\n') | ||||||
self.assertEqual(0, result.exit_code) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say add uppercase when skipped, to help detect accidental configuration errors.