Have shelf_populate_from_git and shelf_pin track failures and fail.
Chris Pressey
3 years ago
415 | 415 | |
416 | 416 | shelf_populate_from_git() { |
417 | 417 | git_prefix="$1" |
418 | failures="" | |
418 | 419 | while read -r line; do |
419 | 420 | project=`echo $line | awk '{split($0,a,"@"); print a[1]}'` |
420 | 421 | tag=`echo $line | awk '{split($0,a,"@"); print a[2]}'` |
425 | 426 | dest=`basename $url` |
426 | 427 | |
427 | 428 | 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 $base" | |
432 | fi | |
429 | 433 | fi |
430 | 434 | |
431 | 435 | branch=`cd $dest && git rev-parse --abbrev-ref HEAD` |
432 | 436 | if [ "X$branch" != "XHEAD" ]; then |
433 | 437 | (echo -n "$dest: " && cd $dest && git pull) |
438 | if [ $? -ne 0 ]; then | |
439 | failures="$failures $base" | |
440 | fi | |
434 | 441 | fi |
435 | 442 | |
436 | 443 | if [ "X$tag" != X ]; then |
437 | 444 | (echo -n "$dest: " && cd $dest && git checkout $tag) |
438 | fi | |
439 | done | |
445 | if [ $? -ne 0 ]; then | |
446 | failures="$failures $base" | |
447 | fi | |
448 | fi | |
449 | done | |
450 | ||
451 | if [ "X$failures" = X ]; then | |
452 | return 0 | |
453 | else | |
454 | echo "Failures: $failures" | |
455 | return 1 | |
456 | fi | |
440 | 457 | } |
441 | 458 | |
442 | 459 | shelf_mirror_from_git() { |
473 | 490 | } |
474 | 491 | |
475 | 492 | shelf_pin() { |
493 | failures="" | |
476 | 494 | while read -r line; do |
477 | 495 | project=`echo $line | awk '{split($0,a,"@"); print a[1]}'` |
478 | 496 | tag=`echo $line | awk '{split($0,a,"@"); print a[2]}'` |
481 | 499 | if [ -d $dest ]; then |
482 | 500 | if [ "X$tag" != X ]; then |
483 | 501 | (echo -n "$dest: " && cd $dest && git checkout $tag) |
484 | fi | |
485 | fi | |
486 | done | |
502 | if [ $? -ne 0 ]; then | |
503 | failures="$failures $base" | |
504 | fi | |
505 | fi | |
506 | fi | |
507 | done | |
508 | if [ "X$failures" = X ]; then | |
509 | return 0 | |
510 | else | |
511 | echo "Failures: $failures" | |
512 | return 1 | |
513 | fi | |
487 | 514 | } |
488 | 515 | |
489 | 516 | shelf_unpin() { |