From 02f4901c547d302bea9cd489300f4d79d520ec35 Mon Sep 17 00:00:00 2001 From: Shrikant Sharat Date: Thu, 7 Jun 2012 16:16:04 +0530 Subject: [PATCH] Tests for all valid bundle command syntaxes. And a couple of fixes for bugs discovered along the way. These are tests *only* for the valid syntaxes. Its currently undefined behavior for invalid syntaxes. Tests for proper error reporting should also be added soon. --- antigen.zsh | 4 ++-- tests/bundle-syntaxes.t | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/antigen.zsh b/antigen.zsh index 1f19ef6..0e60915 100644 --- a/antigen.zsh +++ b/antigen.zsh @@ -45,7 +45,7 @@ bundle () { # Resolve the url. if [[ $url != git://* && $url != https://* ]]; then url="${url%.git}" - name="$(basename "$url")" + test -z "$name" && name="$(basename "$url")" url="https://github.com/$url.git" fi @@ -56,7 +56,7 @@ bundle () { # Make an intelligent guess about the name of the plugin, if not already # done or is explicitly specified. if [[ -z $name ]]; then - name="$(basename $url/$loc)" + name="$(basename $(echo $url | sed 's/\.git$//')/$loc)" fi # Add it to the record. diff --git a/tests/bundle-syntaxes.t b/tests/bundle-syntaxes.t index df1357f..310b01b 100644 --- a/tests/bundle-syntaxes.t +++ b/tests/bundle-syntaxes.t @@ -47,7 +47,7 @@ Short repo with location and name. Long repo with location and name. - $ b https://github.com/user/repo plugin/path plugin-name + $ b https://github.com/user/repo.git plugin/path plugin-name $ lb plugin-name https://github.com/user/repo.git plugin/path @@ -72,14 +72,19 @@ Keyword arguments, in reversed order. Mixed positional and keyword arguments, and skip `loc`. $ b user/repo --name=plugin + $ lb plugin https://github.com/user/repo.git / Just `loc`, using keyword arguments. $ b --loc=plugin/path + $ lb path https://github.com/robbyrussell/oh-my-zsh.git plugin/path Just `name`, using keyword arguments. $ b --name=robby-oh-my-zsh + $ lb robby-oh-my-zsh https://github.com/robbyrussell/oh-my-zsh.git / + +TODO: Error reporting with erroneous arguments or usage with incorrect syntax. -- 2.0.0