Skip to content

Commit

Permalink
Simplify string normalisation
Browse files Browse the repository at this point in the history
Co-authored-by: Russell Keith-Magee <[email protected]>
  • Loading branch information
sarayourfriend and freakboy3742 authored Oct 16, 2024
1 parent bf02180 commit 345ffe7
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/briefcase/commands/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down

0 comments on commit 345ffe7

Please sign in to comment.