commands: explain change in command description splitting

A comment here would help the reader to understand the need for this
splitting logic, which is not so straightforward.

Addresses review comment in
https://github.com/Homebrew/brew/pull/15146#discussion_r1157361656.

Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com>
This commit is contained in:
Ruoyu Zhong 2023-04-04 22:50:40 +08:00
parent 0048a86673
commit 4305443c9c
No known key found for this signature in database
GPG Key ID: 42F3B7E577C2156A

View File

@ -203,6 +203,10 @@ module Commands
if (cmd_parser = Homebrew::CLI::Parser.from_cmd_path(path))
if short
# We only consider a dot as a full stop if it is either followed by a
# whitespace or at the end of the description. In this way we can
# prevent cutting off a sentence in the middle due to dots in URLs or
# paths.
cmd_parser.description.split(/\.(?>\s|$)/).first
else
cmd_parser.description