From 39379a87845eae73deb76c187732563a03c00140 Mon Sep 17 00:00:00 2001 From: Shrikant Sharat Date: Fri, 13 Jul 2012 21:48:11 +0530 Subject: [PATCH] Move url resolving to a separate function. This is done so that url resolving logic can be tested and to make it easier to extend it to more complex resolving rules in the future. --- antigen.zsh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/antigen.zsh b/antigen.zsh index 49a4267..fc43c98 100644 --- a/antigen.zsh +++ b/antigen.zsh @@ -45,10 +45,7 @@ antigen-bundle () { done # Resolve the url. - if [[ $url != git://* && $url != https://* && $url != /* ]]; then - url="${url%.git}" - url="https://github.com/$url.git" - fi + url="$(-antigen-resolve-bundle-url "$url")" # Add it to the record. _ANTIGEN_BUNDLE_RECORD="$_ANTIGEN_BUNDLE_RECORD\n$url $loc $btype $branch" @@ -61,6 +58,20 @@ antigen-bundle () { } +-antigen-resolve-bundle-url () { + # Given an acceptable short/full form of a bundle's repo url, this function + # echoes the full form of the repo's clone url. + + local url="$1" + + if [[ $url != git://* && $url != https://* && $url != /* ]]; then + url="${url%.git}" + url="https://github.com/$url.git" + fi + + echo "$url" +} + antigen-bundles () { # Bulk add many bundles at one go. Empty lines and lines starting with a `#` # are ignored. Everything else is given to `antigen-bundle` as is, no -- 2.0.0