git @ Cat's Eye Technologies shelf / f5ae5de
Merge pull request #5 from catseye/develop-0.6 Develop 0.6 Chris Pressey authored 1 year, 9 months ago GitHub committed 1 year, 9 months ago
2 changed file(s) with 59 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
00 `shelf`
11 =======
22
3 _Version 0.5_
3 _Version 0.6_
44 | _Entry_ [@ catseye.tc](https://catseye.tc/node/shelf)
55 | _See also:_ [ellsync](https://github.com/catseye/ellsync#readme)
66 ∘ [tagfarm](https://github.com/catseye/tagfarm#readme)
140140
141141 The current directory is assumed to be on `SHELF_PATH`.
142142
143 * `shelf_mirror_from_git` *PREFIX* < *CATALOG*
143 * `shelf_mirror_from_git` *PREFIX* < *CATALOG*
144144
145145 The same as `shelf_populate_from_git`, but uses `git clone --mirror` to
146146 clone each new repo directory, and `git remote update` to update it.
149149
150150 When executed from a directory containing repositories listed in *CATALOG*,
151151 create a non-version-controlled directory in *DIR* from each of the listed
152 repositories.
152 repositories, at the tag or branch given by its tag name.
153
154 Two environment variables affect the operation of `shelf_cast`:
155
156 `SHELF_LOWERCASE`, if set, causes the casted directory to be created as
157 the lower-cased version of the catalog entry name.
158
159 `SHELF_CAST_REF`, if set, overrides the tag given in the catalog entry.
153160
154161 * `shelf_pin` < *CATALOG*
155162
188195
189196 ### History
190197
198 #### 0.6
199
200 * `shelf_cast`, by default, now casts the version of the source
201 repository at the tag given in each catalog entry, instead of
202 always casting `HEAD`. Setting the environment variable
203 `SHELF_CAST_REF` to `HEAD` can override this new behaviour.
204 * Made `shelf_populate_from_git` and `shelf_pin` record a list of
205 directories which they failed to process, and fail themselves at the
206 end of procssing if that list is not empty.
207
191208 #### 0.5
192209
193210 * Changed `shelf_which` to [not use the which command][] and to produce
415415
416416 shelf_populate_from_git() {
417417 git_prefix="$1"
418 failures=""
418419 while read -r line; do
419420 project=`echo $line | awk '{split($0,a,"@"); print a[1]}'`
420421 tag=`echo $line | awk '{split($0,a,"@"); print a[2]}'`
425426 dest=`basename $url`
426427
427428 if [ ! -d $dest ]; then
428 echo -n "$dest: " && git clone $url $dest
429 (echo -n "$dest: " && git clone $url $dest)
430 if [ $? -ne 0 ]; then
431 failures="$failures $dest"
432 fi
429433 fi
430434
431435 branch=`cd $dest && git rev-parse --abbrev-ref HEAD`
432436 if [ "X$branch" != "XHEAD" ]; then
433437 (echo -n "$dest: " && cd $dest && git pull)
438 if [ $? -ne 0 ]; then
439 failures="$failures $dest"
440 fi
434441 fi
435442
436443 if [ "X$tag" != X ]; then
437444 (echo -n "$dest: " && cd $dest && git checkout $tag)
438 fi
439 done
445 if [ $? -ne 0 ]; then
446 failures="$failures $dest"
447 fi
448 fi
449 done
450
451 if [ "X$failures" = X ]; then
452 return 0
453 else
454 echo "shelf_populate_from_git failed! Failures: ($failures)"
455 return 1
456 fi
440457 }
441458
442459 shelf_mirror_from_git() {
460477
461478 while read -r line; do
462479 project=`echo $line | awk '{split($0,a,"@"); print a[1]}'`
463 tag=`echo $line | awk '{split($0,a,"@"); print a[2]}'`
480 if [ "X$SHELF_CAST_REF" != X ]; then
481 tag="$SHELF_CAST_REF"
482 else
483 tag=`echo $line | awk '{split($0,a,"@"); print a[2]}'`
484 fi
464485
465486 dest_project=$project
466487 if [ "X$SHELF_LOWERCASE" != X ]; then
468489 fi
469490
470491 rm -rf "$projection_dir/$dest_project"
471 (echo "$projection_dir/$dest_project" && cd $project && git archive --format=tar --prefix=$dest_project/ HEAD | (cd $projection_dir && tar xf -) )
492 (echo "$projection_dir/$dest_project" && cd $project && git archive --format=tar --prefix=$dest_project/ $tag | (cd $projection_dir && tar xf -) )
472493 done
473494 }
474495
475496 shelf_pin() {
497 failures=""
476498 while read -r line; do
477499 project=`echo $line | awk '{split($0,a,"@"); print a[1]}'`
478500 tag=`echo $line | awk '{split($0,a,"@"); print a[2]}'`
481503 if [ -d $dest ]; then
482504 if [ "X$tag" != X ]; then
483505 (echo -n "$dest: " && cd $dest && git checkout $tag)
484 fi
485 fi
486 done
506 if [ $? -ne 0 ]; then
507 failures="$failures $dest"
508 fi
509 fi
510 fi
511 done
512 if [ "X$failures" = X ]; then
513 return 0
514 else
515 echo "shelf_pin failed! Failures: ($failures)"
516 return 1
517 fi
487518 }
488519
489520 shelf_unpin() {