From 345ffe75a0254913e008c9be4f5240081e5addbf Mon Sep 17 00:00:00 2001 From: Sara Date: Wed, 16 Oct 2024 11:54:32 +1100 Subject: [PATCH] Simplify string normalisation Co-authored-by: Russell Keith-Magee --- src/briefcase/commands/base.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/briefcase/commands/base.py b/src/briefcase/commands/base.py index fe75d8fec..a6a34c484 100644 --- a/src/briefcase/commands/base.py +++ b/src/briefcase/commands/base.py @@ -981,15 +981,12 @@ def update_cookiecutter_cache(self, template: str, branch="master"): git_fatal_message = re.findall(r"(?<=fatal: ).*?$", e.stderr, re.S) if git_fatal_message: # GitError captures stderr with single quotes. Because the regex above - # takes everything after git's "fatal" message, we need to strip that final single quote - hint = git_fatal_message[0].rstrip("'") + # takes everything after git's "fatal" message, we need to strip that final single quote. + hint = git_fatal_message[0].rstrip("'").strip() # git is inconsistent with capitalisation of the first word of the message - # and about periods at the end of the message. Normalise those here to ensure - # a clean and uniform presentation - # Also strip the string of any trailing whitespace before applying the period fix. - hint = f"{hint[0].upper()}{hint[1:]}".strip() - hint += "." if hint[-1] != "." else "" + # and about periods at the end of the message. + hint = f"{hint.capitalize()}{'' if hint[-1] == '.' else '.'}" else: hint = ( "This may be because your computer is offline, or "