git @ Cat's Eye Technologies shelf / c5bcebd
Add shelf_fanout command. Chris Pressey 7 years ago
2 changed file(s) with 42 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
00 shelf
11 =====
22
3 *Version 0.1. Subject to change in backwards-incompatible ways.*
3 *Version 0.2-PRE. Subject to change in backwards-incompatible ways.*
44
55 Cat's Eye Technologies' **shelf** is "a package installer which
66 neither packages nor installs". It aims to be a replacement for
105105
106106 *DEST* should be a directory on the `SHELF_PATH`.
107107
108 * `shelf_fanout` *DIR*
109
110 Executes a `shelf_push` to every directory on the `SHELF_PATH` that has the
111 same basename as *DIR*.
112
108113 ### Catalog files
109114
110115 In the context of shelf, a _catalog file_ is a text file with one entry per line.
252252 fi
253253 }
254254
255 _shelf_push() {
256 src=$1
257 dest=$2
258 if [ "$src" = "$dest" ]; then
259 echo "'$dest' is same as source directory"
260 return 0
261 fi
262 if [ ! -d "$dest/.git" ]; then
263 echo "'$dest' is not a git repository"
264 return 1
265 fi
266 (cd $dest && git pull $src)
267 }
268
255269 shelf_push() {
256270 if [ "X$1" = X ]; then
257271 echo "Usage: shelf_push dest_shelf {dir}"
269283 failures=""
270284
271285 for dir in $*; do
272 project=$dir
273286 dir=`_shelf_abspath_dir "$dir"`
274287 base=`basename "$dir"`
275 dest="$dest_shelf/$base"
276
277 if [ ! -d "$dest/.git" ]; then
278 echo "'$dest' is not a git repository"
279 continue
280 fi
281
282 (cd $dest && git pull $dir)
288
289 _shelf_push $dir "$dest_shelf/$base"
290
283291 if [ $? -ne 0 ]; then
284 failures="$failures $project"
292 failures="$failures $base"
285293 fi
286294 done
287295
291299 echo "Failures: $failures"
292300 return 1
293301 fi
302 }
303
304 shelf_fanout() {
305 path=`echo "$SHELF_PATH" | sed -e 's/:/ /g'`
306
307 project=$1
308 dir=`_shelf_abspath_dir "$dir"`
309 base=`basename "$dir"`
310
311 for shelf in $path; do
312 if [ "$dir" = "$shelf/$base" ]; then
313 continue
314 fi
315 if [ -d "$shelf/$base" ]; then
316 echo "--> $shelf/$base"
317 _shelf_push $dir "$shelf/$base"
318 fi
319 done
294320 }
295321
296322 shelf_pwd() {