diff options
| author | Bundlerbot <bot@bundler.io> | 2018-11-16 10:37:20 +0000 |
|---|---|---|
| committer | Bundlerbot <bot@bundler.io> | 2018-11-16 10:37:20 +0000 |
| commit | 05b552ccafb6fc6492e498edaeddd0979657c517 (patch) | |
| tree | 93958bc4fe5663783d3625a8a8a2f3906b9bd6b1 /lib | |
| parent | 172ec59db53ec05a91c0d9eb72e2d715ae82f3c0 (diff) | |
| parent | 19237b490b690b8f9cf922f2ac982ef684c23cee (diff) | |
| download | bundler-05b552ccafb6fc6492e498edaeddd0979657c517.tar.gz | |
Merge #6775
6775: [Plugin::Index] Only register each plugin once for a given hook r=colby-swandale a=segiddins
### What was the end-user problem that led to this PR?
The problem was running `plugin install` twice for a plugin withs hooks would cause that hook to be registered twice.
Closes #6771.
### What was your diagnosis of the problem?
My diagnosis was a plugin's hooks should only be run once per event.
### What is your fix for the problem, implemented in this PR?
My fix is to `uniq` the list of plugins registered for each event.
Co-authored-by: Samuel Giddins <segiddins@segiddins.me>
Co-authored-by: Olle Jonsson <olle.jonsson@gmail.com>
Co-authored-by: Colby Swandale <me@colby.fyi>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/bundler/plugin/index.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/bundler/plugin/index.rb b/lib/bundler/plugin/index.rb index 642e7c8163..faabf3a8d1 100644 --- a/lib/bundler/plugin/index.rb +++ b/lib/bundler/plugin/index.rb @@ -58,7 +58,10 @@ module Bundler raise SourceConflict.new(name, common) unless common.empty? sources.each {|k| @sources[k] = name } - hooks.each {|e| (@hooks[e] ||= []) << name } + hooks.each do |event| + event_hooks = (@hooks[event] ||= []) << name + event_hooks.uniq! + end @plugin_paths[name] = path @load_paths[name] = load_paths |
