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

Sort plugin exec order #41

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

fernandocollova
Copy link
Contributor

As discussed in #36, this code sorts plugins by number before running them.

Please let me know of any improvements you see on this code, and thanks in advance for reviewing.

Copy link
Owner

@markchalloner markchalloner left a comment

Choose a reason for hiding this comment

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

Thanks, it's looking good just a couple of minor suggestions.

Can you also update the CHANGELOG file with the changes from this PR and your previous one?

@@ -63,7 +63,15 @@ plugin-list() {
plugin_dir="${dirs[${i}]}/.git-semver/plugins"
if [ -d "${plugin_dir}" ]
then
find "${plugin_dir}" -maxdepth 1 -type f -exec echo "${plugin_type},{}" \;
plugins=()
Copy link
Owner

Choose a reason for hiding this comment

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

Is this variable needed? I can't see it being referenced in the following code.

Copy link
Owner

Choose a reason for hiding this comment

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

Actually I realise this may have been to cache the result of the find. That would save a command.

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 that might actually be a mistake. I don't see it in the master branch of this repo, and I added it on the Fixed MacOS compatibility commit for no apparent reason. And, if it actually does any caching, I can't see how, but I'm happy to leave it there if it's useful.

@@ -63,7 +63,15 @@ plugin-list() {
plugin_dir="${dirs[${i}]}/.git-semver/plugins"
if [ -d "${plugin_dir}" ]
then
find "${plugin_dir}" -maxdepth 1 -type f -exec echo "${plugin_type},{}" \;
plugins=()
for plugin in $(find "${plugin_dir}" -maxdepth 1 -type f -exec basename {} \; | grep "^[0-9]" | LC_ALL="C" sort -g)
Copy link
Owner

Choose a reason for hiding this comment

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

Probably worth a quick comment here as to why the loop is run twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That loop is ran twice to first echo the numeric prefixed plugins (note that the output is piped to a grep) and then echo the not numeric ones. This is basically what you suggested doing in this comment.

As you also said, it's hacky, but I really couldn't come with a better solution :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants