From 7e4b800b650f35fd8aa03abea528f708c4f6286d Mon Sep 17 00:00:00 2001 From: Jorge Bucaran Date: Thu, 25 Feb 2016 13:48:48 +0900 Subject: [PATCH] Improve __fisher_name name resolution algorithm. Improve __fisher_name name resolution from paths or URLs more accurately. Now correctly process names paths such as fisher-plugin-*, fisher-theme-* and other permutations. --- CHANGELOG.md | 2 + functions/__fisher_name.fish | 5 ++- functions/fisher_uninstall.fish | 1 - test/name.fish | 69 +++++++++++++++++++++++++++++---- 4 files changed, 68 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5159197..16cd8c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ * Update plugins with a dirty working tree by recording changes in the stash and re-reapplying them again after the git-pull update strategy completes. +* Improve `__fisher_name` name resolution from paths or URLs more accurately. Now correctly process names paths such as `fisher-plugin-*`, `fisher-theme-*` and other permutations. + * Make `__fisher_key_bindings_undo` smarter by supporting more complex `bind` expressions, such as those inside conditional statements. Close #121. * The Quickstart Guide is now available in [Chinese](https://github.com/fisherman/fisherman/wiki/快速上手指南), [Russian](https://github.com/fisherman/fisherman/wiki/Краткое-Руководство) and [Korean](https://github.com/fisherman/fisherman/wiki/빠르게-살펴보기). Thanks to @pickfire, @denji, @dfdgsdfg. You folks are awesome! diff --git a/functions/__fisher_name.fish b/functions/__fisher_name.fish index 1f8efba..6ab8612 100644 --- a/functions/__fisher_name.fish +++ b/functions/__fisher_name.fish @@ -1,3 +1,6 @@ function __fisher_name - sed -E 's|.*/(.*)|\1|; s/^(plugin|omf-theme|theme|pkg|omf|fish|fisher)-//' + sed -E ' + s|.*/(.*)|\1| + s/(plugin|omf-theme|theme|pkg|omf|fish|fisher|fisherman)-//g + ' end diff --git a/functions/fisher_uninstall.fish b/functions/fisher_uninstall.fish index a6098f9..0aada6b 100644 --- a/functions/fisher_uninstall.fish +++ b/functions/fisher_uninstall.fish @@ -38,7 +38,6 @@ function fisher_uninstall -d "Uninstall Plugins" set -l skipped if set -q plugins[1] - printf "%s\n" $plugins else __fisher_file diff --git a/test/name.fish b/test/name.fish index 411eac9..50248ba 100644 --- a/test/name.fish +++ b/test/name.fish @@ -1,31 +1,86 @@ -test "$TESTNAME - Remove plugin- prefix" +test "$TESTNAME - Remove plugin-* prefix" bar = (echo https://github.com/foo/plugin-bar | __fisher_name) end +test "$TESTNAME - Remove plugin-theme-* prefix" + bar = (echo https://github.com/foo/plugin-theme-bar | __fisher_name) +end -test "$TESTNAME - Remove omf-theme- prefix" +test "$TESTNAME - Remove omf-theme-* prefix" bar = (echo https://github.com/foo/omf-theme-bar | __fisher_name) end -test "$TESTNAME - Remove theme- prefix" +test "$TESTNAME - Remove theme-omf-* prefix" + bar = (echo https://github.com/foo/theme-omf-bar | __fisher_name) +end + +test "$TESTNAME - Remove theme-* prefix" bar = (echo https://github.com/foo/theme-bar | __fisher_name) end -test "$TESTNAME - Remove pkg- prefix" +test "$TESTNAME - Remove pkg-* prefix" bar = (echo https://github.com/foo/pkg-bar | __fisher_name) end -test "$TESTNAME - Remove omf- prefix" +test "$TESTNAME - Remove pkg-pkg-* prefix" + bar = (echo https://github.com/foo/pkg-pkg-bar | __fisher_name) +end + +test "$TESTNAME - Remove omf-* prefix" bar = (echo https://github.com/foo/omf-bar | __fisher_name) end -test "$TESTNAME - Remove fish- prefix" +test "$TESTNAME - Remove fish-* prefix" bar = (echo https://github.com/foo/fish-bar | __fisher_name) end -test "$TESTNAME - Remove fisher- prefix" +test "$TESTNAME - Remove fish-fish-* prefix" + bar = (echo https://github.com/foo/fish-fish-bar | __fisher_name) +end + +test "$TESTNAME - Remove fisher-* prefix" bar = (echo https://github.com/foo/fisher-bar | __fisher_name) end +test "$TESTNAME - Remove fisher-fisher-* prefix" + bar = (echo https://github.com/foo/fisher-fisher-bar | __fisher_name) +end + +test "$TESTNAME - Remove fisher-theme-* prefix" + bar = (echo https://github.com/foo/fisher-theme-bar | __fisher_name) +end + +test "$TESTNAME - Remove theme-fisher-* prefix" + bar = (echo https://github.com/foo/theme-fisher-bar | __fisher_name) +end + +test "$TESTNAME - Remove fish-theme-* prefix" + bar = (echo https://github.com/foo/fish-theme-bar | __fisher_name) +end + +test "$TESTNAME - Remove theme-fish-* prefix" + bar = (echo https://github.com/foo/theme-fish-bar | __fisher_name) +end + +test "$TESTNAME - Remove fish-pkg-* prefix" + bar = (echo https://github.com/foo/fish-pkg-bar | __fisher_name) +end + +test "$TESTNAME - Remove pkg-fish-* prefix" + bar = (echo https://github.com/foo/pkg-fish-bar | __fisher_name) +end + +test "$TESTNAME - Remove fisherman-* prefix" + bar = (echo https://github.com/foo/fisherman-bar | __fisher_name) +end + +test "$TESTNAME - Remove fisherman-theme-* prefix" + bar = (echo https://github.com/foo/fisherman-theme-bar | __fisher_name) +end + +test "$TESTNAME - Remove fisherman-plugin-* prefix" + bar = (echo https://github.com/foo/fisherman-plugin-bar | __fisher_name) +end + test "$TESTNAME - Pass through other names" bar = (echo https://github.com/foo/bar | __fisher_name) end