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

Correct to start_string consistently #301

Merged
merged 10 commits into from
Dec 20, 2020
Merged

Conversation

altendky
Copy link
Member

Fixes #277.

@codecov-io
Copy link

codecov-io commented Dec 14, 2020

Codecov Report

Merging #301 (fe295f6) into master (46c3157) will increase coverage by 0.10%.
The diff coverage is 97.36%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #301      +/-   ##
==========================================
+ Coverage   96.15%   96.25%   +0.10%     
==========================================
  Files          20       20              
  Lines        1117     1148      +31     
  Branches      104      105       +1     
==========================================
+ Hits         1074     1105      +31     
  Misses         24       24              
  Partials       19       19              
Impacted Files Coverage Δ
src/towncrier/_settings.py 95.94% <ø> (ø)
src/towncrier/_writer.py 88.46% <85.71%> (+0.46%) ⬆️
src/towncrier/build.py 95.94% <100.00%> (ø)
src/towncrier/test/test_build.py 100.00% <100.00%> (ø)
src/towncrier/test/test_write.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 46c3157...fe295f6. Read the comment docs.

@altendky

This comment has been minimized.

@altendky altendky requested a review from adiroiban December 20, 2020 00:57
Copy link
Member

@adiroiban adiroiban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.
Only minor comments.

If we are doing the rename, my suggestion is to rename it to "start_marker" as I think it's a better name.

The start_string name tells us that it's the start of something and that the type is string.
I don't think that we need to include the type name in the configuration value name.


def test_start_string(self):
"""
Rendered content added after specified start string.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Rendered content added after specified start string.
The `start_string` configuration is used to detect the starting point for inserting the generated release notes.
A newline is automatically added to the configured value.

with open("pyproject.toml", "w") as f:
f.write(dedent("""\
[tool.towncrier]
start_string="a different start line"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
start_string="a different start line"
start_string="Release notes start marker"


def test_multiple_file_no_start_string(self):
"""
Multiple file output with no start string works.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe move this to test_build to have better coverage / end to end testing.

Suggested change
Multiple file output with no start string works.
When no `start_string` is defined, the generated content is added at the start of the file.

Comment on lines +688 to +689
with open("newsfragments/123.feature", "w") as f:
f.write("Adds levitation")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this pattern many times

I think it can be extracted into a helper ... and the helper can also auto call os.mkdir if not already exists.

Suggested change
with open("newsfragments/123.feature", "w") as f:
f.write("Adds levitation")
self.createFragment('123.feature', "Adds levitation")

README.rst Outdated
@@ -137,7 +137,7 @@ Towncrier has the following global options, which can be specified in the toml f
version = "1.2.3" # project version if maintained separately
name = "arbitrary project name"
template = "path/to/template.rst"
start_line = "start of generated content"
start_string = "start of generated content"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a better name and documentation

Suggested change
start_string = "start of generated content"
start_marker = "Text used to detect where to add the generated content in the middle of a file. Generated content added after this text. Newline auto added."

src/towncrier/newsfragments/277.doc.rst Outdated Show resolved Hide resolved
@altendky
Copy link
Member Author

If we are doing the rename, my suggestion is to rename it to "start_marker" as I think it's a better name.

The actual name read out of the configuration file is not being changed in this PR. The docs are being corrected and the code is being changed to match. I agree with the sentiment that the name isn't great but wasn't shooting for breaking changes here. If you agree with this path I'll skip those comments and address the rest.

Comment on lines +43 to +46
if existing_content:
if existing_content[0]:
f.write(b"\n\n")
f.write(existing_content[0].lstrip().encode("utf8"))

This comment was marked as outdated.

@@ -24,7 +24,7 @@ def append_to_newsfile(
else:
with io.open(news_file, "r", encoding="utf8") as f:
existing_content = f.read()
existing_content = existing_content.split(start_line, 1)
existing_content = existing_content.split(start_string, 1)
else:
existing_content = [u""]

This comment was marked as outdated.

This comment was marked as outdated.

@adiroiban
Copy link
Member

I agree with the sentiment that the name isn't great but wasn't shooting for breaking changes here. If you agree with this path I'll skip those comments and address the rest.

Yes. This can be merged with the current name (via the approved action) :) Thanks!

@altendky altendky merged commit 82a092b into twisted:master Dec 20, 2020
@altendky altendky deleted the start_string branch December 20, 2020 21:23
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 this pull request may close these issues.

start_string vs start_line
3 participants