From 4dbb1ca57cc02477eb0f00ee3b1d405a0f9eba0c Mon Sep 17 00:00:00 2001
From: Itzik Ephraim <oranja@gmail.com>
Date: Fri, 25 Dec 2015 18:02:44 +0200
Subject: [PATCH] Support omf- prefix for packages

---
 pkg/omf/cli/omf.bundle.install.fish | 2 +-
 pkg/omf/cli/omf.bundle.remove.fish  | 9 ++++-----
 pkg/omf/cli/omf.install.fish        | 4 ++--
 pkg/omf/util/omf.package_name.fish  | 3 +++
 4 files changed, 10 insertions(+), 8 deletions(-)
 create mode 100644 pkg/omf/util/omf.package_name.fish

diff --git a/pkg/omf/cli/omf.bundle.install.fish b/pkg/omf/cli/omf.bundle.install.fish
index 908dad2..94549eb 100644
--- a/pkg/omf/cli/omf.bundle.install.fish
+++ b/pkg/omf/cli/omf.bundle.install.fish
@@ -16,7 +16,7 @@ function omf.bundle.install
       set name_or_url (echo $record | cut -s -d' ' -f2- | sed 's/ //g')
       test -n "$name_or_url"; or continue
 
-      set name (basename $name_or_url | sed 's/\.git//;s/^pkg-//;s/^plugin-//;s/^theme-//')
+      set name (omf.package_name $name_or_url)
 
       if not contains $name $packages
         omf.install $name_or_url;
diff --git a/pkg/omf/cli/omf.bundle.remove.fish b/pkg/omf/cli/omf.bundle.remove.fish
index 1006238..cc2bdad 100644
--- a/pkg/omf/cli/omf.bundle.remove.fish
+++ b/pkg/omf/cli/omf.bundle.remove.fish
@@ -10,12 +10,11 @@ function omf.bundle.remove
 
       for record in $bundle_contents
         set record_type (echo $record | cut -d' ' -f1)
-        set record_name (echo $record | cut -d' ' -f2-)
-        set record_basename (basename (echo $record_name | \
-          sed -e 's/\.git$//') | sed 's/^pkg-//;s/^plugin-//;s/^theme-//')
+        set record_name_or_url (echo $record | cut -d' ' -f2-)
+        set record_name (omf.package_name $record_name_or_url)
 
-        if not test "$type" = "$record_type" -a "$name" = "$record_basename"
-          echo "$record_type $record_name" >> $bundle
+        if not test "$type" = "$record_type" -a "$name" = "$record_name"
+          echo "$record_type $record_name_or_url" >> $bundle
         end
       end
     end
diff --git a/pkg/omf/cli/omf.install.fish b/pkg/omf/cli/omf.install.fish
index 1fb77d6..ec48524 100644
--- a/pkg/omf/cli/omf.install.fish
+++ b/pkg/omf/cli/omf.install.fish
@@ -17,9 +17,9 @@ function omf.install -a name_or_url
 
   if test -e $OMF_PATH/db/$parent_path/$name_or_url
     set name $name_or_url
-    set url (cat $OMF_PATH/db/$parent_path/$name_or_url)
+    set url (cat $OMF_PATH/db/$parent_path/$name)
   else
-    set name (basename $name_or_url | sed 's/^pkg-//;s/^plugin-//;s/^theme-//;s/\.git$//')
+    set name (omf.package_name $name_or_url)
     set url $name_or_url
   end
 
diff --git a/pkg/omf/util/omf.package_name.fish b/pkg/omf/util/omf.package_name.fish
new file mode 100644
index 0000000..77f730c
--- /dev/null
+++ b/pkg/omf/util/omf.package_name.fish
@@ -0,0 +1,3 @@
+function omf.package_name -a name_or_url
+  basename $name_or_url | sed -E 's/^(omf-)?((plugin|pkg|theme)-)?//;s/.git$//'
+end
-- 
GitLab