-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
formulary: handle @ formulae. #812
Conversation
@@ -86,7 +86,7 @@ def search | |||
metacharacters = %w[\\ | ( ) [ ] { } ^ $ * + ? .] | |||
bad_regex = metacharacters.any? do |char| | |||
ARGV.any? do |arg| | |||
arg.include?(char) && !arg.start_with?("/") | |||
arg.include?(char) && !arg.start_with?("/") && !arg.include?("@") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open to opinions on whether this is sane. It might be a bit broad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what the intent is here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah because of the .
? Could consider just removing that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it interprets the .
in something like [email protected]
as a failed desire to regex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree that .
without a modifier isn't a strong regex signal; the current version makes sense 👍
@@ -57,6 +57,7 @@ def self.class_s(name) | |||
class_name = name.capitalize | |||
class_name.gsub!(/[-_.\s]([a-zA-Z0-9])/) { $1.upcase } | |||
class_name.tr!("+", "x") | |||
class_name.gsub!(/\b[@]\b/, "AT") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think you need the []
. Also, maybe can go for /.@\d
to enforce a digit (for now at least, we can tweak it later). After that 👍 to shipping this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/.@\d
matches l@1
in this case, which produces things like:
Expected to find class OpenssAT1, but only found: OpensslAT11.
I'm not sure how to shake that off in the context of gsub
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capture parts of the matched text and use them in the replacement:
"[email protected]".gsub!(/(.)@(\d)/, "\\1AT\\2")
(And a sub!
should be sufficient since we don't expect to have multiple @
in a formula name for now.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Pushed in the #832 PR.
Before this change: ``` ~> brew search [email protected] [email protected] ✔ ==> Did you mean to perform a regular expression search? ==> Surround your query with /slashes/ to search by regex. ```
Will merge this as-is for now, with the redundant |
Use lookahead/lookbehind?
|
Changed in #832 to |
brew tests
with your changes locally?Useful for #620 & Homebrew/homebrew-core#971.