Commit 2923c490cc7e8f4d3677aef51e0605d91c61ed85

Authored by Shrikant Sharat
1 parent 759e381e13

Branch information is saved along with the url.

Keeping the branch and the repo url as separate fields for each bundle entry,
seems to be only causing trouble. Now, the repo url and the branch are joined
togather with a `|` character and split only when needed.

Showing 1 changed file with 21 additions and 29 deletions Side-by-side Diff

... ... @@ -15,7 +15,7 @@ antigen-bundle () {
15 15 # Bundle spec arguments' default values.
16 16 local url="$ANTIGEN_DEFAULT_REPO_URL"
17 17 local loc=/
18   - local branch=-
  18 + local branch=
19 19 local btype=plugin
20 20  
21 21 # Set spec values based on the positional arguments.
... ... @@ -47,14 +47,19 @@ antigen-bundle () {
47 47 # Resolve the url.
48 48 url="$(-antigen-resolve-bundle-url "$url")"
49 49  
  50 + # Add the branch information to the url.
  51 + if [[ ! -z $branch ]]; then
  52 + url="$url|$branch"
  53 + fi
  54 +
50 55 # Add it to the record.
51   - _ANTIGEN_BUNDLE_RECORD="$_ANTIGEN_BUNDLE_RECORD\n$url $loc $btype $branch"
  56 + _ANTIGEN_BUNDLE_RECORD="$_ANTIGEN_BUNDLE_RECORD\n$url $loc $btype"
52 57  
53 58 # Ensure a clone exists for this repo.
54   - -antigen-ensure-repo "$url" "$branch"
  59 + -antigen-ensure-repo "$url"
55 60  
56 61 # Load the plugin.
57   - -antigen-load "$url" "$loc" "$btype" "$branch"
  62 + -antigen-load "$url" "$loc" "$btype"
58 63  
59 64 }
60 65  
... ... @@ -93,10 +98,10 @@ antigen-bundles () {
93 98 antigen-update () {
94 99 # Update your bundles, i.e., `git pull` in all the plugin repos.
95 100 -antigen-echo-record \
96   - | awk '{print $1 "|" $4}' \
  101 + | awk '{print $1}' \
97 102 | sort -u \
98   - | while read url_line; do
99   - -antigen-ensure-repo --update "${url_line%|*}" "${url_line#*|}"
  103 + | while read url; do
  104 + -antigen-ensure-repo --update "$url"
100 105 done
101 106 }
102 107  
... ... @@ -104,22 +109,13 @@ antigen-update () {
104 109 # Takes a repo url and gives out the path that this url needs to be cloned
105 110 # to. Doesn't actually clone anything.
106 111 # TODO: Memoize?
107   - local url="$1"
108   - local branch="$2"
109 112  
110   - # The branched_url will be the same as the url itself, unless there is no
111   - # branch specified.
112   - local branched_url="$url"
113   -
114   - # If a branch is specified, i.e., branch is not `-`, append it to the url,
115   - # separating with a pipe character.
116   - if [[ "$branch" != - ]]; then
117   - branched_url="$branched_url|$branch"
118   - fi
  113 + # The url given.
  114 + local url="$1"
119 115  
120 116 # Echo the full path to the clone directory.
121 117 echo -n $ADOTDIR/repos/
122   - echo "$branched_url" | sed \
  118 + echo "$url" | sed \
123 119 -e 's/\.git$//' \
124 120 -e 's./.-SLASH-.g' \
125 121 -e 's.:.-COLON-.g' \
... ... @@ -153,21 +149,20 @@ antigen-update () {
153 149  
154 150 # Get the clone's directory as per the given repo url and branch.
155 151 local url="$1"
156   - local branch="$2"
157   - local clone_dir="$(-antigen-get-clone-dir $url $branch)"
  152 + local clone_dir="$(-antigen-get-clone-dir $url)"
158 153  
159 154 # Clone if it doesn't already exist.
160 155 if [[ ! -d $clone_dir ]]; then
161   - git clone "$url" "$clone_dir"
  156 + git clone "${url%|*}" "$clone_dir"
162 157 elif $update; then
163 158 # Pull changes if update requested.
164 159 git --git-dir "$clone_dir/.git" --work-tree "$clone_dir" pull
165 160 fi
166 161  
167 162 # If its a specific branch that we want, checkout that branch.
168   - if [[ "$branch" != - ]]; then
  163 + if [[ $url == *\|* ]]; then
169 164 git --git-dir "$clone_dir/.git" --work-tree "$clone_dir" \
170   - checkout "$branch"
  165 + checkout "${url#*|}"
171 166 fi
172 167  
173 168 }
... ... @@ -177,10 +172,9 @@ antigen-update () {
177 172 local url="$1"
178 173 local loc="$2"
179 174 local btype="$3"
180   - local branch="$4"
181 175  
182 176 # The full location where the plugin is located.
183   - local location="$(-antigen-get-clone-dir "$url" "$branch")/$loc"
  177 + local location="$(-antigen-get-clone-dir "$url")/$loc"
184 178  
185 179 if [[ $btype == theme ]]; then
186 180  
... ... @@ -229,9 +223,7 @@ antigen-cleanup () {
229 223  
230 224 # Find directores in ADOTDIR/repos, that are not in the bundles record.
231 225 local unused_clones="$(comm -13 \
232   - <(-antigen-echo-record \
233   - | awk '{print ($4 == "-" ? $1 : $1 "|" $4)}' \
234   - | sort -u) \
  226 + <(-antigen-echo-record | awk '{print $1}' | sort -u) \
235 227 <(ls "$ADOTDIR/repos" \
236 228 | while read line; do
237 229 -antigen-get-clone-url "$line"