Commit 39379a87845eae73deb76c187732563a03c00140

Authored by Shrikant Sharat
1 parent 8a241a1678

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.

Showing 1 changed file with 15 additions and 4 deletions Side-by-side Diff

... ... @@ -45,10 +45,7 @@ antigen-bundle () {
45 45 done
46 46  
47 47 # Resolve the url.
48   - if [[ $url != git://* && $url != https://* && $url != /* ]]; then
49   - url="${url%.git}"
50   - url="https://github.com/$url.git"
51   - fi
  48 + url="$(-antigen-resolve-bundle-url "$url")"
52 49  
53 50 # Add it to the record.
54 51 _ANTIGEN_BUNDLE_RECORD="$_ANTIGEN_BUNDLE_RECORD\n$url $loc $btype $branch"
... ... @@ -61,6 +58,20 @@ antigen-bundle () {
61 58  
62 59 }
63 60  
  61 +-antigen-resolve-bundle-url () {
  62 + # Given an acceptable short/full form of a bundle's repo url, this function
  63 + # echoes the full form of the repo's clone url.
  64 +
  65 + local url="$1"
  66 +
  67 + if [[ $url != git://* && $url != https://* && $url != /* ]]; then
  68 + url="${url%.git}"
  69 + url="https://github.com/$url.git"
  70 + fi
  71 +
  72 + echo "$url"
  73 +}
  74 +
64 75 antigen-bundles () {
65 76 # Bulk add many bundles at one go. Empty lines and lines starting with a `#`
66 77 # are ignored. Everything else is given to `antigen-bundle` as is, no