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

install tap cmd completions #1708

Merged

Conversation

joshka
Copy link
Contributor

@joshka joshka commented Dec 20, 2016

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run 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).

@joshka joshka force-pushed the feature/install-tap-cmd-completions branch 2 times, most recently from 5a12a0b to 3b5e895 Compare December 21, 2016 11:41
@@ -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
Copy link
Member

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)?

Copy link
Contributor Author

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)

Copy link
Member

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).

Copy link
Member

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)
Copy link
Member

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.

Copy link
Contributor Author

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, ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. YAGNI, 2) we can change the name then. link_additional_files doesn't really communicate anything.

Copy link
Member

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.

end
end

def install_manpages(path, command)
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Member

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 👍

Copy link
Member

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.

@MikeMcQuaid
Copy link
Member

Nice work here so far. A few comments but looking good 👍

@@ -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
Copy link
Member

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)
Copy link
Member

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.

end
end

def install_manpages(path, command)
Copy link
Member

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.

@MikeMcQuaid
Copy link
Member

@joshka Ping on the changes/conflicts here, thanks.

@joshka
Copy link
Contributor Author

joshka commented Feb 15, 2017

@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. :)

@joshka
Copy link
Contributor Author

joshka commented Feb 18, 2017

@MikeMcQuaid I've fixed up the review comments. I'm happy to rebase / squash / resolve conflicts once you've looked at it.

@joshka joshka force-pushed the feature/install-tap-cmd-completions branch from e308f29 to 1de4f84 Compare February 18, 2017 04:24
@joshka joshka force-pushed the feature/install-tap-cmd-completions branch from 1de4f84 to 8ea6d37 Compare February 18, 2017 22:52
@joshka
Copy link
Contributor Author

joshka commented Feb 18, 2017

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)
Copy link
Member

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).

Copy link
Contributor Author

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.

Copy link
Member

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.

@@ -0,0 +1,62 @@
def link_src_dst_dirs(src_dir, dst_dir, command, link_dir: false)
Copy link
Member

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

Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense to me

end
end

def link_manpages(path, command)
Copy link
Member

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

Copy link
Contributor Author

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

EOS
end

def unlink_src_dst_dirs(src_dir, dst_dir, unlink_dir: false)
Copy link
Member

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

@joshka joshka force-pushed the feature/install-tap-cmd-completions branch from 8ea6d37 to 46fd691 Compare February 23, 2017 22:05
@joshka
Copy link
Contributor Author

joshka commented Feb 23, 2017

Addressed module change

@joshka joshka force-pushed the feature/install-tap-cmd-completions branch from 46fd691 to beedb2b Compare February 24, 2017 21:25
@@ -0,0 +1,68 @@
module Link
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

module Utils
  module Link

Copy link
Contributor Author

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.

@MikeMcQuaid
Copy link
Member

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.
@joshka joshka force-pushed the feature/install-tap-cmd-completions branch from beedb2b to 25396d9 Compare February 26, 2017 21:40
@joshka
Copy link
Contributor Author

joshka commented Feb 26, 2017

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.

@MikeMcQuaid
Copy link
Member

Thanks for your work and patience here @joshka!

@MikeMcQuaid MikeMcQuaid merged commit 0a8c8f9 into Homebrew:master Feb 27, 2017
@Homebrew Homebrew locked and limited conversation to collaborators May 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants