homebrew-core icon indicating copy to clipboard operation
homebrew-core copied to clipboard

formulae: use `generate_completions`

Open max-ae opened this issue 1 year ago • 2 comments

  • [x] Have you followed the guidelines for contributing?
  • [x] Have you ensured that your commits follow the commit style guide?
  • [x] Have you checked that there aren't other open pull requests for the same formula update/change?
  • [ ] Have you built your formula locally with brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • [ ] Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • [ ] Does your build pass brew audit --strict <formula> (after doing brew install --build-from-source <formula>)? If this is a new formula, does it pass brew audit --new <formula>?

needs https://github.com/Homebrew/brew/pull/13536

cc @MikeMcQuaid

As requested in https://github.com/Homebrew/brew/pull/13536, here is a sample PR to showcase the use of the new generate_completions DSL.

This PR does not contain all formulae that would benefit from this, but only those that could be autocorrected by the RuboCop from https://github.com/Homebrew/brew/pull/13553 (with manual modifications to merge autodetected shells, since the Cop is not yet able to do that). This means that this PR only contains formulae previously using the following pattern

(bash_completion/"foo").write Utils.safe_popen_read(bin/"foo", "completions", "bash")

Once the RuboCop is finalized, I will update this PR to also include formulae using something along the lines of

output = Utils.safe_popen_read(bin/"foo", "completion", "bash")
(bash_completion/"foo").write output

But in the meantime, I think these selected formulae showcase the new DSL quite well 😄

max-ae avatar Jul 13 '22 13:07 max-ae

I have updated the previously changed formulae with the updated DSL and RuboCop. As soon as both are finalized, I will work on also adding all non autocorrectable formulae to this PR too.

max-ae avatar Jul 27 '22 15:07 max-ae

This branch now contains all formulae that can benefit from the new syntax 😄 The only exceptions I encountered were hatch, awscli and pipenv, otherwise no formula needs to use the (bash_completion/"foo).write syntax anymore 🎉

max-ae avatar Aug 11 '22 16:08 max-ae

For this to pass CI, this will need either a long-timeout or syntax-only label 😄 (@Rylan12)

max-ae avatar Aug 18 '22 18:08 max-ae

Cool, looks like this is good to go once https://github.com/Homebrew/brew/pull/13536 is in a tagged release!

max-ae avatar Aug 18 '22 21:08 max-ae

This can be merged now that 3.5.10 is out, no? 😃 (@Rylan12)

max-ae avatar Aug 26 '22 19:08 max-ae

This can be merged now that 3.5.10 is out, no? 😃 (@Rylan12)

Yep! Other maintainers can feel free to review and merge. I probably won't be able to take a look for a bit but will get to it in the next few days if no one else does first.

Rylan12 avatar Aug 26 '22 23:08 Rylan12

I went over all changed formulae again and, as suggested, changed custom shell_parameter_format args to extended commands, where applicable.

max-ae avatar Aug 29 '22 14:08 max-ae

Here's my final set of comments. Everything else looks good 👍

Great! Thank you so much again for assisting in the whole process! 😄

max-ae avatar Sep 02 '22 11:09 max-ae

:robot: A scheduled task has triggered a merge.

BrewTestBot avatar Sep 03 '22 00:09 BrewTestBot