This repository has been archived by the owner on Jul 4, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Allow taps to link manpages. #46795
Closed
Closed
Allow taps to link manpages. #46795
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,6 +118,8 @@ def install(options = {}) | |
raise | ||
end | ||
|
||
link_manpages | ||
|
||
formula_count = formula_files.size | ||
puts "Tapped #{formula_count} formula#{plural(formula_count, "e")} (#{@path.abv})" | ||
Descriptions.cache_formulae(formula_names) | ||
|
@@ -133,6 +135,29 @@ def install(options = {}) | |
end | ||
end | ||
|
||
def link_manpages | ||
return unless (path/"man").exist? | ||
conflicts = [] | ||
(path/"man").find do |src| | ||
next if src.directory? | ||
dst = HOMEBREW_PREFIX/"share"/src.relative_path_from(path) | ||
next if dst.symlink? && src == dst.resolved_path | ||
if dst.exist? | ||
conflicts << dst | ||
next | ||
end | ||
dst.make_relative_symlink(src) | ||
end | ||
unless conflicts.empty? | ||
onoe <<-EOS.undent | ||
Could not link #{name} manpages to: | ||
#{conflicts.join("\n")} | ||
|
||
Please delete these files and run `brew tap --repair`. | ||
EOS | ||
end | ||
end | ||
|
||
# uninstall this {Tap}. | ||
def uninstall | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A unlink method is required for uninstall. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup. |
||
raise TapUnavailableError, name unless installed? | ||
|
@@ -141,11 +166,22 @@ def uninstall | |
unpin if pinned? | ||
formula_count = formula_files.size | ||
Descriptions.uncache_formulae(formula_names) | ||
unlink_manpages | ||
@path.rmtree | ||
@path.dirname.rmdir_if_possible | ||
puts "Untapped #{formula_count} formula#{plural(formula_count, "e")}" | ||
end | ||
|
||
def unlink_manpages | ||
return unless (path/"man").exist? | ||
(path/"man").find do |src| | ||
next if src.directory? | ||
dst = HOMEBREW_PREFIX/src.relative_path_from(path) | ||
dst.delete if dst.symlink? && src == dst.resolved_path | ||
dst.parent.rmdir_if_possible | ||
end | ||
end | ||
|
||
# True if the {#remote} of {Tap} is customized. | ||
def custom_remote? | ||
return true unless remote | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We should check files by origin. Because the symlink may still be a user 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.
Ok, I think I may need to abstract out code from
Keg.link
in this case.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.
Done.