From 4fcf818b58d2ad9a9b09ba6e03f259068c9b95b9 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 17 Jun 2026 16:17:11 -0700 Subject: [PATCH] Fix handling of backticks in proposal names. (#7383) Use slugify, as it properly handles all proposal names. This also makes our branch name consistent with the file name of the proposal. --- proposals/scripts/new_proposal.py | 3 +-- proposals/scripts/new_proposal_test.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/proposals/scripts/new_proposal.py b/proposals/scripts/new_proposal.py index f582bd344725..e5cd5e5dd143 100755 --- a/proposals/scripts/new_proposal.py +++ b/proposals/scripts/new_proposal.py @@ -93,8 +93,7 @@ def _calculate_branch(parsed_args: argparse.Namespace) -> str: if parsed_args.branch: assert isinstance(parsed_args.branch, str) return parsed_args.branch - # Only use the first 20 chars of the title for branch names. - return "proposal-%s" % (parsed_args.title.lower().replace(" ", "-")[0:20]) + return "proposal-%s" % slugify(parsed_args.title) def _find_tool(tool: str) -> str: diff --git a/proposals/scripts/new_proposal_test.py b/proposals/scripts/new_proposal_test.py index ff3e482853c6..16670fc6026e 100644 --- a/proposals/scripts/new_proposal_test.py +++ b/proposals/scripts/new_proposal_test.py @@ -27,7 +27,16 @@ class TestNewProposal(unittest.TestCase): ) self.assertEqual( new_proposal._calculate_branch(parsed_args), - "proposal-a-really-long-long-l", + "proposal-a-really-long-long-long-title", + ) + + def test_calculate_branch_special(self): + parsed_args = new_proposal._parse_args( + ["A title with #*%$ special `char`s"] + ) + self.assertEqual( + new_proposal._calculate_branch(parsed_args), + "proposal-a-title-with-special-char-s", ) def test_calculate_branch_flag(self):