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

add an option to check staged files #677

Merged
merged 6 commits into from
Dec 5, 2024
Merged

Conversation

krpatter-intc
Copy link
Contributor

@krpatter-intc krpatter-intc commented Dec 4, 2024

Description

Implements #676

Adds new --staged parameter to the check command so that staged files are included as part of the check.

Checklist

  • Make sure changes are covered by existing or new tests.
  • For at least one Python version, make sure test pass on your local environment.
  • Create a file in src/towncrier/newsfragments/. Briefly describe your
    changes, with information useful to end users. Your change will be included in the public release notes.
  • Make sure all GitHub Actions checks are green (they are automatically checking all of the above).
  • Ensure docs/tutorial.rst is still up-to-date. N/A
  • If you add new CLI arguments (or change the meaning of existing ones), make sure docs/cli.rst reflects those changes.
  • If you add new configuration options (or change the meaning of existing ones), make sure docs/configuration.rst reflects those changes. N/A

@krpatter-intc krpatter-intc marked this pull request as ready for review December 4, 2024 00:44
@krpatter-intc krpatter-intc requested a review from a team as a code owner December 4, 2024 00:44
@krpatter-intc
Copy link
Contributor Author

FYI: @adiroiban

Copy link
Contributor

@twm twm left a comment

Choose a reason for hiding this comment

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

Hi @krpatter-intc, thank you for the contribution!

Overall this looks good, but I had some (admittedly fairly pedantic) feedback to address before we can merge.

Thanks again!

There must be uncommitted changes otherwise git will complain:
"nothing to commit, working tree clean"
"""
call(["git", "add", "."])
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this check the exit status?

I suppose the same applies to all the other helper functions here. You needn't fix those, but it would be appreciated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, switched all call commands to check_call so an exception is thrown if a call fails

5b5c8ca

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for this!

@@ -204,6 +213,44 @@ def test_fragment_exists_but_not_in_check(self):
(result.output, str(fragment_path)),
)

def test_fragment_exists_and_staged(self):
"""A fragment that exists but is marked as check=False is ignored by the check."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update this test docstring to mention staging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in 363532a

docs/cli.rst Outdated Show resolved Hide resolved
"staged",
is_flag=True,
default=False,
metavar="STAGED",
Copy link
Contributor

Choose a reason for hiding this comment

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

Does metavar do anything when it's a flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good point. removed in: de88e69

src/towncrier/check.py Outdated Show resolved Hide resolved
src/towncrier/newsfragments/676.feature.rst Outdated Show resolved Hide resolved
Comment on lines 228 to 232
"[[tool.towncrier.type]]\n"
'directory = "sut"\n'
'name = "System Under Test"\n'
"showcontent = true\n"
"check=false\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you could shorten this test by omitting this check=False stuff (and staging the .sut file below).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed in 363532a

@krpatter-intc krpatter-intc requested a review from twm December 4, 2024 13:47
Copy link
Contributor

@twm twm left a comment

Choose a reason for hiding this comment

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

Thanks for the quick turn-around @krpatter-intc. This looks great to me!

@twm twm merged commit f338f7b into twisted:trunk Dec 5, 2024
16 checks passed
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.

2 participants