Add shelf_fanout command.
Chris Pressey
7 years ago
0 | 0 |
shelf
|
1 | 1 |
=====
|
2 | 2 |
|
3 | |
*Version 0.1. Subject to change in backwards-incompatible ways.*
|
|
3 |
*Version 0.2-PRE. Subject to change in backwards-incompatible ways.*
|
4 | 4 |
|
5 | 5 |
Cat's Eye Technologies' **shelf** is "a package installer which
|
6 | 6 |
neither packages nor installs". It aims to be a replacement for
|
|
105 | 105 |
|
106 | 106 |
*DEST* should be a directory on the `SHELF_PATH`.
|
107 | 107 |
|
|
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 |
|
108 | 113 |
### Catalog files
|
109 | 114 |
|
110 | 115 |
In the context of shelf, a _catalog file_ is a text file with one entry per line.
|
252 | 252 |
fi
|
253 | 253 |
}
|
254 | 254 |
|
|
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 |
|
255 | 269 |
shelf_push() {
|
256 | 270 |
if [ "X$1" = X ]; then
|
257 | 271 |
echo "Usage: shelf_push dest_shelf {dir}"
|
|
269 | 283 |
failures=""
|
270 | 284 |
|
271 | 285 |
for dir in $*; do
|
272 | |
project=$dir
|
273 | 286 |
dir=`_shelf_abspath_dir "$dir"`
|
274 | 287 |
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 |
|
283 | 291 |
if [ $? -ne 0 ]; then
|
284 | |
failures="$failures $project"
|
|
292 |
failures="$failures $base"
|
285 | 293 |
fi
|
286 | 294 |
done
|
287 | 295 |
|
|
291 | 299 |
echo "Failures: $failures"
|
292 | 300 |
return 1
|
293 | 301 |
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
|
294 | 320 |
}
|
295 | 321 |
|
296 | 322 |
shelf_pwd() {
|