diff --git a/PLUGINS.md b/PLUGINS.md index f5de7c9..61c4724 100644 --- a/PLUGINS.md +++ b/PLUGINS.md @@ -19,7 +19,7 @@ Location | Contains `./.git-semver/plugins` | Project plugins (added and committed) which run on just the current git project `${HOME}/.git-semver/plugins/` | User plugins which run on all git projects -Plugin can stop a tag being generated (for example if a version file does not exist). +Plugins are executed orderedly, so you can number-prefix them to ensure execution order. Number prefixed plugins will run before anything else, and they will be executed from lower to higher. Plugins can also stop a tag being generated (for example if a version file does not exist). See [Contributing](#contributing) for detail on creating a plugin or take a look at the [example plugin] or any of the [real plugins](#plugins). diff --git a/git-semver.sh b/git-semver.sh index 51cbfc6..8d85209 100755 --- a/git-semver.sh +++ b/git-semver.sh @@ -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) + do + echo "${plugin_type},${plugin_dir}/${plugin}" + done + for plugin in $(find "${plugin_dir}" -maxdepth 1 -type f -exec basename {} \; | grep "^[^0-9]" | LC_ALL="C" sort -g) + do + echo "${plugin_type},${plugin_dir}/${plugin}" + done fi done }