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

core, path: Refactor plugin path handling #131

Merged
merged 1 commit into from
Jan 24, 2017
Merged

core, path: Refactor plugin path handling #131

merged 1 commit into from
Jan 24, 2017

Conversation

mbland
Copy link
Owner

@mbland mbland commented Jan 24, 2017

I realized the while true loop from _@go.run_plugin_command_script could live comfortably in _@go.set_search_paths and handle the top-level _GO_PLUGINS_PATHS case as well.

Also, I realized that there was no need for @go to invoke _@go.run_plugin_command_script if the command script in question was from the _GO_SCRIPTS_DIR of the current plugin and not in _GO_SCRIPTS_DIR/plugins.

Plus, there was a bug whereby it'd been presumed that the plugin command path would always reside in the top-level _GO_SCRIPTS_DIR of the plugin. Now the plugin's _GO_SCRIPTS_DIR is correctly set to the /bin parent directory of the command script. I'll add thorough tests for this in a future commit/PR.

I realized the `while true` loop from `_@go.run_plugin_command_script`
could live comfortably in `_@go.set_search_paths` and handle the
top-level `_GO_PLUGINS_PATHS` case as well.

Also, I realized that there was no need for `@go` to invoke
`_@go.run_plugin_command_script` if the command script in question was
from the `_GO_SCRIPTS_DIR` of the current plugin and not in
`_GO_SCRIPTS_DIR/plugins`.

Plus, there was a bug whereby it'd been presumed that the plugin command
path would always reside in the top-level `_GO_SCRIPTS_DIR` of the
plugin. Now the plugin's `_GO_SCRIPTS_DIR` is correctly set to the
`/bin` parent directory of the command script. I'll add thorough tests
for this in a future commit/PR.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.006%) to 95.336% when pulling 04804db on plugins-paths into 69312a7 on master.

@mbland mbland merged commit 790d07b into master Jan 24, 2017
@mbland mbland deleted the plugins-paths branch January 24, 2017 11:46
mbland added a commit that referenced this pull request Jan 25, 2017
While trying to create a test case for #131 and #132 to demonstrate that
setting the `_GO_SCRIPTS_DIR` for a plugin incorrectly may cause it to
find the wrong command scripts, the test exited with an error at some
point because of the constraint that no duplicate scripts are allowed
by `_@go.find_commands` (via `_@go.merge_scripts_into_list`).

Since plugins may contain command names that match those in other
plugins or the top-level `_GO_SCRIPTS_DIR`, and since `_GO_SEARCH_PATHS`
has the correct semantics with regard to which command should take
precedence for any given script, I realized raising an error was no
longer appropriate. Now the first command found via searching
`_GO_SEARCH_PATHS` takes precedence over duplicates in later paths.
mbland added a commit that referenced this pull request Jan 25, 2017
Closes #132. Adds test cases missing from #131.

As demonstrated by the "plugin subcommand finds correct command in own
plugin" test case, not setting `_GO_SCRIPTS_DIR` correctly for a plugin
could've caused serious bugs:

- showstopper (best case): no other command script of that name exists
  outside the plugin
- obscure (medium case): finding the wrong script could cause confusing
  error messages when the interface between the caller and callee don't
  match
- subtle (worst case): finding the wrong version of a script could
  exhibit confusing behaviors that might only become apparent
  after-the-fact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants