Commit 02f4901c547d302bea9cd489300f4d79d520ec35
1 parent
fe44337cbb
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.
Showing 2 changed files with 8 additions and 3 deletions Side-by-side Diff
antigen.zsh
... | ... | @@ -45,7 +45,7 @@ bundle () { |
45 | 45 | # Resolve the url. |
46 | 46 | if [[ $url != git://* && $url != https://* ]]; then |
47 | 47 | url="${url%.git}" |
48 | - name="$(basename "$url")" | |
48 | + test -z "$name" && name="$(basename "$url")" | |
49 | 49 | url="https://github.com/$url.git" |
50 | 50 | fi |
51 | 51 | |
... | ... | @@ -56,7 +56,7 @@ bundle () { |
56 | 56 | # Make an intelligent guess about the name of the plugin, if not already |
57 | 57 | # done or is explicitly specified. |
58 | 58 | if [[ -z $name ]]; then |
59 | - name="$(basename $url/$loc)" | |
59 | + name="$(basename $(echo $url | sed 's/\.git$//')/$loc)" | |
60 | 60 | fi |
61 | 61 | |
62 | 62 | # Add it to the record. |
tests/bundle-syntaxes.t
... | ... | @@ -47,7 +47,7 @@ Short repo with location and name. |
47 | 47 | |
48 | 48 | Long repo with location and name. |
49 | 49 | |
50 | - $ b https://github.com/user/repo plugin/path plugin-name | |
50 | + $ b https://github.com/user/repo.git plugin/path plugin-name | |
51 | 51 | $ lb |
52 | 52 | plugin-name https://github.com/user/repo.git plugin/path |
53 | 53 | |
... | ... | @@ -72,14 +72,19 @@ Keyword arguments, in reversed order. |
72 | 72 | Mixed positional and keyword arguments, and skip `loc`. |
73 | 73 | |
74 | 74 | $ b user/repo --name=plugin |
75 | + $ lb | |
75 | 76 | plugin https://github.com/user/repo.git / |
76 | 77 | |
77 | 78 | Just `loc`, using keyword arguments. |
78 | 79 | |
79 | 80 | $ b --loc=plugin/path |
81 | + $ lb | |
80 | 82 | path https://github.com/robbyrussell/oh-my-zsh.git plugin/path |
81 | 83 | |
82 | 84 | Just `name`, using keyword arguments. |
83 | 85 | |
84 | 86 | $ b --name=robby-oh-my-zsh |
87 | + $ lb | |
85 | 88 | robby-oh-my-zsh https://github.com/robbyrussell/oh-my-zsh.git / |
89 | + | |
90 | +TODO: Error reporting with erroneous arguments or usage with incorrect syntax. |