-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add --describe
arg to brew add
#14
Add --describe
arg to brew add
#14
Conversation
Thank you for developing this feature! I would love to add this to
Thanks again for this PR! |
Absolutely, this contribution can be licensed under both MIT and BSD-2-Clause. No concerns there, but thanks for checking.
This makes sense and wasn't something I considered at first. I think I have a basic implementation working without too much hassle, so I'll go ahead and push it — but if you'd like to have something more robust in place then I'm happy to defer to your implementation as well. Thanks for taking the time to look at this! |
614faa4
to
0a9f3f6
Compare
Thank you! I have a few ideas for how to remove the description that I would like to try myself. A potential problem with your current implementation is that it breaks if the formula description itself is ever changed (or if the user modifies the comment, like you've described). My current idea that I'm planning to implement is for it to remove all comments that come directly before the line until it hits a line that contains either whitespace or a non-comment line (so dropwhile I'll get around to implementing this soon. |
Fair enough, it was a pretty naive attempt and I was guessing you had planned something a little more robust like you describe. Would you prefer I undo the changes I made to try and merge |
I think it's probably best to implement both together. |
0a9f3f6
to
86cbda6
Compare
I've made some changes to the code and implemented the logic for |
File.foreach(brewfile) do |line| | ||
unless line.match(/^\s*#{brewfile_prefix_type}\s+["'](#{regex_name})["']/) | ||
lines.push(line) | ||
if line.match(/^\s*# (?!brew|cask|tap|mas|whalebrew|vscode)\w/) |
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.
Just curious, why bother with this ?!
match here? To avoid capturing places where someone commented out a line like # brew "foo"
?
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.
Yes, that's the goal. It's a pretty ugly hack but I think it'll address the most common cases where a comment would otherwise incorrectly be removed.
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.
LGTM! Not sure about exactly what cases you want to cover with drop
but the logic as written seems like it would cover what was added by --describe
.
Hi, I hope it's okay I didn't file an issue before implementing this! It was pretty simple to write, so I thought I'd just go ahead and open a PR.
This adds a
--describe
to insert a comment line with a description whenbrew add
ing a cask/formula. It also respects the existingHOMEBREW_BUNDLE_DUMP_DESCRIBE
environment variable that has the same effect forbrew bundle dump
.