-
Notifications
You must be signed in to change notification settings - Fork 122
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
Fix orphan fragments with numbers #564
Conversation
We can discuss the changes here. The test changes looks great. It should be enought to update the existing tests. No need for a new tests... a new test would be nice... but the current one is also ok. I see the updated tests failing. THat's excellent.
|
@@ -17,6 +17,8 @@ | |||
.vs/ | |||
.vscode | |||
Justfile | |||
*egg-info/ |
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 guess we can have this. I have this rule in my global gitignore file
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.
good call.
Also this is a python project, so i'd expect that directory to exist eventually.
dc6cede
to
6dae5de
Compare
@@ -70,9 +78,13 @@ def _test_command(self, command): | |||
-------- | |||
|
|||
- Baz levitation (baz) | |||
- Baz fix levitation (#2) | |||
- Baz fix levitation (fix-1.2) |
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'm not so sure about this one. But i'd argue, that is what was actually meant by:
https://github.com/twisted/towncrier/pull/564/files#diff-36db088409efe07783d49792a18cec6ae3778ace338bf1cd08daa8a3fce29e93R45-R47
# NOTE: This allows news fragment names like fix-1.2.3.feature or
# something-cool.feature.ext for projects that don't use ticket
# numbers in news fragment names.
@@ -70,9 +78,13 @@ def _test_command(self, command): | |||
-------- | |||
|
|||
- Baz levitation (baz) | |||
- Baz fix levitation (#2) | |||
- Baz fix levitation (fix-1.2) |
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 think that this need a better comment.
I don't really understant what is the use case here.
This is the bad part of bundling all kind of scenarios in a single test case.
# Towncrier supports files that have a dot in the name of the
# newsfragment
with open("foo/newsfragments/fix-1.2.feature", "w") as f:
f.write("Baz fix levitation")
since it has no orphan marker, I would consider it an error, and the file should be rejected.
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.
As per my comment above, I think this snippet was parsed wrongly. But I cannot find anything in the docs about it the only reference is the comment (_builder.py):
# NOTE: This allows news fragment names like fix-1.2.3.feature or
# something-cool.feature.ext for projects that don't use ticket
# numbers in news fragment names.
And I do not think that in that case "3" was meant to be an issue number.
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.
Also I read the comment you cited as the "name of the newsfragment" being fix-1.2
.
@@ -405,6 +417,7 @@ def test_draft_no_date(self): | |||
call(["git", "init"]) | |||
call(["git", "config", "user.name", "user"]) | |||
call(["git", "config", "user.email", "user@example.com"]) | |||
call(["git", "config", "commit.gpgSign", "false"]) |
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.
We might need to refactor this code into an helper function that does the git init for us.
I expect that this is needed in other tests.
We can leave this as it is for now.
There are numerous bad practices in the towncrier tests.
It would be nice to have them fix, but it should not be a burder for new contributors.
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.
How about this?
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.
Thanks for the PR.
I did a review now as I had some time.
This needs changes due to test_dots_in_ticket_name
This change introduces a regression.
If we decide that test_dots_in_ticket_name
was a bug, we need to add a .removal
news fragment for this PR to let others know that this use case is no longer supported and that it was removed.
But, it looks like test_dots_in_ticket_name
is indeed a feature... it's just that it was not documented.
So we need to decide if we want to keep the undocumented feature, add documentation for it, or plan to remove this feature.
I hope that we can keep this feature.
6dae5de
to
132c8a3
Compare
src/towncrier/test/test_builder.py
Outdated
@@ -8,63 +8,73 @@ | |||
|
|||
class TestParseNewsfragmentBasename(TestCase): | |||
def test_simple(self): | |||
"""Plain <number>.<category> should be valid with counter=0.""" |
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.
We can leave these comments.
Just a note, if you have time to make them better
I recommend this read ... is not log https://jml.io/test-docstrings/
Maybe
"""Plain <number>.<category> should be valid with counter=0.""" | |
""" | |
<number>.<category> generates a counter value of 0. | |
""" |
src/towncrier/test/helpers.py
Outdated
@@ -69,3 +70,43 @@ def setup_simple_project( | |||
|
|||
if mkdir_newsfragments: | |||
Path("foo/newsfragments").mkdir() | |||
|
|||
|
|||
def with_isolated_simple_project( |
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.
Thanks for the refactoring.
I know that we already have setup_simple_project
The test decorators are all about isolation.
And not sure if "simple" has value.
Do we also have "with_isolated_complex_project" ?
def with_isolated_simple_project( | |
def with_project( |
Can we have a docstring for this function?
I think that in the docstring we can have more details about what is considered "simple".
My main goal for the docstring is to describe the intended use cases for each argument.
With that, you can decide if you need to extend this function, or create a new one (that for example is more complex)
src/towncrier/test/test_build.py
Outdated
result = runner.invoke(command, ["--draft", "--date", "01-01-2001"]) | ||
@with_isolated_simple_project() | ||
def _test_command(self, command, runner): | ||
# Off the shelf newsfragment |
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.
What does this comment mean ?
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 consider this the archetype of a newsfragment. (One line down; this is not a docstring...) How would you call it?
src/towncrier/test/helpers.py
Outdated
|
||
def with_isolated_simple_project( | ||
*, | ||
with_git=False, |
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 am not a big fan of flag arguments.
I prefer something like @with_project
and @with_git_project
. but we can have this like this, as long as the intended usage of with_git
is documented.
src/towncrier/test/helpers.py
Outdated
def with_isolated_simple_project( | ||
*, | ||
with_git=False, | ||
config: str | None = None, |
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.
maybe config can be dedented by default, so that we don't have to always call dedent.
By forcing the usage of dedent, it should make the tests easier to read.
We no longer have to do list concatenation
src/towncrier/test/helpers.py
Outdated
*, | ||
with_git=False, | ||
config: str | None = None, | ||
extra_config: str = "", |
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.
Just a comment. Not sure if it make sense to keep this.
I find it easier to read a test, if it has the full configuration.
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.
Changes look very good. Many thanks.
I think that the only major comment is the missing release note for the fix.1.2.3.bugfix
change.
We should add a note about this in the relese note, so that people who were accidentally relying on this bug, should know about it and switch to orphan marker.
The others are just minor comments. Nothing to block the merge.
Thanks again!
I'm going to separate the test rewrite into a different PR for easier review. |
That would be awesome. Much appreciated. |
774f6cf
to
1a27fa3
Compare
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.
Looks good. Thanks.
I am not sure we have a removal here.
I think there are just 2 bugfixes.
fixes twisted#562 Co-authored-by: Adi Roiban <adiroiban@gmail.com>
61cb027
to
16975ed
Compare
I believe i updated the fragments as you wanted (tried to fix any typo found...). |
Many thanks. Great work. I have merged it and I will try to get a new release |
Thank you for the quick reviews! |
Description
Fixes #562
Checklist
src/towncrier/newsfragments/
. Describe yourchange and include important information. Your change will be included in the public release notes.
docs/tutorial.rst
is still up-to-date.docs/cli.rst
reflects those changes.docs/configuration.rst
reflects those changes.