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
install tap cmd completions #1708
install tap cmd completions #1708
Conversation
5a12a0b
to
3b5e895
Compare
Library/Homebrew/cmd/list.rb
Outdated
@@ -76,7 +76,8 @@ def list | |||
lib/ruby/gems/[12].* | |||
lib/ruby/site_ruby/[12].* | |||
lib/ruby/vendor_ruby/[12].* | |||
manpages/brew.1 | |||
manpages/man1/brew.1 | |||
manpages/man1/brew-cask.1 |
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.
Are there taps using non-.1
manpages (or wanting to)?
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.
This allows us to handle the man pages just as a generic nested folder for install / uninstall rather than specifically handling the man case. I'd like to leave this like this for simplicity. It makes it obvious where a non.1 case would belong (arguablely brew should be .8)
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.
Do we have any non-.1
cases currently, though? If not, I'd rather leave as-is (or at least make that another PR).
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.
@joshka Ping on this, let's leave it as-is for now, please and save moving these around to another PR.
@@ -302,16 +302,11 @@ def migrate_legacy_repository_if_necessary | |||
$stderr.puts e.backtrace | |||
end | |||
|
|||
def link_completions_and_docs(repository = HOMEBREW_REPOSITORY) | |||
def link_additional_files(repository = HOMEBREW_REPOSITORY) |
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.
I think perhaps link_completions_manpages_and_docs
would better signify the intent 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.
But what happens when we add a config file, some other related thing, ...
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.
- YAGNI, 2) we can change the name then.
link_additional_files
doesn't really communicate anything.
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.
@joshka Let's use link_completions_manpages_and_docs
, thanks.
Library/Homebrew/utils.rb
Outdated
end | ||
end | ||
|
||
def install_manpages(path, command) |
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.
Can we keep the naming of these to be (un)link_*
? Also, probably worth splitting these into a new utils/link.rb
or similar file.
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.
I like install because it tells the intent rather than the effect. How this occurs might change without too much hassle, but why it's happening remains the same
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.
Kinda agree on link.rb
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.
Let's leave it as link
but move these to link.rb
👍
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.
Again, let's leave these as link
, thanks.
Nice work here so far. A few comments but looking good 👍 |
Library/Homebrew/cmd/list.rb
Outdated
@@ -76,7 +76,8 @@ def list | |||
lib/ruby/gems/[12].* | |||
lib/ruby/site_ruby/[12].* | |||
lib/ruby/vendor_ruby/[12].* | |||
manpages/brew.1 | |||
manpages/man1/brew.1 | |||
manpages/man1/brew-cask.1 |
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.
@joshka Ping on this, let's leave it as-is for now, please and save moving these around to another PR.
@@ -302,16 +302,11 @@ def migrate_legacy_repository_if_necessary | |||
$stderr.puts e.backtrace | |||
end | |||
|
|||
def link_completions_and_docs(repository = HOMEBREW_REPOSITORY) | |||
def link_additional_files(repository = HOMEBREW_REPOSITORY) |
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.
@joshka Let's use link_completions_manpages_and_docs
, thanks.
Library/Homebrew/utils.rb
Outdated
end | ||
end | ||
|
||
def install_manpages(path, command) |
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.
Again, let's leave these as link
, thanks.
@joshka Ping on the changes/conflicts here, thanks. |
@MikeMcQuaid I had a rather extended Christmas / new year vacation and then moved house and had to put this on the back burner. I'll take a look later today and get it back on track. :) |
@MikeMcQuaid I've fixed up the review comments. I'm happy to rebase / squash / resolve conflicts once you've looked at it. |
e308f29
to
1de4f84
Compare
1de4f84
to
8ea6d37
Compare
I've rebased against master, squashed the WIP commits, and fixed the review item that I missed (the link functions are now in link.rb) |
HOMEBREW_PREFIX/"share/man/man1", command) | ||
link_completions(repository, command) | ||
link_manpages(repository, command) | ||
link_docs(repository, command) |
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.
Given this function is only called from here and only applies to Homebrew/brew I wonder if the indirection here is a little confusing (but have no strong views either way).
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.
I'm not sure that I understand your question. Are you talking about link_completions_manpages_and_docs()
or link_docs() method here?
If it's the former, the method exists to DRY up the same code in the taps.
If it's the latter, the method exists for consistency with the other link_
methods.
Or perhaps you're suggesting to inline the calls to link_*
at the call sites? I'm a fan of smaller methods rather than larger generally, and we need to call Tap.link_completions_and_manpages
externally so I think for consistency this means this stays.
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.
link_docs
, yes. If you feel strongly: I don't so leave as-is.
Library/Homebrew/link.rb
Outdated
@@ -0,0 +1,62 @@ | |||
def link_src_dst_dirs(src_dir, dst_dir, command, link_dir: false) |
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.
This should be in utils/link.rb
and be inside a module Link
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.
Additionally, this method could be private
.
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.
makes sense to me
Library/Homebrew/link.rb
Outdated
end | ||
end | ||
|
||
def link_manpages(path, command) |
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.
I realise I'm changing my mind but could always be link_man1pages
or something similar if you wanted to communicate this only refers to man1
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.
I think it makes enough sense as-is to leave it and only update the implementation if a situation presents that other man sections are needed. Adding manX would likely mean reorganizing a bunch of folders across various repos, so it would be a fairly heavy change that isn't just a matter of adding a new method
Library/Homebrew/link.rb
Outdated
EOS | ||
end | ||
|
||
def unlink_src_dst_dirs(src_dir, dst_dir, unlink_dir: false) |
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.
This method could be private
8ea6d37
to
46fd691
Compare
Addressed module change |
46fd691
to
beedb2b
Compare
Library/Homebrew/utils/link.rb
Outdated
@@ -0,0 +1,68 @@ | |||
module Link |
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.
module Utils
module Link
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.
Cool with me. I wasn't sure about the idiomatic ruby way on this was and the modules under /utils
seemed to follow both approaches.
Final bit of pedantry but otherwise looking good. Once that's addressed I'll give this some testing and get Homebrew/homebrew-services ready to go with it then 🚢. |
Taps can include completion scripts for external commands under `completions/bash`, `completions/fish`, or `completions/zsh`. `brew tap` will automatically install these into the correct directories during install.
beedb2b
to
25396d9
Compare
Done. I note that while this PR adds more tests as an absolute number, the code coverage check on the diff reports that it's not quite enough. I think this is due to a large portion of this diff being a refactor of methods to a new module. |
Thanks for your work and patience here @joshka! |
brew tests
with your changes locally?Taps can include completion scripts for external commands under
completions/bash, completions/fish, or completions/zsh. brew tap
will automatically install these into the correct directories during
install.
See Homebrew/homebrew-services#73 for a concrete need for completions in a repo.
This PR follows on from #1195 but github didn't pick up the extra commits automatically as part of the previous PR (possibly because of my local rebase to pickup changes made later).