Commit a5e21a6a10f3aa0862b3c0641ae233d434bb8d17
1 parent
01590aa28a
Do comparisons with directory names in -cleanup.
The directory names were being converted to urls and then compared to the contents of the record. The problem with this is there could be directories with extremely wierd names in there, not created by antigen. This could throw the dir->url conversion off. So, with this, the urls from the record are converted to directory names and are compared with the contents of repos/. Any directory unaccounted for will be converted to a repo url, solely for the purpose of displaying to the user. After confirmation, these directories are deleted, whether they represent a git clone or not.
Showing 1 changed file with 11 additions and 9 deletions Side-by-side Diff
antigen.zsh
... | ... | @@ -116,7 +116,6 @@ antigen-update () { |
116 | 116 | # Echo the full path to the clone directory. |
117 | 117 | echo -n $ADOTDIR/repos/ |
118 | 118 | echo "$url" | sed \ |
119 | - -e 's/\.git$//' \ | |
120 | 119 | -e 's./.-SLASH-.g' \ |
121 | 120 | -e 's.:.-COLON-.g' \ |
122 | 121 | -e 's.|.-PIPE-.g' |
... | ... | @@ -130,8 +129,7 @@ antigen-update () { |
130 | 129 | -e "s:^$ADOTDIR/repos/::" \ |
131 | 130 | -e 's.-SLASH-./.g' \ |
132 | 131 | -e 's.-COLON-.:.g' \ |
133 | - -e 's.-PIPE-.|.g' \ | |
134 | - | awk '/^\// {print; next} {print $0 ".git"}' | |
132 | + -e 's.-PIPE-.|.g' | |
135 | 133 | } |
136 | 134 | |
137 | 135 | -antigen-ensure-repo () { |
... | ... | @@ -228,12 +226,13 @@ antigen-cleanup () { |
228 | 226 | |
229 | 227 | # Find directores in ADOTDIR/repos, that are not in the bundles record. |
230 | 228 | local unused_clones="$(comm -13 \ |
231 | - <(-antigen-echo-record | awk '{print $1}' | sort -u) \ | |
232 | - <(ls "$ADOTDIR/repos" \ | |
229 | + <(-antigen-echo-record \ | |
230 | + | awk '{print $1}' \ | |
233 | 231 | | while read line; do |
234 | - -antigen-get-clone-url "$line" | |
232 | + -antigen-get-clone-dir "$line" | |
235 | 233 | done \ |
236 | - | sort -u))" | |
234 | + | sort -u) \ | |
235 | + <(ls -d "$ADOTDIR/repos/"* | sort -u))" | |
237 | 236 | |
238 | 237 | if [[ -z $unused_clones ]]; then |
239 | 238 | echo "You don't have any unidentified bundles." |
... | ... | @@ -242,14 +241,17 @@ antigen-cleanup () { |
242 | 241 | |
243 | 242 | echo 'You have clones for the following repos, but are not used.' |
244 | 243 | echo "$unused_clones" \ |
244 | + | while read line; do | |
245 | + -antigen-get-clone-url "$line" | |
246 | + done \ | |
245 | 247 | | sed -e 's/^/ /' -e 's/|/, branch /' |
246 | 248 | |
247 | 249 | if $force || (echo -n '\nDelete them all? [y/N] '; read -q); then |
248 | 250 | echo |
249 | 251 | echo |
250 | 252 | echo "$unused_clones" | while read line; do |
251 | - echo -n "Deleting clone for $line..." | |
252 | - rm -rf "$(-antigen-get-clone-dir $line)" | |
253 | + echo -n "Deleting clone for $(-antigen-get-clone-url "$line")..." | |
254 | + rm -rf "$line" | |
253 | 255 | echo ' done.' |
254 | 256 | done |
255 | 257 | else |