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

commands: explain change in command description splitting #15148

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions Library/Homebrew/commands.rb
Expand Up @@ -32,6 +32,11 @@ module Commands
"lc" => "livecheck",
"tc" => "typecheck",
}.freeze
# This pattern is used to split descriptions at full stops. 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.
DESCRIPTION_SPLITTING_PATTERN = /\.(?>\s|$)/.freeze
ZhongRuoyu marked this conversation as resolved.
Show resolved Hide resolved

def valid_internal_cmd?(cmd)
require?(HOMEBREW_CMD_PATH/cmd)
Expand Down Expand Up @@ -203,7 +208,7 @@ def command_description(command, short: false)

if (cmd_parser = Homebrew::CLI::Parser.from_cmd_path(path))
if short
cmd_parser.description.split(/\.(?>\s|$)/).first
cmd_parser.description.split(DESCRIPTION_SPLITTING_PATTERN).first
else
cmd_parser.description
end
Expand All @@ -215,7 +220,7 @@ def command_description(command, short: false)
match_data = /^#: (?<desc>\w.*+)$/.match(line)
if match_data
desc = match_data[:desc]
return T.must(desc).split(".").first if short
return T.must(desc).split(DESCRIPTION_SPLITTING_PATTERN).first if short

return desc
end
Expand Down